API keys
Claves para llamar a la API desde tus sistemas.
GET /v1/api-keys
List the API keys of my organization
Solo para usuarios con sesión iniciada (sin API key) · Rol: admin o superior
An `admin` or above, signed in as a user (an API key cannot manage keys). Newest first, revoked keys included. A key shows its `prefix` (the start of the secret, to tell keys apart), `scopes`, who created it, when it was `last_used_at` (at most a minute late) and its `expires_at` and `revoked_at`. The secret is never returned again. 401 when the token is missing, expired or invalid; 403 below `admin`; 503 when API keys are not available.
Respuestas
200Successful Response · ApiKeyListNombre Tipo Requerido Descripción itemsApiKeyResponse[]sí items[].created_atstring (date-time)sí items[].created_bystring | nullsí items[].created_by_namestring | nullitems[].expires_atstring (date-time) | nullsí items[].idstring (uuid)sí items[].last_used_atstring (date-time) | nullsí items[].namestringsí items[].prefixstringsí items[].revoked_atstring (date-time) | nullsí items[].scopesstring[]sí 401Missing, expired or invalid token. · ErrorResponse403Role below `admin`, or called with a key. · ErrorResponse503API keys are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
POST /v1/api-keys
Create an API key
Solo para usuarios con sesión iniciada (sin API key) · Rol: admin o superior
An `admin` or above, signed in as a user. `scopes` (at least one, no repeats) are `campaigns:read`, `campaigns:write`, `contacts:read`, `contacts:write`, `assistants:read`, `knowledge:read`, `knowledge:write`, `usage:read` and `credit:read`. `expires_at` is optional and must be in the future. The answer has the `secret` (`fnk_...`), **the only time it is shown**: only its hash is stored. Send it as `Authorization: Bearer <secret>` to the operations that accept a key: the operations whose contract shows `x-api-key-scope`. A key acts as an `editor` of its organization, limited to its scopes, and is limited per minute per key (`429` with `Retry-After`). Written to the audit log as `api_key.create`, without the secret. 401 when the token is missing, expired or invalid; 403 below `admin`; 422 when the body is invalid, no scope is given or the expiry is not in the future; 503 when API keys are not available.
Cuerpo de la solicitud
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
expires_at | string (date-time) | null | ||
name | string | sí | |
scopes | string[] | sí |
Respuestas
201Successful Response · CreatedApiKeyResponseNombre Tipo Requerido Descripción created_atstring (date-time)sí created_bystring | nullsí created_by_namestring | nullexpires_atstring (date-time) | nullsí idstring (uuid)sí last_used_atstring (date-time) | nullsí namestringsí prefixstringsí revoked_atstring (date-time) | nullsí scopesstring[]sí secretstringsí 401Missing, expired or invalid token. · ErrorResponse403Role below `admin`, or called with a key. · ErrorResponse503API keys are not available. · ErrorResponsedefaultDefault Response · ErrorResponse
POST /v1/api-keys/{key_id}/revoke
Revoke an API key
Solo para usuarios con sesión iniciada (sin API key) · Rol: admin o superior
An `admin` or above, signed in as a user. The key stops working at once and cannot be restored. Idempotent: a key already revoked is returned as it is. Written to the audit log as `api_key.revoke`. 401 when the token is missing, expired or invalid; 403 below `admin`; 404 when the key is not in the caller's tenant; 503 when API keys are not available.
Parámetros
| Nombre | En | Tipo | Requerido | Descripción |
|---|---|---|---|---|
key_id | path | string (uuid) | sí |
Respuestas
200Successful Response · ApiKeyResponseNombre Tipo Requerido Descripción created_atstring (date-time)sí created_bystring | nullsí created_by_namestring | nullexpires_atstring (date-time) | nullsí idstring (uuid)sí last_used_atstring (date-time) | nullsí namestringsí prefixstringsí revoked_atstring (date-time) | nullsí scopesstring[]sí 401Missing, expired or invalid token. · ErrorResponse403Role below `admin`, or called with a key. · ErrorResponse404No such key in the caller's tenant. · ErrorResponse503API keys are not available. · ErrorResponsedefaultDefault Response · ErrorResponse