v97

latestOpenAPI 3.1.0raw.githubusercontent.com2026-07-31135175384.2 KB
API Keys

Rotate an API key

Rotate an API key. Issues a new key that copies the name and project of the rotated key, and schedules the rotated key to expire after a grace period so in-flight callers can swap over. The new plaintext key is returned once.

post/org/api_keys/{id}/rotate

Path parameters

idstring required

API key ID

Request body

days_to_expireinteger nullable

Lifetime in days for the new key, up to 3650. Omit to reuse the rotated key's original lifetime, or never-expires if it had none.

expire_in_daysinteger nullable

Grace period in days before the rotated key expires. Use 0 to expire it immediately. Omit for the default grace period of 7 days.

Example request

{
  "days_to_expire": 30,
  "expire_in_days": 7
}

Response

New API key created from the rotation

idstring required

Unique API key identifier

namestring required

Label for the API key. API keys are not addressable by name; use the ID or key identifier for stable references.

created_atstring date-time required

When the API key was created

expires_atstring date-time nullable required

When the API key expires

deleted_atstring date-time nullable required

When the API key was deleted (soft-deleted). Null for keys that have not been deleted.

project_idstring nullable required

Project identifier for project-scoped API keys. Null means org-wide.

project_namestring nullable required

Project name for project-scoped API keys. Null means the key is org-wide or the project name is unavailable.

masked_keystring required

Masked version of the API key

keystring required

Plaintext API key. Only returned once when the key is created.

Example response

{
  "id": "ckv9w8q2f000001l5r3j7k9m4",
  "name": "production",
  "created_by": {
    "id": "user-abc123",
    "email": "user@example.com",
    "name": "Jane Doe"
  },
  "project_id": "proj_abc123",
  "project_name": "Production",
  "masked_key": "sk_1234...abcd",
  "key": "sk_1234abcd"
}