VocalDocscontracts 1.65.0

Create an API key

POST /v1/api-keys

PropertyValue
Operationcreate_api_key
GroupAPI keys
Scopeapi_keys:write
Route classcontrol
IdempotencyIdempotency-Key accepted: a retry with the same key replays the first answer
AuditAudited identity.api_key.create (mutation)
Released in1.51.0
Phase 0 hostServed (the hosted api pins 1.65.0)

Creates an active key of the caller's Organization for one environment and answers ApiKeyCreated, the one answer that shows the full key (1.51.0, FR-identity-2); the api stores a per-key salt, the SHA-256 of salt and secret, and the prefix. A replay under the same Idempotency-Key creates nothing and answers secret null. A scope no API key may exercise is refused with validation_failed and the issue scope_session_only at /scopes/<i>, and an expires_at that is not in the future with expires_at_not_future; a scope the creator's role does not hold is refused with forbidden and the detail scope_not_grantable at /scopes/<i>, and a live key asked by a role that manages test keys only with the detail environment_not_grantable at /environment. From 1.57.0 (workspace ADR 0048 decision 2) a content scope (transcripts:read, tool_payloads:read, model_io:read, recordings:read) whose class the creator's role does not have allowed in the Compliance profile's content_visibility is refused with validation_failed and the issue content_scope_not_allowed at /scopes/<i> (contentScopeIssues), so a Member limited to reveal cannot mint a key that reads without a grant. The Audit event identity.api_key.create records the key id, its environment and its scopes, never the secret. Session only (api.md section 2): the api refuses the route to every API key with forbidden, whatever its scopes; Phase 0 accepts a Member ID token.

Request

Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the api_keys:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.

curl -X POST "$VOCAL_API/v1/api-keys" \
  -H "Authorization: Bearer $VOCAL_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "<name>",
    "environment": "live",
    "scopes": [
      "agents:read"
    ]
  }'

Parameters

NameInTypeRequiredDescription
idempotency-keyheaderstringnoA client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response.

Request body

Content type application/json, required: ApiKeyCreateRequest.

FieldTypeRequiredDescription
environmentEnvironmentyes
expires_atRequestTimestampnoWhen the key stops authenticating, in the future (expires_at_not_future); absent, the key does not expire.
namestringyesA name for the console, such as ci.
scopesarray of ApiKeyScopeyesThe permissions the key holds, each once: never one of SESSION_ONLY_PERMISSIONS (scope_session_only), never one the creator's role does not hold (forbidden with scope_not_grantable), and from 1.57.0 never a content scope whose class the creator's visibility cell does not allow (content_scope_not_allowed).

Responses

StatusContent typeShapeError codes
201application/jsonApiKeyCreated
400application/jsonErrorEnvelopeinvalid_request
401application/jsonErrorEnvelopeunauthenticated
403application/jsonErrorEnvelopeforbidden, org_suspended
409application/jsonErrorEnvelopeidempotency_in_progress, idempotency_key_reused
422application/jsonErrorEnvelopevalidation_failed
429application/jsonErrorEnveloperate_limited
500application/jsonErrorEnvelopeinternal_error

Fields of the 201 answer

The shape is ApiKeyCreated.

FieldTypeRequiredDescription
created_atTimestampyes
created_byActorRef or nullnoWho made the key (1.52.0): {type: member, id} for a key created through POST /v1/api-keys, {type: operator, id} for one the seed or an operator command made when the api records it, and null when it does not. Absent from an api before 1.52.0. A removed Member keeps its id here; the keys it made stay.
environmentEnvironmentyes
expires_atTimestamp or nullyes
idApiKeyIdyes
last_used_atTimestamp or nullyes
namestringyes
object"api_key"yes
prefixstringyesThe non-secret start of the key, vk_<env>_<lookup>; the full key is vk_<env>_<lookup>_<secret>.
revoked_atTimestamp or nullyes
scopesarray of ApiKeyScopeyes
secretApiKeySecret or nullyesThe full key (1.51.0), shown in this answer only and never again; null on a replay of the creation under the same Idempotency-Key, which creates nothing.
statusApiKeyStatusyes