REST API
A small, honest REST surface. Bearer-token auth, scoped keys, JSON in / JSON out. v1 covers the read paths your CI runner needs and one write path for logging decisions from external tooling.
Machine-readable spec: /api/v1/openapi.json (OpenAPI 3.1)
Typed client lives at lib/sdk in the repo — copy client.ts into your project. Zero deps, ~150 lines, types map 1:1 to the OpenAPI schema.
Authentication
Every API request must carry a workspace-scoped API key. Keys are minted from Settings → Integrations → API Access on the Enterprise plan. You see the plaintext exactly once at creation; we store only a SHA-256 hash.
# Authorization header (RFC 6750):
curl https://lazynext.com/api/v1/audit-log?workspaceId=<id> \
-H "Authorization: Bearer lzx_..."
# X-Api-Key header is also accepted:
curl https://lazynext.com/api/v1/audit-log?workspaceId=<id> \
-H "X-Api-Key: lzx_..."Cookie-session callers (the dashboard) use the same endpoints with no bearer header — your browser session handles it.
Scopes
Each key is minted with one or both scopes. Default is least-privilege.
read— call any GET endpoint.write— also call POST/PATCH/DELETE endpoints.
A request whose key is missing the required scope returns 403 INSUFFICIENT_SCOPE with a requiredScope field naming what it would have needed.
Rate limits
Buckets are keyed by the key id (cookie sessions: per user) so a leaked key burns its own budget. Each endpoint family has its own limit:
readendpoints — 100 / minute.exportendpoints (workspace dump, CSV) — 10 / minute.mutationendpoints (POST/PATCH/DELETE) — 30 / minute.
Exceeding the bucket returns 429 with a Retry-After header.
Endpoints
/api/v1/exportscope: readFull workspace export (workflows, nodes, decisions) as JSON. Pass ?workspaceId=<uuid> — for bearer requests this must match the key's workspace.
/api/v1/audit-logscope: readCursor-paginated audit log. Filterable by action, resourceType. Includes api_key.create and api_key.revoke entries. Requires the audit-log feature gate (Business plan and up).
/api/v1/decisionsscope: readLists every decision in the workspace, newest first.
/api/v1/decisions/export-csvscope: readSame data as /decisions rendered as a CSV stream — useful for dropping into a spreadsheet or BI tool.
/api/v1/decisionsscope: writeLog a new decision. Body is JSON: workspaceId, question (required), plus optional resolution, rationale, optionsConsidered, decisionType, tags, expectedBy. The Decision DNA scorer runs server-side and the score is in the response.
/api/v1/decisions/{id}scope: readSingle decision by id. Bearer keys must target the workspace that owns the decision — cross-workspace lookups return 403 WORKSPACE_MISMATCH.
/api/v1/decisions/{id}scope: writeUpdate resolution, rationale, status, outcome, outcomeNotes, outcomeConfidence, or tags. Setting an outcome (other than pending) bumps the workspace WMS.
/api/v1/decisions/{id}scope: writePermanently remove a decision. Cascades to all linked outcomes.
Errors
Errors are JSON: { "error": "CODE", "message"?: "..." }.
401 UNAUTHORIZED— no key, malformed key, expired key.403 FORBIDDEN— cookie user isn't a workspace member.403 WORKSPACE_MISMATCH— bearer key targets a different workspace than the request.403 INSUFFICIENT_SCOPE— key lacks the required scope.402 PLAN_GATE— feature requires a higher plan.429— rate-limit exceeded.503 DATABASE_NOT_CONFIGURED— only on misconfigured self-host installs.