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
| Field | Type | Required | Description |
|---|---|---|---|
name | `string | null` | no |
not_before | `string | null` | no |
expires_at | `string | null` | no |
org_id | `string | null` | no |
Responses
| Status | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
Response body
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | yes | — |
name | `string | null` | no |
created_at | string | yes | — |
last_used_at | `string | null` | no |
not_before | `string | null` | no |
expires_at | `string | null` | no |
org_id | `string | null` | no |
key | string | yes | — |
Operation ID: create_api_key_api_keys_post