API reference

API reference · Keys

Rotate a key with a grace period

POST/api/keys/{id}/rotateSigned in session

Mints a replacement carrying the same name, scopes, expiry, allowlist, organization and policy, and leaves the old key working until graceUntil. Revoking a production key with no window is how outages happen, so this is the supported way to change one. The replacement is held by the caller: an organization key rotated by an admin or owner who did not hold it spends as that admin or owner from then on, inside their own budget.

Parameters

Path and query parameters
FieldTypeWhat it is
id (path)requiredintegerThe key id.

Request body

application/json, optional

Request body fields
FieldTypeWhat it is
graceSecondsinteger0 to 2592000. Default 86400.

Example

{
  "graceSeconds": 0
}

Answer 201

Rotated.

Fields of the 201 answer
FieldTypeWhat it is
keystringThe replacement, shown exactly once.
idinteger
retiredKeyIdinteger
graceUntilintegerUnix ms. The old key stops working here.
notestring

Errors

  • 400OpenAI shaped error.
  • 401OpenAI shaped error.
  • 404OpenAI shaped error.
  • 409OpenAI shaped error.

Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.

Antimatter