Authentication
Two kinds of credential, what each one opens, and why only one of them may reach a browser.
Every call to the API carries a credential, in the Authorization header.
Authorization: Bearer <credential>
There are two kinds of credential. Confusing them is the most expensive mistake you can make with this API.
First, choose the address. The API exists once per environment, and a credential issued for one is refused by the other. The examples on this page use Production.
| Environment | API base |
|---|---|
| Production | https://api.saphere.ai |
| Test | https://api.test.saphere.ai |
The two environments are completely separate: separate accounts, separate keys, separate data. See Environments.
The API key
Your API key identifies your client account. A key created in the console starts with ivak-, followed by a random part and a short checksum: a key copied with a character missing or changed is refused straight away. Keys issued before November 2026 are UUIDs, and they keep working. Treat a key as an opaque string: do not check its format on your side.
POST /access-tokens HTTP/1.1
Host: api.saphere.ai
Authorization: Bearer <apiKey>
Content-Type: application/json
Your account can hold several keys, and they are all equivalent: each one acts in the name of the same account. Give each of your applications or servers a key of its own, and you can replace one without touching the others.
A few things about them are worth stating plainly.
- A key is not scoped. It opens every route of the API: creating measurements, reading them back, deleting them, issuing tokens. The rate limits below and your quota still apply.
- You create it yourself, in the console. On the API Keys page, in each environment. An account has no key until one has been created: a new account starts there. You give the key a description — the application or environment it serves — and, if you want, a last day of validity, Valid until.
- It is shown only once. Right after its creation, in a window with a button that copies it. The console never shows it again: it lists your keys by their description alone, with nothing of their value — so give each one a description that tells you where it is used. Copy it into your server’s secrets at that moment. Saphere does not keep the key itself, only a fingerprint of it that opens nothing: a lost key cannot be recovered, by you or by us; it is replaced: create a new one, then revoke the old one.
- It expires only if you give it a last day. Without one, it never expires. With one, it is refused from the next day onwards, in UTC.
- The console shows when each key was last used, to the hour: a key that shows Never, or a date long past, is one your applications no longer use — a good candidate for revocation.
- You revoke it in the console, one key at a time. It is refused at once, and the account’s other keys keep working. The last valid key of an account cannot be revoked: create its replacement first. Deactivating the account still stops all of its keys at once.
A revoked or expired key is refused with a 401, exactly like an unknown key.
The key must never reach a browser or a mobile bundle
A key shipped inside client code is a key anyone can read: by opening the browser’s developer tools, by unpacking a mobile app, or by fetching your files from a cache. Until you notice and revoke it, it opens your entire account to whoever read it, and revoking it cuts off every integration that uses it at the same moment. A leak is not a small incident.
The widget is built so that it never needs the key. It asks your server for a short-lived token instead. Use that route.
Access tokens
An access token is the credential you can hand to a browser. Your server creates it from your API key, with POST /access-tokens. It is deliberately weak.
| API key | Access token | |
|---|---|---|
| Scope | Everything | Only the permissions it names |
| Expiry | None, unless you give it a last day | Mandatory, at most 48 hours |
| Replayable | Always | Only if you allow it |
| Revocation | In the console, one key at a time | DELETE /access-tokens/{id} |
| Safe in a browser | No | Yes, by design |
Two permissions exist: measurement.scan, the Saphere Scan measurement, and measurement.realtime, the real-time chain. They allow opening a measurement session, and nothing else. A token that carries one cannot read your measurements, cannot delete anything, and cannot create other tokens.
Give it maxSessions: 1 and it opens exactly one session. That is what a widget integration should use: a token spent by the measurement it was created for, and worth nothing afterwards.
The token value and the token id are different strings
POST /access-tokens returns both. value is the credential. It begins with ivat-, it is returned only once, and it is what the widget presents. id names the token: it is what you pass to revoke it, and using it as a credential opens nothing.
Only a fingerprint of value is stored, so a copy of the database hands out no usable token.
Rate limiting
Requests are counted per credential and per route, over a rolling minute. Each route holds a count of its own, so a burst on one of them never closes another.
| Route | Limit |
|---|---|
POST /access-tokens, POST /users-cl | 20 per minute |
| Everything else | 300 per minute |
Creating tokens and creating users are deliberately tighter than the rest: each call writes to the database (and a user creation sends an e-mail). A token is meant to be requested once, at the start of a measurement, never in a loop.
These bounds are sized for peaks rather than for steady traffic: they are there so that a burst does not turn into an outage. What governs your volume is your quota, not this table.
Responses carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, the last one in seconds. Exceeding a limit returns 429, with a Retry-After header in seconds: the route stays closed to that credential for up to a minute.
Refused keys
A request refused with a 401 — header missing or malformed, unknown, revoked or expired key, deactivated account — is counted too, per source address and whatever key was tried: beyond 30 refusals per minute from the same address, the next refusals are answered 429 with a Retry-After header (in seconds, a minute at most); once it has elapsed, refusals are counted again from zero. Nothing else changes: the request would have been refused anyway.
A caller whose key is valid is never counted and never slowed down by this, even behind an address that has used up the bound; only the refusals are shared between callers behind the same outgoing address. If you hold a key that has just been revoked, has expired, or whose account has been deactivated, stop replaying it: a loop of retries is what ends in the 429.
Opening a measurement
The handshake that opens a Saphere Scan measurement — whether it presents an access token or a measure id — is counted separately, per client rather than per route:
| What is counted | Limit |
|---|---|
| opening attempts | 2 per second |
| opening attempts | 20 per minute |
The two windows go together: the second spreads out what the minute allows, a measurement holding memory for as long as it runs. An opening refused by this bound does not consume the access token it presented: the token stays usable once the bound has cleared — a second for the per-second bound, up to a minute for the per-minute one. Attempts count whether or not they succeed (a replayed spent token included), so retrying in a tight loop only keeps the bound shut: wait, then try again.
These values leave a wide margin on what a user journey produces — a person does not start two measurements within the same second. You meet them when automating: a test harness that chains measurements has to space them out.
A measure id has bounds of its own. It opens at most five sessions, and no new one once an hour has passed since its first opening; reconnecting to a session that is still open is not an opening, and counts for neither. Beyond either bound the handshake is refused, the same way as for a measure id that has already been used. A measure created for each attempt never gets there.
A useful diagnostic
If a response carriesX-RateLimit-* headers, the request reached a route and was refused by a check. If a 404 carries none — and its body is the plain text Not Found — no route matched at all: the path is wrong, rather than the resource.Error responses
Errors are JSON, with one exception worth knowing about.
{
"statusCode": 400,
"message": ["duration must be an interval amounting to more than zero, such as 2h 30min, 45min or 90s, each unit appearing at most once, and to at most 48h"],
"error": "Bad Request"
}
A path that matches no route answers in plain text: a 404 whose body is Not Found, with no JSON. Every other error, a 404 for a resource that does not exist included, is JSON — { "message": "Not Found", "statusCode": 404 }. If your code parses error bodies as JSON, check the Content-Type first, or a mistyped path will fail on the parsing instead of being handled by its status.
| Status | Meaning |
|---|---|
400 | The request body or query failed validation; message lists what. |
401 | Authorization header missing or malformed, unknown, revoked or expired API key, or deactivated account. A 401 always means the key was refused. |
403 | The route refuses to act on that resource: your key cannot change or delete a user who holds permissions (see Users). |
404 | No such resource, or not yours. Plain text only when no route matched the path. |
406 | Your Accept header rules out JSON on a route that answers JSON. Send application/json or */*. |
409 | The request conflicts with what exists: an e-mail address already in use, or a user who cannot be deleted (see Users). |
415 | A route taking a JSON body received another Content-Type. |
429 | Rate limit exceeded, or too many refused keys from your address (see Refused keys); Retry-After says when to come back. |
500 | The request could not be completed on our side. |
503 | The instance is shedding load, or could not check your API key for a moment; Retry-After says when to come back. The request is safe to repeat. |
Not found and not yours are the same answer
A resource belonging to another account returns exactly the same404 as one that never existed. This is deliberate: nobody can use the API to find out whether an identifier is real.