API reference navigation
POST /v1/keys/{id}/rotate

Rotate an API key

Access
Authenticated
keys:rotate
Cost
Free
Rate limit
20 / minute per account
Quota
None

Mint a fresh secret on the same key and retire the current one over a grace window (default 24h, capped at 168h), so both resolve until the old one expires. A key holding keys:rotate may rotate itself. The new plaintext is returned exactly once.

Path parameters

  • id string required
    max 16 chars

Request body RotateKeyRequest

  • graceMs integer

    How long the retiring secret keeps working, in milliseconds, so you can roll deployments without downtime. Defaults to 24 hours and is capped at 7 days. Send 0 to kill the old secret immediately.

    min 0, max 604800000
  • publicKeyJwk object
    • kty string required

      Key type. Must be `OKP`; anything else is rejected with a 400.

      OKP
    • crv string required

      Curve. Must be `Ed25519`; no other algorithm is accepted.

      Ed25519
    • x string required

      The base64url-encoded Ed25519 public key. Public material only — never send a private key.

      max 64 chars

Responses

  • 200 The new one-time secret
    • keyId string required

      The key this secret belongs to. Unchanged by the rotation.

    • secret string required

      The new plaintext key. Returned EXACTLY ONCE, here, and never retrievable again.

    • prefixHint string required

      The leading, non-secret part of the new key string.

    • last4 string required

      The last four characters of the new secret.

    • display string required

      The masked form, safe to show and log.

    • createdAt string required

      When the new secret was minted, as an ISO 8601 instant.

    • signerThumbprint string | null required

      The RFC 7638 thumbprint of the newly registered signer. Null when no JWK was supplied.

  • 401 No or invalid credential
    • code string required

      Stable machine-readable error code. Branch on this, never on the numeric status.

      bad_requestunauthorizedsignature_requiredpayment_requiredforbiddennot_foundconflictgonepayload_too_largeunprocessable_entitytoo_many_requestsinternal_errornot_implementedbilling_unavailablenot_contactablemailbox_link_unavailablemailbox_requiredmail_engine_unavailablewebhook_publisher_unavailabledatabase_unavailableclient_error
    • message string required

      Human-readable explanation of the refusal.

    • status integer required

      The HTTP status code, repeated in the body.

    • remedy object

      A self-serve path forward, when one exists (a 402 points at the credit top-up).

      • kind string required

        What kind of remedy this is, so a client can route it: whether the caller can clear the condition through the API, or a person must act in the web app.

        topupconnect_mailbox
      • url string required

        Where to go to clear the condition: an API path, or a web app page when only a person can.

  • 402 Plan does not include API keys
    • code string required

      Stable machine-readable error code. Branch on this, never on the numeric status.

      bad_requestunauthorizedsignature_requiredpayment_requiredforbiddennot_foundconflictgonepayload_too_largeunprocessable_entitytoo_many_requestsinternal_errornot_implementedbilling_unavailablenot_contactablemailbox_link_unavailablemailbox_requiredmail_engine_unavailablewebhook_publisher_unavailabledatabase_unavailableclient_error
    • message string required

      Human-readable explanation of the refusal.

    • status integer required

      The HTTP status code, repeated in the body.

    • remedy object

      A self-serve path forward, when one exists (a 402 points at the credit top-up).

      • kind string required

        What kind of remedy this is, so a client can route it: whether the caller can clear the condition through the API, or a person must act in the web app.

        topupconnect_mailbox
      • url string required

        Where to go to clear the condition: an API path, or a web app page when only a person can.

  • 403 Missing required entitlement
    • code string required

      Stable machine-readable error code. Branch on this, never on the numeric status.

      bad_requestunauthorizedsignature_requiredpayment_requiredforbiddennot_foundconflictgonepayload_too_largeunprocessable_entitytoo_many_requestsinternal_errornot_implementedbilling_unavailablenot_contactablemailbox_link_unavailablemailbox_requiredmail_engine_unavailablewebhook_publisher_unavailabledatabase_unavailableclient_error
    • message string required

      Human-readable explanation of the refusal.

    • status integer required

      The HTTP status code, repeated in the body.

    • remedy object

      A self-serve path forward, when one exists (a 402 points at the credit top-up).

      • kind string required

        What kind of remedy this is, so a client can route it: whether the caller can clear the condition through the API, or a person must act in the web app.

        topupconnect_mailbox
      • url string required

        Where to go to clear the condition: an API path, or a web app page when only a person can.

  • 404 No such key on this account
    • code string required

      Stable machine-readable error code. Branch on this, never on the numeric status.

      bad_requestunauthorizedsignature_requiredpayment_requiredforbiddennot_foundconflictgonepayload_too_largeunprocessable_entitytoo_many_requestsinternal_errornot_implementedbilling_unavailablenot_contactablemailbox_link_unavailablemailbox_requiredmail_engine_unavailablewebhook_publisher_unavailabledatabase_unavailableclient_error
    • message string required

      Human-readable explanation of the refusal.

    • status integer required

      The HTTP status code, repeated in the body.

    • remedy object

      A self-serve path forward, when one exists (a 402 points at the credit top-up).

      • kind string required

        What kind of remedy this is, so a client can route it: whether the caller can clear the condition through the API, or a person must act in the web app.

        topupconnect_mailbox
      • url string required

        Where to go to clear the condition: an API path, or a web app page when only a person can.