Uygulamayı aç
Moonborn — API · api-keys

Rotate an API key (zero-downtime)

Issues a successor key with the same scopes. The old key transitions to `rotated` status. Supply `graceSeconds` to keep the old key accepted during the switchover window (Tier-0: zero-downtime rotation).

POST/v1/api-keys/{id}/rotatescope · Bearer (API key or session JWT)
Path parameters
FieldTypeDescription
idreqstringAPI key id (UUID).
Request body
FieldTypeDescription
graceSecondsnumber

Responses

201Rotation completed. New key `plaintextKey` returned once.
Body
FieldTypeDescription
oldKeyIdreqstring
newKeyreqobject
newKey.idreqstring
newKey.prefixreqstring
newKey.plaintextKeyreqstring
newKey.scopesreqstring · "*" | "read:personas" | "write:personas" | "read:chat" | "write:chat" | "read:marketplace" | "write:marketplace" | "read:billing" | "read:audit" | "read:webhooks" | "write:webhooks" | "read:config" | "write:config"[]
newKey.createdAtreqstring
newKey.expiresAtreqstring
graceSecondsreqnumber
400Validation error.
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject
401Unauthenticated.
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject
403Forbidden.
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject
404Key not found.
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject
409Key is in a terminal state (already rotated/revoked/expired).
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject

Examples

cURL
curl -X POST https://api.moonborn.co/v1/api-keys/<id>/rotate \
  -H "Authorization: Bearer $MOONBORN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "graceSeconds": 0
    }'
TypeScript
import Moonborn from '@moonborn/sdk';

const client = new Moonborn({ apiKey: process.env.MOONBORN_API_KEY });

const result = await client.api_keys.rotateApiKey({
  id: '<id>',
  graceSeconds: 0,
});
Python
import os
from moonborn import Moonborn

client = Moonborn(api_key=os.environ["MOONBORN_API_KEY"])

result = client.api_keys.rotate_api_key(
    id="<id>",
    grace_seconds=0,
)