Workspace

Settings, API keys, audit log, analytics and usage.

Workspace settings#

Workspace settings

GET/api/v2/settings

Requires settings:read.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/settings" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"settings": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"slug": "invoices",
"logo": "logo",
"createdAt": "2026-10-01T12:00:00.000Z",
"retentionDays": 1,
"defaultThreshold": 1,
"allowedDomains": [
"allowedDomain"
],
"defaultModel": "defaultModel",
"counts": {
"members": 1,
"documents": 1,
"queues": 1
}
},
"role": "role"
}

Update workspace settings#

Update workspace settings

PATCH/api/v2/settings

Requires settings:manage.

Body

application/json
namestring
slugstring
logostring | null
retentionDaysinteger | null
defaultThresholdnumber
allowedDomainsstring[]
defaultModelstring | null

Responses

OK

curl -X PATCH "https://docuflow.pendral.io/api/v2/settings" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoices",
"slug": "invoices"
}'
Response200
{
"settings": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"slug": "invoices",
"logo": "logo",
"createdAt": "2026-10-01T12:00:00.000Z",
"retentionDays": 1,
"defaultThreshold": 1,
"allowedDomains": [
"allowedDomain"
],
"defaultModel": "defaultModel",
"counts": {
"members": 1,
"documents": 1,
"queues": 1
}
}
}

List business calendars#

Weekly open intervals, holiday presets and date exceptions SLA clocks count in, with the queues using each. The workspace default is created on first read.

GET/api/v2/business-calendars

Requires queues:read.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/business-calendars" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"calendars": [
{
"name": "Invoices",
"timeZone": "timeZone",
"week": [
[
{
"start": 1,
"end": 1
}
]
],
"presets": [
"us_federal"
],
"exceptions": [
{
"date": "date",
"name": "Invoices",
"hours": []
}
],
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"isDefault": false,
"updatedAt": "2026-10-01T12:00:00.000Z",
"queues": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices"
}
]
}
]
}

Create a business calendar#

Create a business calendar

POST/api/v2/business-calendars

Requires settings:manage.

Body

application/json
namestringrequired
timeZonestringrequired
weekobject[][]required
presets("us_federal" | "payer_common")[]required
exceptionsobject[]required

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/business-calendars" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoices",
"timeZone": "timeZone",
"week": [
[
{
"start": 1,
"end": 1
}
]
],
"presets": [
"us_federal"
],
"exceptions": [
{
"date": "date",
"name": "Invoices",
"hours": [
{
"start": 1,
"end": 1
}
]
}
]
}'
Response201
{
"calendar": {
"name": "Invoices",
"timeZone": "timeZone",
"week": [
[
{
"start": 1,
"end": 1
}
]
],
"presets": [
"us_federal"
],
"exceptions": [
{
"date": "date",
"name": "Invoices",
"hours": [
{
"start": 1,
"end": 1
}
]
}
],
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"isDefault": false,
"updatedAt": "2026-10-01T12:00:00.000Z"
}
}

Get a business calendar#

One calendar with the queues whose business-hours SLA counts in it.

GET/api/v2/business-calendars/{id}

Requires queues:read.

Path parameters

idstringrequired
Calendar id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/business-calendars/{id}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"calendar": {
"name": "Invoices",
"timeZone": "timeZone",
"week": [
[
{
"start": 1,
"end": 1
}
]
],
"presets": [
"us_federal"
],
"exceptions": [
{
"date": "date",
"name": "Invoices",
"hours": [
{
"start": 1,
"end": 1
}
]
}
],
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"isDefault": false,
"updatedAt": "2026-10-01T12:00:00.000Z",
"queues": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices"
}
]
}
}

Update a business calendar#

Send isDefault: true to make it the workspace default. Open, not-yet-breached documents on affected queues get their due times re-computed.

PATCH/api/v2/business-calendars/{id}

Requires settings:manage.

Path parameters

idstringrequired
Calendar id.

Body

