Authentication and API keys
Every /api/v1 request authenticates with a per-workspace API key sent as
a bearer token. There is no other credential scheme for the public API.
Authorization: Bearer klaf_live_…
Keys
- Format:
klaf_live_followed by 32 random bytes (base64url). Only the SHA-256 hash is stored; the raw key is shown once at creation. - Created in Settings → Integrations by a workspace owner or admin, with a name, a scope set, and an optional expiry (never / 30 / 90 / 365 days).
- One workspace per key. Every query is scoped to the key's workspace server-side; there is no way to address another workspace through the API. The workspace is resolved from the key, never from a client-supplied header or parameter.
- Revocation is immediate. A revoked key fails with
401on the next request — there is no token cache to wait out. lastUsedAtis updated at most once per key per minute.
Two-gate authorization
Every request passes two independent gates:
- Scope gate — the key must carry a scope for the endpoint's domain
(
tasks:writefor task writes,tasks:readfor task reads;writeimpliesreadfor the same domain). See Scopes. - Permission gate — the key creator's current Kalaaf permissions must include the operation's required permission, re-resolved fresh on every request. Revoking a user's role or removing them from the workspace immediately stops their keys — keys never outlive the creator's access.
Reads additionally run the workspace's own checks: feature gating per plan, project scope, and record confidentiality.
Rotating a key
- Create a new key with the same scopes.
- Update the external system to use the new key; verify a request succeeds.
- Revoke the old key.
Leaked key
Revoke it immediately in Settings → Integrations. Because authorization is
re-resolved per request, revocation takes effect on the next request.
Check the key's lastUsedAt and the workspace audit log for suspicious
activity, then rotate any webhook secrets that shared the same storage.
Troubleshooting
401— missing, expired, or revoked key, or the key's creator lost workspace access. Create a new key.403— the key lacks the scope for the endpoint, or the creator lacks the underlying Kalaaf permission. Add the scope (or grant the permission) and retry.