Authentication and scopes
Every HTTP request carries an API key as a bearer token over TLS:
GET /v1/account HTTP/1.1Host: api.sonicdocs.aiAuthorization: Bearer <api-key>A key belongs to a tenant, your organization’s account. Documents belong to the tenant, not to the key that uploaded them, so any key in the tenant with the right scope can read them.
Scopes
Section titled “Scopes”Each key carries one or more scopes. Each operation in the API reference lists the scope it requires.
| Scope | Allows |
|---|---|
documents:write |
Upload documents and delete them |
documents:read |
List documents; read status, events, results and files; issue event tickets |
usage:read |
Read usage for the tenant |
keys:manage |
Create, list and revoke API keys |
GET /account and GET /limits work with any valid key. Use GET /account to see which tenant and scopes the current key has.
Failures
Section titled “Failures”| Response | Meaning |
|---|---|
401 invalid_api_key |
The key is missing, malformed, unknown or revoked. The response includes WWW-Authenticate: Bearer. |
403 |
The key is valid but lacks the scope the operation requires. |
404 document_not_found |
The document does not exist, was deleted, expired or belongs to another tenant. The response is the same in every case, so it does not reveal whether another tenant’s document exists. |
503 control_plane_unavailable |
The service could not check the key. Retry later. |
See errors for the full list.
Keeping keys safe
Section titled “Keeping keys safe”- Keep keys on your server. Do not put them in browser code, mobile apps or browser storage.
- Give each integration its own key with only the scopes it needs. See API keys.
- Revoking a key takes effect on HTTP requests, outstanding WebSocket tickets and open event subscriptions before the revoke call returns.
- WebSocket connections never carry the API key. Your server exchanges the key for a short-lived event ticket instead.