Token keys API

Reference for the management API's endpoints that list, register and revoke a database's token keys.

These endpoints manage a database's token keys: the Ed25519 public keys that verify document tokens your backend signs. See token keys for how they are used, and the management API overview for authentication and errors.

MethodPathDoes
GET/v1/databases/{databaseId}/token-keysLists a database's token keys
POST/v1/databases/{databaseId}/token-keysRegisters a token key
DELETE/v1/databases/{databaseId}/token-keys/{tokenKeyId}Revokes a token key

Token keys can be registered and revoked while the database is ready or suspended. In any other state those requests are answered 409.

The token key object

{
  "id": "tk_…",
  "databaseId": "db_…",
  "kid": "k1",
  "name": "backend-2026",
  "publicKey": "<base64url Ed25519 public key>",
  "createdAt": "2026-01-15T10:00:00.000Z",
  "registeredAt": "2026-01-15T10:00:01.000Z",
  "registeringUntil": null,
  "revokedAt": null,
  "revokedInDatabaseAt": null
}
NameTypeDescription
id *stringThe token key's ID. Use it as tokenKeyId to revoke the key.
databaseId *stringThe database it belongs to.
kid *stringThe key ID your tokens carry to name this key.
name *stringThe name it was given.
publicKey *stringThe Ed25519 public key, base64url-encoded.
createdAt *stringWhen the registration was requested.
registeredAt *string | nullWhen the cluster confirmed the key. Null while it is registering, or if its registration ended without settling it.
registeringUntil *string | nullUntil when a registration in progress may settle the key. It cannot be revoked before then.
revokedAt *string | nullWhen it was revoked. Null for a key that is not revoked.
revokedInDatabaseAt *string | nullWhen the key was found revoked or removed in the database itself, with an admin key, or another key under its `kid` there, and recorded revoked here. Null for a key revoked here, or one that is not revoked.

A key's condition follows from three of these fields:

ConditionrevokedAtregisteredAtregisteringUntil
ActivenullSetnull
RegisteringnullnullIn the future
Unsettled: revoke it, then register the key again under a new kidnullnullnull or in the past
RevokedSetEithernull

List token keys

GET /v1/databases/{databaseId}/token-keys

Returns the database's token keys as an array of token key objects, newest first, including revoked ones. At most the 100 most recent are returned.

curl "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/token-keys" \
  -H "Authorization: Bearer $MIMIC_API_KEY"

Register a token key

POST /v1/databases/{databaseId}/token-keys
NameTypeDescription
name *string1 to 64 characters, trimmed.
kid *string1 to 64 letters, digits, '.', '_' or '-'. Not '.' or '..', and not starting with 'gw_'. Unique among the database's keys that are not revoked.
publicKey *stringThe raw 32-byte Ed25519 public key, base64url-encoded: 43 characters, optionally followed by one '='.

Answers 201 with the token key, already confirmed by the cluster: registeredAt is set.

curl -X POST "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/token-keys" \
  -H "Authorization: Bearer $MIMIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "backend-2026", "kid": "k1", "publicKey": "<base64url Ed25519 public key>"}'
StatusWhen
400kid or publicKey does not have the form above
409A key with this kid is registered, or was and has been revoked (a kid is used once per database); the cluster holds another key under it; the database is not ready or suspended; or the registration ended before it could be recorded and the key was withdrawn
503The cluster could not be reached, or its answer was lost. List the token keys before trying again: a key left unsettled has to be revoked first, and a withdrawn key's kid is not used again

Revoke a token key

DELETE /v1/databases/{databaseId}/token-keys/{tokenKeyId}

Revokes the key in the database's cluster, so tokens signed with it are no longer accepted. tokenKeyId is the key's id (tk_…), not its kid.

Answers 204 with no body. The kid is not registered again in this database.

curl -X DELETE "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/token-keys/$TOKEN_KEY_ID" \
  -H "Authorization: Bearer $MIMIC_API_KEY"
StatusWhen
404The key does not exist in this database, or is already revoked
409The key is still being registered or revoked; try again once registeringUntil has passed. Or the database is not ready or suspended
503The cluster could not be reached or did not answer in time. The key was not revoked; try again

Revoke all tokens

POST /v1/databases/{databaseId}/tokens/revoke

Ends every document token issued for the database until now, whatever key signed it or minted it, and revokes no key. Answers 200 with the time before which no token holds: the database's clock plus the five minutes of skew a signer may have, so it is a few minutes ahead. From then on a token is accepted only with an issued-at claim (iat) later than it: signed with iat of notBefore plus one second, a token is accepted from a second or two after the revocation; signed with iat from your clock, once your clock passes notBefore. Tokens without iat are refused from then on, for good. Tokens the HTTP API mints carry it.

{ "notBefore": "2026-01-15T10:00:00.000Z" }

Repeating it is safe: the time only moves later.

curl -X POST "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/tokens/revoke" \
  -H "Authorization: Bearer $MIMIC_API_KEY"
StatusWhen
404The database does not exist, or the key cannot reach it
409The database is not ready or suspended, or is not available in its cluster
503The cluster could not be reached or did not answer in time; try again, it is safe

Token keys not made here

Token keys the database holds that were not registered through this API, such as ones registered in the database itself with an admin key, are listed with the database's other keys not made here: see keys not made here.