application/json
namestring
timeZonestring
weekobject[][]
presets("us_federal" | "payer_common")[]
exceptionsobject[]
isDefaulttrue

Responses

OK

curl -X PATCH "https://docuflow.pendral.io/api/v2/business-calendars/{id}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoices"
}'
Response200
{
"calendar": {
"name": "Invoices",
"timeZone": "timeZone",
"week": [
[
{
"start": 1,
"end": 1
}
]
],
"presets": [
"us_federal"
],
"exceptions": [
{
"date": "date",
"name": "Invoices",
"hours": [
{
"start": 1,
"end": 1
}
]
}
],
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"isDefault": false,
"updatedAt": "2026-10-01T12:00:00.000Z"
}
}

Delete a business calendar#

The default can't be deleted. Queues on it fall back to the default.

DELETE/api/v2/business-calendars/{id}

Requires settings:manage.

Path parameters

idstringrequired
Calendar id.

Responses

OK

curl -X DELETE "https://docuflow.pendral.io/api/v2/business-calendars/{id}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"ok": true
}

AI spend#

What the models cost over a period, grouped by day, model, kind of work, queue and document. Computed from the per-call record.

GET/api/v2/spend

Requires usage:read.

Query parameters

period"24h" | "7d" | "30d" | "90d"
Default"30d"

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/spend" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"period": "period",
"from": "2026-10-01T12:00:00.000Z",
"promptsRecorded": false,
"totals": {
"calls": 1,
"errors": 1,
"inputTokens": 1,
"outputTokens": 1,
"cachedTokens": 1,
"reasoningTokens": 1,
"costUsd": 1,
"medianMs": 1,
"p95Ms": 1
},
"byDay": [
{
"day": "day",
"costUsd": 1,
"calls": 1
}
],
"byModel": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"calls": 1,
"costUsd": 1,
"inputTokens": 1,
"outputTokens": 1,
"medianMs": 1
}
],
"byKind": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"calls": 1,
"costUsd": 1,
"inputTokens": 1,
"outputTokens": 1,
"medianMs": 1
}
],
"byQueue": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"calls": 1,
"costUsd": 1,
"inputTokens": 1,
"outputTokens": 1,
"medianMs": 1
}
],
"topDocuments": [
{
"documentId": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"costUsd": 1,
"calls": 1
}
]
}

List AI traces#

One row per piece of AI work — an extraction, a classification, a rule that asked a model something — with its token counts, cost and duration.

GET/api/v2/traces

Requires usage:traces.cursor-paginated

Query parameters

period"24h" | "7d" | "30d" | "90d"
kindstring
status"running" | "ok" | "error"
documentIdstring
queueIdstring
searchstring
cursorstring
limitinteger

Responses

OK. Cursor-paginated: pass nextCursor back as cursor; null means the last page.

curl -X GET "https://docuflow.pendral.io/api/v2/traces" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"items": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"kind": "kind",
"name": "Invoices",
"source": "upload",
"status": "status",
"error": null,
"documentId": "clx9k2m4p0001qh8z3v7d5f2a",
"queueId": "clx9k2m4p0001qh8z3v7d5f2a",
"userId": "clx9k2m4p0001qh8z3v7d5f2a",
"callCount": 1,
"errorCount": 1,
"inputTokens": 1,
"outputTokens": 1,
"cachedTokens": 1,
"reasoningTokens": 1,
"costUsd": 1,
"startedAt": "2026-10-01T12:00:00.000Z",
"endedAt": "2026-10-01T12:00:00.000Z",
"durationMs": 184
}
],
"nextCursor": "clx9k2m4p0001qh8z3v7d5f2a"
}

One AI trace#

The trace with every model call inside it, in the order they were made. Prompt and answer text is only present when prompt capture is enabled for the deployment.

GET/api/v2/traces/{id}

Requires usage:traces.

Path parameters

