DocsAPI ReferenceCreate a new API key
POST/api/v1/api-keys

Generates a new `srvk_` prefixed API key scoped to the workspace of the calling key. The full plaintext secret is returned **only once** in the response — copy it immediately. All future reads return metadata only (prefix, expiry, last used) but never the secret. Keys can optionally have an expiry. Keys without `expires_at` never expire.

Headers

X-API-Keystringrequired

Your existing workspace API key (must have edit permissions).

Content-Typestringrequired

Must be `application/json`.

Request Body

application/json

namestringrequired

Human-readable label to identify this key.

Example: "Production Bot Key"

expires_atstring

Optional expiry datetime (ISO 8601 UTC). Omit for a key that never expires.

Example: "2027-01-01T00:00:00Z"

Responses

201Key created. Copy the `key` field now — it will not be shown again.
{
  "id": 42,
  "name": "Production Bot Key",
  "prefix": "srvk_a1b2",
  "workspace_id": "aaaaaaaa-0000-0000-0000-000000000001",
  "created_at": "2026-05-12T10:00:00Z",
  "last_used_at": null,
  "expires_at": "2027-01-01T00:00:00Z",
  "key": "srvk_ABCdefGHIjklMNOpqrSTUvwxYZ0123456789abcd"
}
403API key is not bound to a workspace.