API Keys

Issue scoped, rate-limited credentials so frontends and integrations can consume the REST API safely.

Routes

RouteMethodPurpose
/admin/api-keysGETList keys
/admin/api-keys/createGETNew key form
/admin/api-keysPOSTCreate key (secret shown ONCE on response)
/admin/api-keys/{key}/editGETEdit key metadata
/admin/api-keys/{key}PUTUpdate scopes, origins, rate limit, expiry
/admin/api-keys/{key}DELETERevoke (soft delete)

Key attributes

FieldDescription
nameHuman-readable label ("Website Production", "Mobile App")
keyPublic identifier sent in request headers (unique, 32 chars)
secret_hashbcrypt hash of the secret — plaintext never stored
scopesJSON array: read, write, delete
allowed_originsJSON array of CORS origins (wildcard * allowed)
rate_limitRequests per minute (default 60)
expires_atOptional auto-expiry timestamp
is_activeSoft pause without deletion
usage_countLifetime request count (incremented by the api.log middleware)
last_used_at / last_used_ipDiagnostics

Scopes

Scopes are enforced by the api.scope middleware on a per-route basis. See API: Authentication & Scopes for full details.

Rate limiting

The api.rate middleware applies a sliding window keyed by the API key's UUID, defaulting to the key's rate_limit value (requests/min). Exceeded limits return 429 Too Many Requests with a Retry-After header.

CORS

The api.cors middleware checks the request's Origin header against allowed_origins. Empty or wildcard lists allow any origin. Preflight (OPTIONS) requests are handled automatically.

Secret handling

Secrets are shown onceWhen you create a key, the response shows the plaintext secret one time only. Store it in your client's secret store immediately — it cannot be retrieved later.

Request audit

Every authenticated request is logged to api_request_logs by the api.log middleware: API key, endpoint, status, duration, IP, user agent. View the trail per-key on the API Key detail page.