# API (/docs/reference/api)



The whole surface is self-documented. The OpenAPI document is generated from the routes and
served with two interactive references, **without a session or a key**:

```
GET /api/v1/openapi.json      the OpenAPI 3.1 document
GET /api/v1/docs              Scalar
GET /api/v1/docs/swagger      Swagger UI
```

## Two surfaces, two ways in [#two-surfaces-two-ways-in]

**Execution** — what an application calls, protected by an API key scoped to its project. The
key needs the `execute` scope (the default when it is created); a key without it gets `403`.
Responses carry `X-RateLimit-Limit` / `X-RateLimit-Remaining`, and `Retry-After` on a `429`.

```
POST /api/v1/decisions/:key/execute         ?version=latest|3|tag:stable, header X-Decision-Version
POST /api/v1/decisions/:key/execute/batch   { "items": [ {...}, {...} ] }
```

A batch runs every record against one version (resolved once, so a publish mid-batch cannot
split it), stores each record as a normal execution, and reports a failed record in place
without stopping the rest: the answer is `200` whenever the batch ran, so check
`summary.failed`. Each record costs one unit of the rate limit.
`EXECUTION_BATCH_MAX_ITEMS` (100) caps the size and `EXECUTION_BATCH_CONCURRENCY` (8) how many
run at once.

The execution record and its explanation are read from the console (session):

```
GET  /api/v1/executions/:id             full record: input, output, reasons, trace, deliveries
GET  /api/v1/executions/:id/explain     the reasons, for support and auditors
POST /api/v1/tables/:key/evaluate       try a table on its own
```

**Management** — what the console calls, protected by a session cookie. Requests carry the
active project in `x-project-id` (and the workspace in `x-workspace-id`), and the server proves
membership on every call.

