Every call carries a key, and the key's kind decides what the call may do. Choose the narrowest kind that does the job: a key on a device or in a web page can be copied, and a copied key does whatever its kind allows until you revoke it.
| Kind | scope | May call | Where it belongs |
|---|---|---|---|
| Full access | full | Everything the workspace may but /v1/keys: decisions, models, uploads, sessions, batch jobs, collections and per-key usage | Your servers, in a secret manager or an environment variable |
| Decisions only | decide | POST /v1/decide and GET /v1/models; a face search only where the key allows it | One per device, app install or service that only decides |
| Manage device keys | keys | /v1/keys: create, list, change and revoke Decisions-only keys, and read their usage. No decisions | Your provisioning server, and nowhere else |
| Publishable | publishable | POST /v1/decide only, not even GET /v1/models, on the models it lists (DecisionNode Flash unless you add more), never a face search, always within its rate limits and daily spend cap | Web pages and mobile apps: public by design |
Full access, Manage device keys and Publishable keys are made only in the console, under API keys. An Owner, Admin or Developer makes Full access and Decisions-only keys; only an Owner or Admin makes, changes or revokes a Manage device keys or Publishable key. Decisions-only keys are also made by your provisioning server through /v1/keys, one per device.
Which kind to use#
| Where the call comes from | Use |
|---|---|
| A service of yours that does more than decide (batches, sessions, collections) | Full access, kept on the server |
| A service of yours that only decides | Decisions only: the same answers, and much less to lose if it leaks |
| A fleet of devices: cameras, kiosks, robots, vehicles | One Decisions-only key per device, made by your provisioning server: Keys on devices |
| A web page or a mobile app with no server of yours behind it | Publishable: Publishable keys |
| A web page with your own server behind it | Your server calls DecisionNode with its key; the page calls your server |
Why every device gets its own key#
- A device can be lost, opened or copied. Its key is only as safe as its storage. With a key per device, one lost device is one revoked key, and every other device keeps working.
- Never a Full access key on a device or in a browser. A full key reads, changes and deletes your collections, starts batch jobs and sessions, and spends at the workspace's rate. Copied from one device, it is all of that for whoever has it. Pasted into a web page, it does not even work: only a publishable key's answers carry the headers that let a page read them, so a page cannot read a Full access, Decisions-only or Manage device keys key's answers, whatever origin it sends. Outside a browser, on a server or in a desktop app, such a key works as it always does.
- Never the Manage device keys key on a device. It makes keys. It belongs to the server that hands them out.
- Bound what a key can spend. A Decisions-only key can carry its own rate limits and a daily spend cap, so a copied key costs at most its cap a day until you revoke it.
- Name and label it.
device_idfinds the key of one device, andlabelsrevoke a group at once: a store, a batch of hardware, a firmware version. - A key is a meter. Every call is metered on the key that made it, and
GET /v1/usagereads each key's usage and cost for a period, so with a key per device you can bill each of your customers for its own devices: Bill your customers per device. - Let it expire.
expires_atends a key on its own: a pilot, a rental, a device that renews its key on a schedule. An expired key is replaced, never extended: only a rename or a revoke still works on it. A Full access key's expiry is checked when a session's socket connects: a socket already open keeps going until its session ends. - Images go inline. A Decisions-only key cannot make uploads (
POST /v1/uploadsis403key_scope_denied), so a device sends its pictures inline or byurlin the decision, up to 25 MiB a request.
A key's settings#
- Face search is opt-in. A Decisions-only key cannot use the
face_recognitionbooster unless you tick May search your face collections when you create it or edit it (may_search_collections). Anyone holding such a key can search your collections and read the matches, so tick it only for a device that runs face recognition. A Full access key always may. - Its own rate limits. Under Rate limits (optional), set the key's own Requests per second and Tokens per second, each a whole number from 1 to your workspace's own. Left empty, the workspace's limit applies. Over them,
429rate_limit_errorwithRetry-After, as for any key.
What a key's kind refuses#
A call outside a key's kind is 403 key_scope_denied, before anything runs or is billed: "This key may only make decisions." for a route the kind does not reach, such as an upload, a batch, a session or a collection, and "This key may not search collections." for a face_recognition booster on a key without the search allowed. A key past its daily spend cap gets 429 key_spend_cap_reached until the cap resets at 00:00 UTC, and an expired key 401 authentication_error with details.reason key_expired. A Manage device keys key anywhere but /v1/keys and the usage routes gets "This key may only manage keys.", and a Full access key on /v1/keys "Keys are managed with a keys key, made in the console." A publishable key anywhere but a decision gets "A publishable key may only make decisions.", and adds two of its own: 403 origin_not_allowed and 403 model_not_allowed (Publishable keys).
{
"detail": {
"error_type": "key_scope_denied",
"message": "This key may only make decisions."
}
}A key's kind never changes#
A key's kind is set when it is made. Its name, labels, limits, spend cap, expiry and the face search flag can be changed later; its kind cannot. To change the kind, make a new key, move to it, and revoke the old one.