latestOpenAPI 3.0.32026-08-20146131.7 MB

672b1916ba61

API Keys

Rotate API key

Rotates an API key and returns the new key plus the old key grace period.

post/v1/api-keys/{keyId}/rotate

Path parameters

keyIdstring required

API key identifier.

Example:key_example

API key identifier.

Headers

x-project-idstring

Selects the active project for this request. Required for session/dashboard callers. Ignored when authenticating with an API key, whose scope is fixed to the key's project.

Example:prj_example

Selects the active project for this request. Required for session/dashboard callers. Ignored when authenticating with an API key, whose scope is fixed to the key's project.

Request body

gracePeriodHoursnumber

Grace period for the old key before revocation.

Example request

{
  "gracePeriodHours": 24
}

Response

API key rotated

Example response

{
  "data": {
    "apiKey": {
      "id": "key_example",
      "name": "Primary Key",
      "key": "sk_test_example",
      "keyPrefix": "sk_test_abc",
      "role": "api_developer",
      "environment": "sandbox",
      "expiresAt": "2025-12-31T00:00:00.000Z",
      "createdAt": "2025-01-01T00:00:00.000Z"
    },
    "previousKey": {
      "id": "key_example",
      "rotationDeadline": "2025-02-01T00:00:00.000Z"
    }
  },
  "meta": {
    "requestId": "req_example",
    "timestamp": "2025-01-01T00:00:00.000Z"
  }
}