API
Authentication
There's no sign-up and no key to create. Your first claim starts a session, and the cookie it sets is what makes that claim yours.
Sessions without sign-up
A request with no session can do one thing that matters: create a claim. When it does, the server makes an account, starts a session for it, and sets the prufy_session cookie on the response. From then on, that cookie is the credential.
The domain is checked before any of that happens, so a typo doesn't leave an empty account behind. A request that already has a session keeps it: claiming a second domain adds to the same account.
curl -X POST 'https://www.prufy.dev/api/v1/claims' \
-c cookies.txt -b cookies.txt \
-H 'content-type: application/json' \
-d '{
"input": "yourcompany.com"
}'const response = await fetch("https://www.prufy.dev/api/v1/claims", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ input: "yourcompany.com" }),
})
// The session cookie is what makes this claim yours. Keep it for later requests.
const cookie = response.headers.getSetCookie()[0]?.split(";")[0]
const data = await response.json()import requests
# A Session keeps the cookie the response sets, and sends it from then on.
session = requests.Session()
response = session.post(
"https://www.prufy.dev/api/v1/claims",
json={"input": "yourcompany.com"},
)
data = response.json()One network can start 10 new sessions an hour. After that, creating a claim without a cookie answers rate_limited until the oldest one ages out. A client that keeps its cookie never meets this limit.
Carrying the session
Send the cookie back on every later request. A browser does this by itself for same-origin requests. From code, each tool has its own way: curl reads and writes a cookie jar, Python's requests.Session remembers cookies, and Node's fetch has to be handed the header.
curl 'https://www.prufy.dev/api/v1/claims/clm_4b1f7c1e-52e7-4c0a-9a3b-7d2f0c6e8a10' \
-b cookies.txt// `cookie` is the session cookie that Create a claim returned.
const response = await fetch("https://www.prufy.dev/api/v1/claims/clm_4b1f7c1e-52e7-4c0a-9a3b-7d2f0c6e8a10", {
headers: { cookie },
})
const data = await response.json()import requests
# `session` is the requests.Session() that created the claim.
response = session.get("https://www.prufy.dev/api/v1/claims/clm_4b1f7c1e-52e7-4c0a-9a3b-7d2f0c6e8a10")
data = response.json()Without the cookie, a route that needs one answers 401. A cookie that's malformed or that we never issued gets the same answer.
{
"error": {
"kind": "unauthorized",
"message": "This browser isn't signed in to any domains yet."
}
}A claim that belongs to another account answers 404 not_found, exactly like one that doesn't exist. There's no way to tell from the outside whether an id is real.
The cookie
| Attribute | Value | Why |
|---|---|---|
| Name | prufy_session | One cookie, holding one random token of 43 characters. |
| HttpOnly | Always | Scripts on the page can't read it, so an injected script can't take it. |
| SameSite | Lax | Another site can't make a signed-in POST. This is the CSRF protection. |
| Secure | Over HTTPS | On production it never travels in the clear. |
| Max-Age | 400 days | The longest a browser will keep a cookie. The session ends then too. |
| Path | / | Sent to every route. |
The token is 256 random bits and it's never stored. The database keeps its SHA-256 hash, which is enough to find the session and useless for signing in, so a leaked database doesn't leak sessions.
Signing in on another device
An account with a confirmed alert address can be reached from anywhere. Request a sign-in link with that address, and we email a link that works once, for 15 minutes. It opens a page with a button. Pressing it makes that device one more session on the same account, with its own cookie.
curl -X POST 'https://www.prufy.dev/api/v1/sign-in' \
-H 'content-type: application/json' \
-d '{
"email": "owner@yourcompany.com"
}'const response = await fetch("https://www.prufy.dev/api/v1/sign-in", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ email: "owner@yourcompany.com" }),
})
const data = await response.json()import requests
response = requests.post(
"https://www.prufy.dev/api/v1/sign-in",
json={"email": "owner@yourcompany.com"},
)
data = response.json()- The answer never says who has an account. Every address gets the same
{ requested: true }, and the email is sent after the response, so the timing doesn't say either. - Only a confirmed address works. Typing an address into the alerts form doesn't make it one, and a link stops working if the address is changed or removed before it's used.
- Opening the link does nothing by itself. Mail scanners open every link, so the page asks for a press, and the press is a POST.
- Nothing moves between accounts. A device that was signed in to a different account ends that session. Its claims stay where they were.
A terminal can't press a button, so prufy login asks for the link with the SHA-256 of a secret it keeps. Pressing that link's button shows a code instead of signing the browser in. The terminal sends the code and its secret to Redeem a sign-in code, and gets its session in Set-Cookie. The code lasts 10 minutes, and the session token never appears in a URL or on the page.
Signing out
Sign out ends the session that sends it, on the server, and clears the cookie. Only that one: the account, its claims and its other devices are untouched. Repeating it is safe. Sign out everywhere else ends every other session on the account, for a lost phone or a token that leaked.
curl -X DELETE 'https://www.prufy.dev/api/v1/session' \
-b cookies.txt// `cookie` is the session cookie that Create a claim returned.
const response = await fetch("https://www.prufy.dev/api/v1/session", {
method: "DELETE",
headers: { cookie },
})
const data = await response.json()import requests
# `session` is the requests.Session() that created the claim.
response = session.delete("https://www.prufy.dev/api/v1/session")
data = response.json()Tokens that stand in for one
Four things have to work for someone who has no session, often on a different device. Each uses a token that does one job and nothing else.
| Token | Where it goes | What it can do | How long |
|---|---|---|---|
| Setup link | The path of /api/setup/{token} | See one claim's record and run a check. Nothing else. | 30 days |
| Email confirmation | The body of Confirm the alert email | Confirm one address, once. | 24 hours |
| Unsubscribe | The query of Unsubscribe from alert emails | Stop alert emails to one address. | Until the address changes |
| Sign-in link | The body of Use a sign-in link | Start one session on the account whose alert address it went to, once. | 15 minutes |
A setup link is safe to forward for exactly that reason. Whoever holds it can add the record and ask us to look, and can't get a new code, stop the claim or see its history.
What each route needs
| A request needs | Routes |
|---|---|
| Nothing. Starts a session if there isn't one | |
| The session cookie |
|
| The session cookie, if you have one | |
| A token in the path, query or body | |
| Nothing |
What isn't here yet
- API keys. A long-lived secret you create once and send as a header. Until they exist, a server-side integration has to keep the cookie from its first claim.
- Passkeys. Signing in without an inbox in between. Sign-in links need a confirmed address first.
Both are planned and tracked in the project's issues.