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.
| Endpoint | Purpose |
|---|---|
POST /v1/keys | Create a key |
GET /v1/keys | List 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:
Code
- Console keys can read usage and manage keys.
- Keys created through
POST /v1/keyscan only be used for search. On/v1/keysand/v1/usagethey get403 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
| Field | Required | Description |
|---|---|---|
name | yes | 1 to 255 characters, e.g. your customer's name |
expires_at | no | ISO 8601 date in the future; omit or null for no expiry |
Code
Response 201:
Code
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
Code
Returns every key of the account, newest first, without secrets:
Code
origin is console for keys created in the console and api for keys created through POST /v1/keys.
Delete a key
Code
Code
Response 200:
Code
- 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.
| HTTP | code / message | Cause |
|---|---|---|
400 | invalid field | Invalid name, expires_at or {id} |
401 | INVALID_KEY_FORMAT | Missing or malformed Authorization header |
401 | INVALID_CREDENTIALS | Unknown key or wrong secret |
403 | KEY_DISABLED | The key is disabled |
403 | SCOPE_NOT_GRANTED | Key created through the API: use a console key |
403 | API key limit reached | 100 keys already on the account (POST /v1/keys) |
403 | Console key on DELETE | Console keys are deleted from the console |
404 | not found | {id} does not belong to your account |
410 | KEY_EXPIRED | The key has expired |
429 | too many requests | Rate limit exceeded |