me

Rotate an API key (current user only)

Creates a new API key with the same settings as the old key and sets a grace period on the old key. During the grace period, both keys are valid.

post/admin/v1/me/api-keys/{key_id}/rotate

Request

  • Base URL: / (relative, and the document was published on a file host, not at the API’s origin)
  • URL: /admin/v1/me/api-keys/{key_id}/rotate
  • Auth: HTTP bearer

Path parameters

key_idstring uuid required

API key ID to rotate

Request body

grace_period_secondsinteger nullable

Grace period in seconds during which both old and new keys are valid. Default: 86400 (24 hours). Maximum: 604800 (7 days).

Response

API key rotated. Store the new key value securely.

allowed_modelsstring[] nullable

Allowed models (null = all models, supports wildcards like "gpt-4*")

budget_limit_centsinteger nullable

Budget limit in cents

budget_period'daily' | 'monthly'

Budget period for spending limits

created_atstring date-time required
expires_atstring date-time nullable
idstring uuid required
ip_allowliststring[] nullable

IP allowlist in CIDR notation (null = all IPs allowed)

key_prefixstring required

Prefix of the key (for identification without exposing full key)

last_used_atstring date-time nullable
namestring required
rate_limit_rpminteger nullable

Requests per minute override (null = use global default)

rate_limit_tpminteger nullable

Tokens per minute override (null = use global default)

revoked_atstring date-time nullable
rotated_from_key_idstring uuid nullable

ID of the key this was rotated from (for audit trail)

rotation_grace_untilstring date-time nullable

If set, this key is being rotated out but still valid until this time

scopesstring[] nullable

Permission scopes (null = full access) Valid scopes: chat, completions, embeddings, images, videos, audio, files, models, admin

keystring required

The raw API key (only shown once at creation)

Changes

No recorded changes to this operation across all 1 revision of this API.