API keys
Rotate an API key with an optional grace period
POST /v1/api-keys/{id}/rotate: Rotate an API key with an optional grace period
POST /v1/api-keys/{id}/rotate
| |
|---|
| Operation id | rotateApiKey |
| Key scope | admin: admin keys only |
| Section | API keys |
#Parameters
| Name | In | Type | Required | Description |
|---|
id | path | string | yes | pattern ^key_[0-9a-hjkmnp-tv-z]{26}$ |
#Request body
| Field | Type | Required | Description |
|---|
grace_seconds | integer | | ≥ 0 · ≤ 86400 · default 0 |
#Example request
curl -X POST "https://api.kaab.ist/v1/api-keys/{id}/rotate" \
-H "Authorization: Bearer $KAAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"grace_seconds":3600}'
#Responses
#200
Key
| Field | Type | Required | Description |
|---|
id | string | yes | pattern ^key_[0-9a-hjkmnp-tv-z]{26}$ |
object | "api_key" | yes | |
name | string | yes | |
prefix | string | yes | |
scopes | "run", "read", "admin" | yes | min items 1 |
mode | "live", "test" | yes | |
last_used_at | string or null (date-time) | yes | |
expires_at | string or null (date-time) | yes | |
created_at | string (date-time) | yes | |
key | string | yes | pattern ^sk_(live|test)_[A-Za-z0-9]{32,}$ |
#Errors
Every error answers with the error envelope; its code is one of the error codes.
| Status | When |
|---|
| 400 | request_invalid: request validation failed |
| 401 | Missing or invalid API key |
| 402 | insufficient_credits: top up to continue |
| 403 | The key's scope does not cover this operation |
| 404 | Resource not found |
| 409 | Conflicting state (see error.code) |
| 422 | Semantically invalid request (see error.code) |
| 429 | Rate limited; see Retry-After |
| 500 | internal: unexpected server error |
Was this page helpful?