Skip to content

Rotate an API key

Settings module

POST/api-keys/{id}/rotateapiKeys.rotate

Issues a new secret and revokes the old one. The secret is shown once. Requires `Idempotency-Key`; a replay returns the original response. A rule that refuses the request returns 422 with `refusal` and `reason`.

  • Requires the capability org.api_keys.manage.
  • OAuth scopes: org.
  • Send an Idempotency-Key header. A replay with the same key returns the original response.
  • Error statuses: 400, 401, 404, 409, 422, 429. Errors are RFC 9457 problem details.

Path and query parameters

apiKeys.rotate: Path and query parameters
FieldTypeRequiredDescription
idstring (uuid)YesIdentifier of the api key.

Response 200: ApiKeySecret

apiKeys.rotate: ApiKeySecret
FieldTypeRequiredDescription
api_key_idstring (uuid)YesIdentifier of the API key.
secretstringYesThe full key. Shown once; only its hash is stored.Constraints: length 1 to any
{
  "api_key_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "secret": "xos_live_7Hq2wQ1nC8vL0pR4tY6u"
}

Code samples

curl -X POST "$XOS_BASE_URL/api-keys/0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f/rotate" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
const { data } = await xos.apiKeys.rotate("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f");
response = xos.api_keys.rotate("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f")
xos api-keys rotate 0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f