Staan
Account Management

API Keys API

Create API keys for your own customers, list the keys of your account and delete them — without going through the Staan console. Then follow what each key consumes with the Usage API.

EndpointPurpose
POST /v1/keysCreate a key
GET /v1/keysList the keys of your account
DELETE /v1/keys/{id}Delete a key created through the API

Base URL: https://api.staan.ai. All requests and responses are JSON.

Authentication

Call these endpoints with an API key created in the Staan console:

TerminalCode
Authorization: Bearer YOUR_CONSOLE_API_KEY
  • Console keys can read usage and manage keys.
  • Keys created through POST /v1/keys can only be used for search. On /v1/keys and /v1/usage they get 403 SCOPE_NOT_GRANTED. This lets you hand them to your customers safely.

Keep your console key on your servers only: anyone holding it can create keys on your account.

Create a key

Code
POST https://api.staan.ai/v1/keys
FieldRequiredDescription
nameyes1 to 255 characters, e.g. your customer's name
expires_atnoISO 8601 date in the future; omit or null for no expiry
TerminalCode
curl -X POST https://api.staan.ai/v1/keys \ -H "Authorization: Bearer YOUR_CONSOLE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name": "Customer A", "expires_at": "2027-12-31T23:59:59Z"}'

Response 201:

JSONCode
{ "id": "6f1c2a9e-3b4d-4e5f-8a7b-1c2d3e4f5a6b", "key": "stn_...", "name": "Customer A", "expires_at": "2027-12-31T23:59:59.000Z", "created_at": "2026-11-02T08:22:46.594Z" }

The secret is returned only once

The key field is returned only in this response. Store it right away: it cannot be retrieved later.

  • The new key gets the default settings: web search with extra snippets (Web Search for AI) and the default rate limits.
  • An account holds up to 100 keys.

List keys

Code
GET https://api.staan.ai/v1/keys
TerminalCode
curl https://api.staan.ai/v1/keys \ -H "Authorization: Bearer YOUR_CONSOLE_API_KEY"

Returns every key of the account, newest first, without secrets:

JSONCode
[ { "id": "6f1c2a9e-3b4d-4e5f-8a7b-1c2d3e4f5a6b", "name": "Customer A", "origin": "api", "enabled": true, "expires_at": "2027-12-31T23:59:59.000Z", "created_at": "2026-11-02T08:22:46.594Z" } ]

origin is console for keys created in the console and api for keys created through POST /v1/keys.

Delete a key

Code
DELETE https://api.staan.ai/v1/keys/{id}
TerminalCode
curl -X DELETE https://api.staan.ai/v1/keys/6f1c2a9e-3b4d-4e5f-8a7b-1c2d3e4f5a6b \ -H "Authorization: Bearer YOUR_CONSOLE_API_KEY"

Response 200:

JSONCode
{ "deleted": true, "id": "6f1c2a9e-3b4d-4e5f-8a7b-1c2d3e4f5a6b" }
  • The key stops working immediately. Its past usage stays in GET /v1/usage.
  • Only keys created through the API can be deleted this way; console keys are managed in the console (403).

Rate limits and errors

These endpoints accept 1 request per second, per key and per endpoint. Above that they return 429: wait a second and retry.

HTTPcode / messageCause
400invalid fieldInvalid name, expires_at or {id}
401INVALID_KEY_FORMATMissing or malformed Authorization header
401INVALID_CREDENTIALSUnknown key or wrong secret
403KEY_DISABLEDThe key is disabled
403SCOPE_NOT_GRANTEDKey created through the API: use a console key
403API key limit reached100 keys already on the account (POST /v1/keys)
403Console key on DELETEConsole keys are deleted from the console
404not found{id} does not belong to your account
410KEY_EXPIREDThe key has expired
429too many requestsRate limit exceeded
Last modified on