Skip to main content

Create API Key

Creates a new API key. The full key value is returned only once in the response — store it securely.
For new integrations we recommend OAuth clients or the SDK instead of long-lived API keys — short-lived tokens, scope narrowing, and no long-lived secret to store. See the Authentication guide. This endpoint remains fully supported; the examples below authenticate with a minted OAuth access token ($TOKEN).

Request Body

The key_type is set automatically based on the host the request is sent to and cannot be specified in the request body. Requests to api.knoxcall.com produce a standard key; requests to sandbox.knoxcall.com produce a test key.

Response

The api_key field contains the full key and is only returned at creation time. KnoxCall does not store the plain-text key. If you lose it, you must revoke it and create a new one.

Permissions on the new key

A key created with no role_ids holds no policy, and is therefore default-denied on every policy-gated endpoint — it authenticates, then 403s. That is the platform default since the legacy *:* auto-attach was retired, and it is almost never what you want.
Roles govern the /v1 management API, not calls to your routes. The proxy does not evaluate a key’s roles today: any active key can call any enabled route in its mode (Live or Test) — including a key holding only Key — Read-only, or no role at all. What limits proxied calls is each route’s own configuration: Require authorized clients (set per environment — the caller must be one of the route’s clients, identified by source IP or mTLS certificate) and the route’s IP allowlist. An OAuth access token minted with explicit scopes is narrowed on the proxy as well: it needs routes:invoke:<slug> for one route, or routes:invoke, routes:* or *:* for every route. Management scopes such as routes:read and routes:write do not let it call a route.
List the roles you can attach with GET /v1/roles?subject_kind=api_key and pass their ids:
A key can never mint a key more privileged than itself. Every rule in every requested role must be covered by a rule the calling credential already holds. If it is not, the request is refused with 403 privilege_escalation and the response names the offending grant verbatim so you can see exactly what was rejected:
Two grants can never be delegated at all by a key holding only a wildcard (*:*) rule: secret:reveal and the custody / workload-binding actions. Delegating one requires the calling key to name that exact (resource_type, action) pair literally.
A scope-narrowed OAuth access token cannot create API keys, with or without role_ids. An API key carries no scope narrowing, so any key such a token created would exceed the token’s own grant; the call returns 403 privilege_escalation. Create keys with an API key, or with an OAuth token whose scope is not narrowed (no scope requested, or *).

Errors