Common Patterns

Documentation for Common Patterns

Pagination

List endpoints accept the following query parameters:

ParameterTypeDefaultConstraintsDescription
pagenumber1min: 1Page number (1-indexed)
limitnumber20min: 1, max: 100Items per page

Paginated responses include a pagination object:

json

Error Responses

All errors follow a consistent JSON shape:

json

Common HTTP Status Codes

StatusMeaning
200 OKSuccess
201 CreatedResource successfully created
400 Bad RequestInvalid request parameters or body (validation failure)
401 UnauthorizedMissing or invalid JWT token
403 ForbiddenToken valid but permission denied
404 Not FoundResource not found or not accessible (ownership check failed)
429 Too Many RequestsRate limit exceeded
500 Internal Server ErrorUnexpected server error
503 Service UnavailableServer is draining for deployment; retry after Retry-After seconds

Note: The server uses 404 to mask forbidden resources (for security). If you receive 404, the resource may exist but you don't have access.

Server-Sent Events (SSE)

Several endpoints stream responses using Server-Sent Events (SSE). These are long-lived HTTP connections that push events incrementally.

Response Headers

text

Event Format

Each event has an event name and a JSON-encoded data payload:

text

SSE Event Types

Chat / Rules streaming (POST /chats/:threadId/messages, POST /rules/:threadId/messages)

EventDescription
pingKeep-alive heartbeat, sent every 9 seconds
messageAI assistant text chunk: { "content": "<text>" }
errorStream error: { "content": "<message>" }

Workflow execution streaming (POST /workflow-runs/execute/stream)

EventDescription
pingKeep-alive heartbeat, sent every 9 seconds
activity-runActivity run status update: { "content": { "workflowRunId": "...", "status": "...", ... } }
workflow-runWorkflow run status update: { "content": { "workflowRunId": "...", "status": "...", ... } }
thinkingAI thinking trace: { "content": "<thinking text>", "stepId": "...", "activityRunId": "..." }
resultFinal result when workflow completes: { "success": true, "workflowRun": { ... } }
errorExecution error: { "error": "...", "details": "..." }

Connecting to an SSE Endpoint

javascript

Handling Deployment Draining

When the server is restarting for deployment, SSE-enabled endpoints return 503 Service Unavailable before establishing the stream:

text

Form Data (Multipart)

Several endpoints accept multipart/form-data requests, especially those involving file uploads or AI message sending.

Encoding Complex Fields

JSON objects and arrays within form data are JSON-encoded strings:

javascript

IDs and UUIDs

All public resource IDs use UUIDv7 format (time-sortable), e.g.:
018f4e3a-1234-7abc-8def-0123456789ab

Internal IDs (bigint) are never exposed in API responses.

Timestamps

All timestamps are returned as ISO 8601 strings:
"2024-01-15T10:30:00.000Z"

List endpoints that support search perform case-insensitive substring matching on the resource name field.

api-docs/common-patterns