Referencia de la API

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

  • 200 Successful Response · ApiKeyList
    NombreTipoRequeridoDescripción
    itemsApiKeyResponse[]sí
    items[].created_atstring (date-time)sí
    items[].created_bystring | nullsí
    items[].created_by_namestring | null
    items[].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í
  • 401 Missing, expired or invalid token. · ErrorResponse
  • 403 Role below `admin`, or called with a key. · ErrorResponse
  • 503 API keys are not available. · ErrorResponse
  • default Default 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

NombreTipoRequeridoDescripción
expires_atstring (date-time) | null
namestringsí
scopesstring[]sí

Respuestas

  • 201 Successful Response · CreatedApiKeyResponse
    NombreTipoRequeridoDescripción
    created_atstring (date-time)sí
    created_bystring | nullsí
    created_by_namestring | null
    expires_atstring (date-time) | nullsí
    idstring (uuid)sí
    last_used_atstring (date-time) | nullsí
    namestringsí
    prefixstringsí
    revoked_atstring (date-time) | nullsí
    scopesstring[]sí
    secretstringsí
  • 401 Missing, expired or invalid token. · ErrorResponse
  • 403 Role below `admin`, or called with a key. · ErrorResponse
  • 503 API keys are not available. · ErrorResponse
  • default Default 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

NombreEnTipoRequeridoDescripción
key_idpathstring (uuid)sí

Respuestas

  • 200 Successful Response · ApiKeyResponse
    NombreTipoRequeridoDescripción
    created_atstring (date-time)sí
    created_bystring | nullsí
    created_by_namestring | null
    expires_atstring (date-time) | nullsí
    idstring (uuid)sí
    last_used_atstring (date-time) | nullsí
    namestringsí
    prefixstringsí
    revoked_atstring (date-time) | nullsí
    scopesstring[]sí
  • 401 Missing, expired or invalid token. · ErrorResponse
  • 403 Role below `admin`, or called with a key. · ErrorResponse
  • 404 No such key in the caller's tenant. · ErrorResponse
  • 503 API keys are not available. · ErrorResponse
  • default Default Response · ErrorResponse