```
POST     /api/v1/auth/register          account + workspace + first project, in one step
POST     /api/v1/auth/login             checks the password, sets the session cookie
POST     /api/v1/auth/logout            revokes the session server-side
POST     /api/v1/auth/forgot-password   emails a one-hour reset link (same answer for any address)
POST     /api/v1/auth/reset-password    sets the new password and ends every session
POST     /api/v1/auth/login/2fa         completes a sign-in with a TOTP or recovery code
GET      /api/v1/auth/2fa               POST /setup, /enable, /disable, /recovery-codes
PATCH    /api/v1/workspaces             rename, require two-factor authentication
POST     /api/v1/auth/sso/discover      GET /auth/sso/:id/start, /callback, /metadata, POST /acs
GET|POST /api/v1/workspaces/sso         PUT|DELETE /:id   identity providers
GET|POST /api/v1/workspaces/scim/tokens DELETE /:id; GET /scim/groups, PUT /scim/groups/:id/mapping
*        /api/v1/scim/v2/Users|Groups   SCIM 2.0, with a workspace SCIM token
GET      /api/v1/auth/me                user, workspaces and the projects they belong to
GET|POST /api/v1/workspaces             + /members, /members/:userId
GET|POST /api/v1/projects               + /:id/members, /:id/invitations
GET|POST /api/v1/decisions              GET|PATCH|DELETE /api/v1/decisions/:key
GET|PUT  /api/v1/decisions/:key/draft   optimistic concurrency via `revision` -> 409
POST     /api/v1/decisions/:key/publish POST /decisions/:key/validate
POST     /api/v1/decisions/:key/publish-requests   GET /publish-requests[/:id]
POST     /api/v1/publish-requests/:id/approve|reject|cancel
GET      /api/v1/decisions/:key/versions[/:version]
POST     /api/v1/decisions/:key/versions/:version/restore
POST     /api/v1/decisions/:key/simulate
GET|POST /api/v1/decisions/:key/tests   PUT|DELETE /tests/:id
POST     /api/v1/decisions/:key/tests/run   against the draft or a published version
POST     /api/v1/decisions/:key/backtest    replay executions or records, compare with a baseline
GET|POST /api/v1/tables …               drafts, publish, validate, evaluate, versions/:version
GET|POST /api/v1/comments              ?subjectType=decision|table&subjectKey=…   PATCH|DELETE /:id
GET|POST /api/v1/environments          PATCH|DELETE /:key, POST /:key/promote
POST     /api/v1/decisions/:key/deployments   { environment, version | from }
GET|PUT|DELETE /api/v1/decisions/:key/deployments/:environment/experiment   POST …/experiment/promote
GET|POST /api/v1/connections           DELETE /:id, POST /:id/test
GET|POST /api/v1/webhooks              PATCH|DELETE /:id, POST /:id/test
GET      /api/v1/webhooks/deliveries   POST /webhooks/deliveries/:id/retry
GET      /api/v1/outbox                POST /outbox/:id/retry, POST /outbox/retry
GET      /api/v1/audit-logs            ?entityType&action&actor&from&to&cursor
GET      /api/v1/audit-logs/export     ?format=csv|jsonl   /executions/export   /chain (verify)
GET|PUT  /api/v1/decisions/:key/access   restriction and per-member grants
GET|POST /api/v1/workspaces/roles      PUT|DELETE /:id   custom roles (x-workspace-id)
GET|POST|DELETE /api/v1/credentials     GET|POST|PATCH|DELETE /api/v1/api-keys
GET      /api/v1/auth/sessions         DELETE /:id, POST /sessions/revoke-others; POST /verify-email, /resend-verification; GET /config
POST     /api/v1/decisions/import      POST /import-bundle; POST /:key/restore; PUT /:key/tags; GET /:key/runtime-bundle; GET /:key/monitoring
GET|POST /api/v1/datasets              GET /:key[/versions/:version], POST /:key/versions, DELETE /:key, POST /:key/restore
GET|POST /api/v1/tags                  PATCH|DELETE /:id
GET|POST /api/v1/globals               PATCH|DELETE /:name
GET|POST /api/v1/email-templates       GET|PATCH|DELETE /:key, POST /:key/preview, /:key/test-send
GET|POST /api/v1/features              GET|POST /:key/observations, GET /:key/aggregate
GET|POST /api/v1/cases                 GET|PATCH /:id, POST /:id/transition|resolve|reopen, /bulk; members, messages, attachments, PUT /:id/tags
GET|POST /api/v1/case-types            GET|PATCH|DELETE /:key, POST /:key/reset
GET|POST /api/v1/scheduled-jobs        GET|PATCH|DELETE /:id, POST /:id/run|preview, GET /:id/runs|stats, /runs/:runId[/items], POST /test-source
GET      /api/v1/notifications         POST /read-all, /:id/read; GET|PUT /preferences
GET|POST /api/v1/webhooks/inbound      PATCH|DELETE /:id, POST /:id/rotate-secret|rotate-token; routes, events, POST /:id/routes/:routeId/test
POST     /api/v1/public/webhooks/:token   public inbound webhook receiver, no session (signed by the sender)
GET|PUT  /api/v1/decisions/:key/versions/:version/public-form   GET /api/v1/public/forms/:token; POST …/unlock, …/submissions (no session)
GET      /api/v1/workspaces/http-logs  /stats, /filters, /archives, /export, /:id
GET|POST /api/v1/personal-data/requests   POST /personal-data/erasures
GET      /api/v1/stats                 GET /api/v1/meta, /api/v1/templates[/:id]
POST     /api/v1/assistant/decision-draft   /explain, /explain-execution, /test-cases, /dead-rules, /formula
*        /api/v1/mcp                   MCP server over HTTP, with an API key
*        /api/v1/admin/*               platform admin only (see Platform administration)
```

## The shape of an error [#the-shape-of-an-error]

Errors are uniform:

```json
{ "error": { "code": "...", "message": "...", "details": {/* optional */} } }
```

Stable codes include `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_A_MEMBER`,
`INVALID_CREDENTIALS`, `EMAIL_TAKEN`, `VERSION_NOT_FOUND`, `UPSTREAM_FAILED`, `RATE_LIMITED`,
`APPROVAL_REQUIRED`, `TESTS_FAILED`, `TWO_FACTOR_REQUIRED`, `SSO_REQUIRED`.

See [Errors](/docs/reference/errors) for the full list.
