Rotate an API key
Módulo Settings
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`.
- Requiere la capacidad org.api_keys.manage.
- Alcances de OAuth: org.
- Envía el encabezado Idempotency-Key. Una repetición con la misma clave devuelve la respuesta original.
- Estados de error: 400, 401, 404, 409, 422, 429. Los errores son detalles de problema RFC 9457.
Parámetros de ruta y de consulta
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| id | string (uuid) | Sí | Identifier of the api key. |
Respuesta 200: ApiKeySecret
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| api_key_id | string (uuid) | Sí | Identifier of the API key. |
| secret | string | Sí | The full key. Shown once; only its hash is stored.Restricciones: length 1 to any |
{
"api_key_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"secret": "xos_live_7Hq2wQ1nC8vL0pR4tY6u"
}Ejemplos de código
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