idstringrequired
Trace id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/traces/{id}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"trace": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"kind": "kind",
"name": "Invoices",
"source": "upload",
"status": "status",
"error": null,
"documentId": "clx9k2m4p0001qh8z3v7d5f2a",
"queueId": "clx9k2m4p0001qh8z3v7d5f2a",
"userId": "clx9k2m4p0001qh8z3v7d5f2a",
"callCount": 1,
"errorCount": 1,
"inputTokens": 1,
"outputTokens": 1,
"cachedTokens": 1,
"reasoningTokens": 1,
"costUsd": 1,
"startedAt": "2026-10-01T12:00:00.000Z",
"endedAt": "2026-10-01T12:00:00.000Z",
"durationMs": 184,
"metadata": {},
"spans": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"seq": 1,
"kind": "kind",
"name": "Invoices",
"status": "status",
"error": null,
"model": "model",
"provider": "provider",
"finishReason": "finishReason",
"promptText": "promptText",
"outputText": "outputText",
"params": {},
"truncated": false,
"inputTokens": 1,
"outputTokens": 1,
"cachedTokens": 1,
"reasoningTokens": 1,
"costUsd": 1,
"startedAt": "2026-10-01T12:00:00.000Z",
"endedAt": "2026-10-01T12:00:00.000Z",
"durationMs": 184
}
],
"document": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "invoice-1042.pdf",
"status": "status"
},
"queue": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"slug": "invoices",
"color": "indigo"
},
"promptsRecorded": false
}
}

List API keys#

List API keys

GET/api/v2/api-keys

Requires apiKeys:read.

Needs a signed-in person: API keys can't call this.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/api-keys" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION"
Response200
{
"apiKeys": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Accounts payable sync",
"prefix": "dfk_live_7Hq2",
"scopes": [
"documents:read",
"documents:create"
],
"rateLimit": 1,
"lastUsedAt": "2026-10-01T12:00:00.000Z",
"expiresAt": null,
"revokedAt": null,
"createdAt": "2026-10-01T12:00:00.000Z",
"createdBy": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
}
}
]
}

Create an API key#

The dfk_ token is returned once. scopes are narrowed to the grantable catalog and to your own permissions; governance scopes are never grantable.

POST/api/v2/api-keys

Requires apiKeys:manage.

Needs a signed-in person: API keys can't call this.

Body

application/json
namestringrequired
expiresAtstring | null
scopesstring[]
rateLimitinteger | null

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/api-keys" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoices",
"scopes": [
"documents:read",
"documents:create"
]
}'
Response201
{
"apiKey": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Accounts payable sync",
"prefix": "dfk_live_7Hq2",
"scopes": [
"documents:read",
"documents:create"
],
"rateLimit": 1,
"lastUsedAt": "2026-10-01T12:00:00.000Z",
"expiresAt": null,
"revokedAt": null,
"createdAt": "2026-10-01T12:00:00.000Z",
"createdBy": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
}
},
"token": "dfk_live_7Hq2xV9mLr4tW8bN3cKp"
}

Get an API key#

Its name, prefix, scopes, rate limit, creator and when it was last used. Never the token. Keys can't hold apiKeys:*, so managing keys needs a signed-in person; a key can describe itself through /whoami.

GET/api/v2/api-keys/{id}

Requires apiKeys:read.

Needs a signed-in person: API keys can't call this.

Path parameters

idstringrequired
API key id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/api-keys/{id}" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION"
Response200
{
"apiKey": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Accounts payable sync",
"prefix": "dfk_live_7Hq2",
"scopes": [
"documents:read",
"documents:create"
],
"rateLimit": 1,
"lastUsedAt": "2026-10-01T12:00:00.000Z",
"expiresAt": null,
"revokedAt": null,
"createdAt": "2026-10-01T12:00:00.000Z",
"createdBy": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
}
}
}

Change an API key's rate limit#

rateLimit is requests per minute; null puts the key back on the workspace default.

PATCH/api/v2/api-keys/{id}

Requires apiKeys:manage.

