Chats

Documentation for Chats

Base path: /api/v1/chats

Chat threads are the primary interaction surface for AI-powered workflow authoring and execution. Each thread contains a conversation history and is optionally linked to a workflow draft or a decision rule draft.

All endpoints require JWT authentication (Authorization: Bearer <token> or Cookie: token=<jwt>) and an x-active-org header.


Endpoints Overview

MethodPathDescription
POST/api/v1/chatsCreate a new empty chat thread
POST/api/v1/chats/from-workflowCreate a thread linked to a workflow version
GET/api/v1/chatsList chat threads (paginated)
GET/api/v1/chats/:threadId/messagesGet messages in a thread
POST/api/v1/chats/:threadId/messagesSend a message (SSE stream response)
DELETE/api/v1/chats/:threadIdDelete a thread
PATCH/api/v1/chats/:threadId/sharingUpdate team sharing
PATCH/api/v1/chats/:threadId/titleGenerate and set thread title

POST /api/v1/chats

Creates a new empty chat thread.

Request

No request body required.

Response 200 OK

json
FieldTypeDescription
threadIdstring (UUID)The newly created thread's ID

Example

bash

POST /api/v1/chats/from-workflow

Creates a new chat thread linked to a specific workflow version. The specified version is copied into a draft for editing within the thread.

Request Body (JSON)

FieldTypeRequiredDescription
workflowPublicIdstring (UUID)YesID of the workflow to link
versionPublicIdstring (UUID)NoSpecific version ID; uses default version if omitted
titlestringNoCustom title for the thread
json

Response 201 Created

json
FieldTypeDescription
threadIdstring (UUID)New thread ID
workflowPublicIdstring (UUID)The linked workflow ID
draftPublicIdstring (UUID)The new workflow draft created for this thread
visibilitystringAlways "owner" on creation

Errors

StatusReason
403 ForbiddenInsufficient access to the workflow
404 Not FoundWorkflow or version not found

GET /api/v1/chats

Lists chat threads for the authenticated user, newest first.

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page

Response 200 OK

json

Thread object fields:

FieldTypeDescription
idstring (UUID)Thread ID
titlestring | nullThread title
descriptionstring | nullThread description
workflowIdstring (UUID) | nullAssociated workflow ID (if workflow thread)
ruleobject | nullAssociated rule info (if rules thread): { id, name, description }
lastUpdatedAtstring (ISO 8601)Last activity timestamp
sharedTeamKeysstring[]Teams this thread is shared with

Note: Threads shared with teams outside the user's membership are filtered out automatically.


GET /api/v1/chats/:threadId/messages

Retrieves messages in a thread along with the associated workflow/rule context.

Path Parameters

ParameterTypeDescription
threadIdstring (UUID)Thread ID

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page

Response 200 OK

json

Message object fields:

FieldTypeDescription
idstring (UUID)Message ID
role"user" | "assistant"Message author
typestringMessage type (currently "text")
contentstringMessage text content
createdAtstring (ISO 8601)Creation timestamp

Response top-level fields:

FieldTypeDescription
messagesarrayPaginated list of messages
workflowobject | nullCurrent workflow definition in planner format (if workflow thread)
workflowPublicIdstring (UUID) | nullID of linked workflow
ruleobject | nullRule info { id, name, description } (if rules thread)
rulePublicIdstring (UUID) | nullID of linked rule

POST /api/v1/chats/:threadId/messages

Sends a message to the AI assistant in a thread and streams the response via SSE.

Path Parameters

ParameterTypeDescription
threadIdstring (UUID)Thread ID

Request Body (multipart/form-data)

FieldTypeRequiredDefaultDescription
messagestringYes–The user's message text
isInterruptbooleanNofalseWhether this is a response to an interrupt (AI is awaiting user input)
interruptTypestringNo"workflow-inputs"Type of interrupt: "workflow-inputs" or "subworkflow-select"
inputsJSON objectNo{}Input values when responding to a workflow-inputs interrupt
envsJSON objectNo{}Environment variable overrides (string-to-string map)
selectedWorkflowIdstringNo–Required when interruptType is "subworkflow-select"
attachmentsFile[]No[]File attachments (images, documents)
modelstringNo"GPT-4o"AI model to use (see available models below)

Available models: GPT-4o, GPT-4o-mini, Claude-3-5-Sonnet, Claude-3-5-Haiku, Gemini-2.0-Flash, Gemini-2.5-Pro, DeepSeek-R1, o3-mini, o4-mini

Response

Returns an SSE stream (Content-Type: text/event-stream).

SSE Events:

EventDataDescription
ping{ "content": "ping" }Keep-alive, sent every 9 seconds
message{ "content": "<text>" }AI response text
error{ "content": "<message>" }Error during streaming

Example (JavaScript)

javascript

Handling Interrupts

The AI may pause and request user input (an interrupt). When this happens, the SSE stream will emit a message indicating the interrupt type. Resume by sending another message with isInterrupt: true:

javascript

DELETE /api/v1/chats/:threadId

Soft-deletes a thread and all its messages.

Path Parameters

ParameterTypeDescription
threadIdstring (UUID)Thread ID

Response 200 OK

json

PATCH /api/v1/chats/:threadId/sharing

Updates the team access list for a thread. Replaces the existing sharing configuration (not a merge).

Path Parameters

ParameterTypeDescription
threadIdstring (UUID)Thread ID

Request Body (JSON)

FieldTypeRequiredDefaultDescription
shareWithTeamKeysstring[]Yes[]List of team keys to share with. Pass [] to make owner-only.
json

Response 200 OK

Returns the updated sharing result object.


PATCH /api/v1/chats/:threadId/title

Generates an AI-powered title for the thread based on the provided conversation messages, then saves it.

Path Parameters

ParameterTypeDescription
threadIdstring (UUID)Thread ID

Request Body (JSON)

An array of conversation messages (1–20 messages):

json

Message object:

FieldTypeRequiredDescription
role"user" | "assistant"YesMessage role
contentarrayYesArray of content parts: [{ "type": "text", "text": "..." }]

Constraints: minimum 1 message, maximum 20 messages.

Response 200 OK

json
api-docs/chats