Rotate a dashboard API key (revoke old, issue new)
POST /api/keys/{id}/rotate
Atomically creates a replacement for a key owned by the authenticated account and deactivates the old key. Requires keys.write and api-keys.rotate; the new plaintext is returned once. Transaction failure returns 500 and a missing or other-account key returns 404.
Authenticate with a portal session token.
Parameters
idinteger path required
Responses
200 Replacement key created; plaintext is returned once and the old key is deactivated.
application/json object
api_keyany requiredAll of
- ApiKeyResourceC6b
- object
keystring requiredWrite only
rotated_frominteger requiredwarningstring required
Generated sample
{
"api_key": {
"allowed_ips": [
"string"
],
"created_at": "2026-01-01T00:00:00Z",
"expires_at": "2026-01-01T00:00:00Z",
"id": 0,
"is_active": true,
"is_default": true,
"last_used_at": "2026-01-01T00:00:00Z",
"mirrors_account_settings": true,
"name": "string",
"permissions": [
"string"
],
"prefix": "string",
"privacy_tier_override": "balanced",
"rate_limit_rpm": 0,
"key": "string"
},
"rotated_from": 0,
"warning": "string"
}401 Missing or invalid bearer token.
application/json object
Any keys are accepted.
403 Authenticated caller lacks the required permission, ability, or role.
application/json object
Any keys are accepted.
404 Key was not found for this account.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
409 The Idempotency-Key cannot be used for this request because it conflicts with another request (idempotency_key_conflict), is still in progress (idempotency_request_in_progress), or its response was not retained (idempotency_response_not_retained).
application/json IdempotencyError
errorobject requiredcodestring requiredOne of:"idempotency_key_conflict","idempotency_request_in_progress","idempotency_response_not_retained"messagestring requiredtypestring requiredValue:"idempotency_error"
422 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
429 The request was rate limited. API-generated responses are JSON;
Response headers
Retry-Afterstring headerSeconds to wait before retrying, when provided.
X-RateLimit-Scopestring headerIdentifies the scope of the request limit, when provided.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
text/html string
500 Rotation transaction failed.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.