Skip to content

Authentication

ANANZI authenticates classify and key routes with a Bearer API key. Health routes do not require a key.

Send the raw key on every protected request:

Authorization: Bearer <key>

Do not put keys in query strings, client analytics, or screenshots.

POST /v1/accounts is an operator route: it needs Authorization: Bearer $ANANZI_OPERATOR_TOKEN (the ANANZI_OPERATOR_TOKEN the API runs with; 401 without it, 503 when the API has none configured). For local runs, export a value for it before starting the API. It creates a user, organization, membership, and the first key. The raw key is returned once in api_key.key. The database stores key_prefix plus a SHA-256 hex digest — not the raw secret.

Terminal window
curl -fsS http://localhost:5150/v1/accounts \
-H 'content-type: application/json' \
-H "authorization: Bearer $ANANZI_OPERATOR_TOKEN" \
-d '{"organization_name":"Quickstart Org"}'

email is optional. organization_name is required.

With a valid Bearer key for the organization:

Method Path Purpose
GET /v1/keys List keys (no raw secrets)
POST /v1/keys Create another key (raw shown once)
POST /v1/keys/{id}/revoke Revoke a key
POST /v1/keys/{id}/rotate Replace the secret. The new raw is returned once; the previous raw is not retained.

Rotation does not keep the previous raw secret or a previous hash. A revoked key cannot be rotated. List responses still omit raw secrets.

A Bearer key lists keys, reads usage, and reads billing only for its own organization. Those responses omit other organizations’ key ids, prefixes, names, request counts, and used units. An organization_id query parameter or an X-Organization-Id header does not change the organization.

Protected inspection uses the same header on POST /v1/inspect.

Missing, malformed, unknown, mismatched, or revoked keys return 401 with error: unauthorized and the shared error body. See Errors.