Skip to main content
The key management endpoints let you create and administer the API keys used to authenticate calls to /v1/compress. All six endpoints require a Firebase ID token — not an API key — because they operate on behalf of a signed-in user and are the same routes the dashboard UI calls.

Authentication

All requests on this page must include:
In dev mode (SC_AUTH_DEV=1) you can pass a synthetic token such as dev:my-uid:me@dev.local instead of a real Firebase token.

GET /api/me

Returns the Firebase uid and email address for the currently authenticated user. This is a lightweight liveness check for the auth layer and is also used by the dashboard on first load.

Example request

Response fields

string
The Firebase user ID.
string
The email address associated with the Firebase account. May be null for anonymous or OAuth-only accounts.

Example response


GET /api/keys

Lists all active (non-revoked) API keys for the authenticated user, together with a per-key usage summary.

Example request

Example response


POST /api/keys

Creates a new API key for the authenticated user. Returns the key record and the full secret value. The secret is derived from a cryptographically random 24-byte token and is shown only once — it is not stored, only its SHA-256 hash is.

Body parameters

string
default:"Production"
A human-readable label for the key. Maximum 80 characters. Whitespace-only names are stored as "Untitled key".

Example request

Example response

The secret field contains the full sc_live_… key and is returned exactly once. Copy it to a secrets manager immediately. If you lose it, you must create a replacement key and revoke the old one.

PATCH /api/keys/

Renames an existing key. Only the display name is changed; the key secret, prefix, and usage history are unaffected.

Path parameter

Body parameters

string
required
New display name. Between 1 and 80 characters. Whitespace-only values are ignored and the existing name is preserved.

Example request

Example response

Returns 404 if the key does not exist or does not belong to the authenticated user.

DELETE /api/keys/

Permanently revokes an API key. The key is immediately removed from the hash lookup index, so any in-flight requests using it will start failing with 401 within milliseconds.

Path parameter

Example request

Example response

Revocation is permanent and immediate. The key hash is removed from the lookup index, and the key record is marked "revoked": true. There is no undo — create a new key if access needs to be restored.
Returns 404 if the key does not exist or does not belong to the authenticated user.

GET /api/keys//usage

Returns a usage snapshot for a single key, broken down by calendar day (UTC).

Path parameter

Example request

Response fields

integer
Total number of successful /v1/compress calls made with this key.
integer
Cumulative input token count across all requests (tokens before compression).
integer
Cumulative output token count across all requests (tokens after compression).
integer
Cumulative tokens saved: total_tokens_in − total_tokens_out. This directly maps to KV-cache reduction.
object
A map from UTC date strings ("YYYY-MM-DD") to per-day usage records. Each record contains key_id, requests, tokens_in, tokens_out, and tokens_saved for that day.

Example response

Returns 404 if the key does not exist or does not belong to the authenticated user.