Needs a signed-in person: API keys can't call this.

Path parameters

idstringrequired
API key id.

Body

application/json
rateLimitinteger | nullrequired

Responses

OK

curl -X PATCH "https://docuflow.pendral.io/api/v2/api-keys/{id}" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION" \
-H "Content-Type: application/json" \
-d '{
"rateLimit": 1
}'
Response200
{
"apiKey": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Accounts payable sync",
"prefix": "dfk_live_7Hq2",
"scopes": [
"documents:read",
"documents:create"
],
"rateLimit": 1,
"lastUsedAt": "2026-10-01T12:00:00.000Z",
"expiresAt": null,
"revokedAt": null,
"createdAt": "2026-10-01T12:00:00.000Z",
"createdBy": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
}
}
}

Revoke an API key#

Revoke an API key

DELETE/api/v2/api-keys/{id}

Requires apiKeys:manage.

Needs a signed-in person: API keys can't call this.

Path parameters

idstringrequired
API key id.

Responses

OK

curl -X DELETE "https://docuflow.pendral.io/api/v2/api-keys/{id}" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION"
Response200
{
"ok": true
}

Audit log#

Append-only activity. action matches a prefix when it ends with a dot (document.). format=csv downloads up to 500 rows as CSV.

GET/api/v2/audit

Requires audit:read.cursor-paginated

Query parameters

actorstring
actionstring
targetTypestring
targetIdstring
searchstring
fromstring
tostring
cursorstring
limitnumber
format"json" | "csv"

Responses

OK. Cursor-paginated: pass nextCursor back as cursor; null means the last page.

curl -X GET "https://docuflow.pendral.io/api/v2/audit" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"items": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"actor": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
},
"actorType": "actorType",
"actorLabel": "actorLabel",
"action": "action",
"targetType": "targetType",
"targetId": "clx9k2m4p0001qh8z3v7d5f2a",
"targetLabel": "targetLabel",
"summary": "summary",
"metadata": null,
"ip": "ip",
"userAgent": "userAgent",
"createdAt": "2026-10-01T12:00:00.000Z"
}
],
"nextCursor": "clx9k2m4p0001qh8z3v7d5f2a"
}

Get an audit entry#

One entry of the activity log with its full metadata.

GET/api/v2/audit/{id}

Requires audit:read.

Path parameters

idstringrequired
Audit entry id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/audit/{id}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"entry": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"actor": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
},
"actorType": "actorType",
"actorLabel": "actorLabel",
"action": "action",
"targetType": "targetType",
"targetId": "clx9k2m4p0001qh8z3v7d5f2a",
"targetLabel": "targetLabel",
"summary": "summary",
"metadata": null,
"ip": "ip",
"userAgent": "userAgent",
"createdAt": "2026-10-01T12:00:00.000Z"
}
}

Workspace, plan and usage#

The workspace this credential is bound to, the plan in force, what it includes, each limit (-1 = unlimited) and how much of it is used — so an integration can see a plan_limit coming instead of meeting a 402. Needs usage:read, which an API key may hold; workspace governance stays with people.

GET/api/v2/workspace

Requires usage:read.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/workspace" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"workspace": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Acme Health",
"slug": "acme-health",
"personal": false
},
"plan": "free",
"granted": false,
"expiresAt": null,
"enforced": false,
"features": [
"feature"
],
"limits": {
"key": 1
},
"usage": {
"key": 1
}
}

Analytics#

Throughput, auto-approval, processing times, field accuracy and usage.

GET/api/v2/analytics

Requires analytics:read.

Query parameters

period"7d" | "30d" | "90d"
Default"30d"

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/analytics" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"totals": {},
"usage": {}
}

Usage#

Pages and cost for billing views (a subset of analytics).

GET/api/v2/usage

Requires usage:read.

Query parameters

period"7d" | "30d" | "90d"
Default"30d"

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/usage" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"period": "period",
"usage": {},
"documents": 1
}