Getting started

Authentication

One key, one header, one workspace. A key acts as the person who made it, and never as more than them.

Sending the key

Every request carries the key as a bearer token. Keys are created and revoked under Developers → API keys; a revoked key stops working on its next request.

curl "https://docuflow.pendral.io/api/v2/documents" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"

x-api-key works too

For clients that can't set Authorization, send the same key as x-api-key: dfk_…. The app itself calls the same endpoints with its browser session, which is why some are documented as needing a signed-in person.

What a key is

dfk_…
Keys are prefixed so they can be recognised in a log or a leak scan. The token is shown once, at creation; DocuFlow keeps only its hash.
one workspace
A key belongs to the workspace you were working in when you made it. A document or queue in another workspace answers 404, the same as one that does not exist.
its creator, or less
A key acts as the person who created it. What it may do is the creator's permissions ∩ the key's scopes, worked out on every request, so a key loses access the moment its creator's role narrows or they leave the workspace, and is turned away if their account is deactivated.
expiresAt, rateLimit
Optional at creation: a date after which the key is refused, and its own requests-per-minute ceiling in place of the workspace default.

Treat a key as a password

Keep it in an environment variable or a secret store. Never in source control, a browser bundle or a mobile app.

Scopes

Scopes are permissions in module:action form, the same vocabulary roles are made of. Choose them when you create a key and it can do only those things, narrowed further to whatever you yourself hold. Each endpoint's reference names the permission it requires; a request outside the key's reach is refused with 403 forbidden, and details.required names what was missing.

POST /api/v2/api-keys
{
"name": "Accounts payable sync",
"scopes": ["documents:create", "documents:read", "queues:read"],
"rateLimit": 300
}

Queue-scoped endpoints check the permission on the queue they touch. If your role grants a permission on some queues only, a key you create carries the same limit: lists come back narrowed to those queues and anything else answers 404.

What a key can never do

Governance needs a person. Keys can never hold members, teams, roles, org, apiKeys or platform permissions, whatever their creator holds: a key cannot invite people, change roles, mint other keys or administer the platform. Endpoints that act for the signed-in person (their profile, sessions, notifications) refuse keys as well. The reference marks every one of them Needs a signed-in person.

Asking what a key can do

GET /api/v2/whoami needs no permission beyond a valid credential. It returns the key, the person it acts as, the workspace, the effective permissions after scoping, the queues it is limited to (null for all) and what is left of this minute's budget.

curl "https://docuflow.pendral.io/api/v2/whoami" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"

When it fails

401unauthorized
No credential, or a key that is invalid, expired or revoked. Every one of those gets the same answer, so the API never says which keys exist.Check the header and that the variable is set where the code runs.
403forbidden
A valid key, refused here: it lacks the permission (named in details.required), or the endpoint needs a signed-in person.Scopes are fixed at creation; issue a new key rather than editing this one.
402plan_required, plan_limit
The key may do this, but the workspace's plan does not include it or has reached a limit.See plans.
429rate_limited
Over this key's requests per minute.Wait for Retry-After; see rate limits.