Authentication and scopes
Every request to the API carries an API key in the Authorization header, with the Bearer scheme:
Authorization: Bearer vc_…
The API never uses cookies or sessions. A request without the header is answered with 401 and the code not_authenticated.
API keys
- Keys are created on the API keys page of the web interface. Each key has a name, a set of scopes and, optionally, an expiry date.
- A key is shown only once, when it is created. The service stores a hash of the key, not the key itself: a lost key cannot be recovered, only replaced.
- A key can be revoked at any time; from that moment it opens nothing.
- A key belongs to one customer. Everything a request reads or writes belongs to the customer of its key: there is no parameter to choose another customer.
GET /v1/me answers with the customer of the key, and is the simplest way to check that a key works.
Scopes
A scope is <resource>:read or <resource>:write. A key with write on a resource can also read it; the opposite is not true.
| Resource | Scopes |
|---|---|
jobs | jobs:read, jobs:write |
captures | captures:read, captures:write |
monitors | monitors:read, monitors:write |
webhooks | webhooks:read, webhooks:write |
lists | lists:read, lists:write |
notices | notices:read, notices:write |
connections | connections:read, connections:write |
labels | labels:read, labels:write |
usage | usage:read |
billing | billing:read, billing:write (credits, credit packs and checkout, paid services) |
A request that needs a scope the key does not have is answered with 403 and the code scope_missing; detail.required_scope names the missing scope.
Give each program the smallest set of scopes it needs: a program that only reads captures does not need jobs:write.
When a key is refused
| Status | Code | Meaning |
|---|---|---|
401 | not_authenticated | The Authorization: Bearer header is missing. |
401 | api_key_invalid | The key is malformed or does not exist. |
401 | api_key_revoked | The key has been revoked. |
401 | api_key_expired | The key has expired. |
401 | account_deactivated | The account of the key is paused: the key works again when the account is reactivated. |
403 | account_inactive | The account of the key is suspended or being deleted. |
403 | scope_missing | The key lacks the scope the operation requires. |
The shape of an error response is described in Errors.
Identifiers
Every object has a public identifier made of a prefix and a random part, such as job_01J9Z3K4R5S6T7V8W9X0Y1Z2A3. Identifiers are not sequential. An identifier that belongs to another customer is answered with 404, exactly like one that does not exist.