Skip to content
Sign in Create account

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

  • id integer path required

Responses

200 Replacement key created; plaintext is returned once and the old key is deactivated.

application/json object

  • api_key any required

    All of

  • rotated_from integer required
  • warning string 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

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any 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

  • error object required
    • code string required
      One of: "idempotency_key_conflict", "idempotency_request_in_progress", "idempotency_response_not_retained"
    • message string required
    • type string required
      Value: "idempotency_error"
422 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

429 The request was rate limited. API-generated responses are JSON;

Response headers

  • Retry-After string header

    Seconds to wait before retrying, when provided.

  • X-RateLimit-Scope string header

    Identifies the scope of the request limit, when provided.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

text/html string

500 Rotation transaction failed.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.