Revoke an API key
POST /v1/api-keys/{key_id}:revoke · permission api-keys:write · optional Idempotency-Key
Revokes a key immediately. Revocation cannot be undone; the key is rejected within 30 seconds at the latest. A rotated key whose overlap has not ended is revoked at once as well. A key created in the dashboard, and every key rotated from it, can be revoked only by itself or in the dashboard (permission_escalation).
Request
| Parameter | In | Description |
|---|---|---|
key_id |
path | API key id (key_…). |
Body:
The body is optional; without it all defaults apply.
| Field | Type | Description |
|---|---|---|
reason |
string | Optional. manual (default) or leaked. |
Response
200 OK. The key object with revoked_at and revoke_reason set.
{
"id": "key_0000000000000000000000001z",
"name": "ci",
"type": "restricted",
"permissions": ["users:read"],
"allowed_cidrs": [],
"last4": "xxxx",
"created_by": "key_…",
"created_at": "2026-10-01T10:00:00Z",
"expires_at": "2027-10-01T10:00:00Z",
"last_used_at": null,
"last_used_ip": null,
"rotated_from": null,
"revoked_at": "2026-10-02T10:00:00Z",
"revoke_reason": "leaked"
}
Errors
| HTTP | code |
When |
|---|---|---|
| 401 | unauthenticated |
The key is missing, invalid or revoked. |
| 403 | insufficient_permissions |
The key lacks the required permission. |
| 403 | permission_escalation |
The request would give a key more permissions, a wider network range or a later expiry than the calling key has, a restricted key tries to create, rotate or revoke beyond its own permissions, or another key tries to rotate or revoke a key created in the dashboard. |
| 404 | not_found |
The key does not exist in this environment. |
| 409 | conflict |
The key is already revoked. |
| 422 | validation_failed |
The body is invalid: reason is not manual or leaked. |
Example
curl -X POST "https://api.eu.keenauth.com/v1/api-keys/key_0000000000000000000000001z:revoke" \
-H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"reason":"leaked"}'