Database keys API
Reference for the management API's endpoints that list, create, rotate and revoke a database's keys.
These endpoints manage a database's keys: the credentials your backend uses against the database's cluster. See database keys for how they behave, and the management API overview for authentication and errors.
| Method | Path | Does |
|---|---|---|
GET | /v1/databases/{databaseId}/keys | Lists a database's keys |
GET | /v1/databases/{databaseId}/unmanaged-credentials | Lists the keys and token keys the database holds that were not made here |
DELETE | /v1/databases/{databaseId}/unmanaged-credentials/database-keys/{keyIdInDatabase} | Revokes a key not made here |
DELETE | /v1/databases/{databaseId}/unmanaged-credentials/token-keys/{kid} | Revokes a token key not made here |
POST | /v1/databases/{databaseId}/keys | Creates a key |
POST | /v1/databases/{databaseId}/keys/{keyId}/rotate | Rotates a key |
DELETE | /v1/databases/{databaseId}/keys/{keyId} | Revokes a key |
Keys can be created, rotated and revoked while the database is ready or suspended. In any other state those requests are answered 409.
The database key object
{
"id": "dbk_…",
"databaseId": "db_…",
"name": "api-server",
"permission": "write",
"reference": null,
"secretHint": "a1B2",
"createdAt": "2026-01-15T10:00:00.000Z",
"revokedAt": null,
"revokeAfter": null,
"rotatedToKeyId": null,
"revokedInDatabaseAt": null
}| Name | Type | Description |
|---|---|---|
id * | string | The key's ID. |
databaseId * | string | The database it belongs to. |
name * | string | The name it was given. |
permission * | "read" | "write" | "admin" | What the key may do in the database. |
reference * | string | null | Your own name for the key, if you gave one when creating it. |
secretHint * | string | null | The last characters of the secret, to tell keys apart. |
createdAt * | string | When it was created. |
revokedAt * | string | null | When it was revoked. Null for a key that works. |
revokeAfter * | string | null | When a rotation will revoke this key. Null unless it is being rotated. |
rotatedToKeyId * | string | null | The ID of the key that replaces it. Null unless it was rotated. |
revokedInDatabaseAt * | string | null | When the key was found revoked or removed in the database itself, with an admin key, and recorded revoked here. Null for a key revoked here, or one that works. |
The secret is never part of this object. It is returned once, by the request that creates or rotates the key.
List keys
GET /v1/databases/{databaseId}/keysReturns the database's keys as an array of database key objects, newest first, including revoked ones. At most the 100 most recent are returned.
curl "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/keys" \
-H "Authorization: Bearer $MIMIC_API_KEY"Create a key
POST /v1/databases/{databaseId}/keys| Name | Type | Description |
|---|---|---|
name * | string | 1 to 64 characters, trimmed. |
permission * | "read" | "write" | "admin" | What the key may do in the database. |
reference | string | Your own name for the key, drawn before you create it: 1 to 128 letters, digits and `._:-`. At most one key of the database that is not revoked holds it. |
Answers 201 with the key and its secret:
{
"key": {
"id": "dbk_…",
"databaseId": "db_…",
"name": "api-server",
"permission": "write",
"reference": null,
"secretHint": "a1B2",
"createdAt": "2026-01-15T10:00:00.000Z",
"revokedAt": null,
"revokeAfter": null,
"rotatedToKeyId": null,
"revokedInDatabaseAt": null
},
"secret": "mk_…"
}A deployment tool gives each key a reference so a create whose answer was lost is not left behind: the next create under the same reference is refused, and names the key the lost answer made. Revoke that key, whose secret nobody received, and create it again. While that key is still being issued it cannot be revoked, and the create is answered 503: try again a few minutes later. A rotation's successor takes over the reference from the key it replaces.
Store secret straight away. No later request returns it. Keep it out of logs: pipe the response
into your secret store rather than printing it.
curl -X POST "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/keys" \
-H "Authorization: Bearer $MIMIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "api-server", "permission": "write"}'| Status | When |
|---|---|
409 | The database is not ready or suspended, or its cluster refused the key |
409 | A key that is not revoked holds the reference; the message names it |
503 | The cluster could not be reached, issuing the key was interrupted, or a key under the reference is still being issued. No working key was left behind; try again |
Rotate a key
POST /v1/databases/{databaseId}/keys/{keyId}/rotateCreates a successor with the same name and permission, and schedules the old key to be revoked when the overlap ends.
| Name | Type | Description |
|---|---|---|
overlapSeconds * | integer | How long the old key keeps working, from 0 to 604800 (7 days). 0 revokes it straight away. |
Answers 201 with the successor and its secret, in the same shape as creating a key. Deploy the secret before the overlap ends.
curl -X POST "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/keys/$KEY_ID/rotate" \
-H "Authorization: Bearer $MIMIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"overlapSeconds": 3600}'After the request, the old key has revokeAfter set to the end of the overlap and rotatedToKeyId set to the successor's ID. A rotate_database_key operation waits out the overlap and then revokes the old key, setting its revokedAt.
| Status | When |
|---|---|
404 | The key does not exist in this database, or is already revoked |
409 | The key is already being rotated, the database has another operation in progress, or the database is not ready or suspended |
Revoke a key
DELETE /v1/databases/{databaseId}/keys/{keyId}Revokes the key at once. Requests to the database with it fail from then on, and it cannot be undone.
Answers 204 with no body.
curl -X DELETE "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/keys/$KEY_ID" \
-H "Authorization: Bearer $MIMIC_API_KEY"| Status | When |
|---|---|
404 | The key does not exist in this database, or is already revoked |
409 | The database is not ready or suspended |
503 | The cluster could not be reached. The key was not revoked; try again |
Rotating a key from a pipeline
response=$(curl -s -X POST \
"$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/keys/$KEY_ID/rotate" \
-H "Authorization: Bearer $MIMIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"overlapSeconds": 86400}')
# Hand the new secret to your secret store without printing it.
echo "$response" | jq -r '.secret' | your-secret-store set MIMIC_DATABASE_KEY
# Remember the successor's ID: it is the key to rotate next time.
echo "$response" | jq -r '.key.id'your-secret-store stands for whatever your platform uses. The job needs only an API key scoped to this one database.
Keys not made here
GET /v1/databases/{databaseId}/unmanaged-credentialsAn admin key can create, revoke and remove keys and token keys in the database itself, beside this API. This lists the ones the database holds that were not made here (usually made in it with an admin key, or issued between when a backup was taken and when this service was restored from it), as the service last compared the database with its records (about every 15 minutes), never with a secret. Keys this API made are not in it. A database that is not ready or suspended lists none.
{
"databaseKeys": [
{
"keyIdInDatabase": "3f1c…",
"name": "made-in-db",
"permission": "read",
"isRevoked": false,
"firstSeenAt": "2026-01-15T10:00:00.000Z",
"lastSeenAt": "2026-01-15T11:00:00.000Z"
}
],
"tokenKeys": [
{
"kid": "k9",
"publicKey": "11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo",
"isRevoked": true,
"firstSeenAt": "2026-01-15T10:00:00.000Z",
"lastSeenAt": "2026-01-15T11:00:00.000Z"
}
],
"checkedAt": "2026-01-15T11:00:00.000Z"
}keyIdInDatabase is the database's own ID for the key, which this API's key endpoints do not take, and checkedAt when the database was last compared, null before the first time. These keys are managed in the database: this API does not revoke them.
curl "$MIMIC_MANAGEMENT_API/v1/databases/$DATABASE_ID/unmanaged-credentials" \
-H "Authorization: Bearer $MIMIC_API_KEY"Revoke a key not made here
DELETE /v1/databases/{databaseId}/unmanaged-credentials/database-keys/{keyIdInDatabase}
DELETE /v1/databases/{databaseId}/unmanaged-credentials/token-keys/{kid}Revokes in the database a key or token key listed as not made here, such as one a leaked admin key created; what it signed or minted ends with it. A key this API made is revoked through its own endpoint instead (409 here). Answers 204; repeating it is safe.
| Status | When |
|---|---|
404 | The database does not list such a key not made here (yet: it is compared about every 15 minutes) |
409 | The key is one this API made, or the database is not ready or suspended |
503 | The cluster could not be reached or did not answer in time; the key may be revoked already. Try again |