Skip to main content

Create API key

POST /api/keys

Create a new API key for the authenticated user. The new key is bound to key_data.org_id when provided. An omitted org_id falls back to the request's effective org (preserving the pre-existing API). An explicit org_id: null creates an unbound key whose effective org is resolved per-request via the X-Org-Id header or, as a fallback, the caller's user.current_org_id. When a specific org_id is supplied, the caller must be a member of that org (or hold a super role).

Request body

FieldTypeRequiredDescription
name`stringnull`no
not_before`stringnull`no
expires_at`stringnull`no
org_id`stringnull`no

Responses

StatusDescription
200Successful Response
422Validation Error

Response body

FieldTypeRequiredDescription
idintegeryes
name`stringnull`no
created_atstringyes
last_used_at`stringnull`no
not_before`stringnull`no
expires_at`stringnull`no
org_id`stringnull`no
keystringyes

Operation ID: create_api_key_api_keys_post