Skip to main content

Tasks

Tasks (conversations in the API): create one, send messages, read and stream its events, stop a run, and choose its model route and environment.

OperationMethod and path
List owned conversations or administrator metadataGET /api/v1/conversations
Create an owned conversationPOST /api/v1/conversations
Read permitted conversation metadataGET /api/v1/conversations/{id}
Rename a conversation or choose the route for its next runPATCH /api/v1/conversations/{id}
Delete a task: gone at once, its data purged within minutesDELETE /api/v1/conversations/{id}
Read a page or replay and stream durable eventsGET /api/v1/conversations/{id}/events
Submit a user messagePOST /api/v1/conversations/{id}/messages
The messages that waited behind the task's run, or still wait for a slotGET /api/v1/conversations/{id}/messages/queued
Cancel a held message or one waiting for a slot, or dismiss a dropped oneDELETE /api/v1/conversations/{id}/messages/queued/{message_id}
Request run cancellationPOST /api/v1/conversations/{id}/runs/{run_id}/cancel
List model routes available for conversation creationGET /api/v1/models
List environment templates available to the authenticated userGET /api/v1/templates
Choose the environment for the next runPUT /api/v1/conversations/{id}/environment
A task's key usesGET /api/v1/conversations/{id}/key-uses

List owned conversations or administrator metadata​

GET /api/v1/conversations

Most recently active first (last_activity_at, then id, descending). A task that gains activity while you page moves to the top, so a later page may repeat or skip it; clients de-duplicate by id. q searches the caller's own titles only, case-insensitively and as literal text (% and _ are not wildcards), even with all=true; trimmed, at most 100 characters, else 400 value_too_long. Each item carries run_status.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
allqueryboolean
cursorquerystringThe next_cursor of the previous page; opaque. A cursor this gateway did not issue is 400 with details reason cursor_invalid.
limitqueryinteger 1–1000
qquerystringSearch text in your own titles; empty is no search.
scopequery"top"top leaves agent-team members out (their lead carries them). Ignored with q, and filters nothing while agent teams are off.

Responses

StatusMeaningBody
200Successful operationConversationPage
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Create an owned conversation​

POST /api/v1/conversations

Idempotency-Key is required and scoped to the authenticated user. The canonical request body is fingerprinted. A replay returns the original 201 response and conversation id without repeating side effects; a changed body returns 422 idempotency_key_reused and a key used on another route returns 409 idempotency_route. The conversation and key record commit atomically. Records expire after the configured idempotency retention (24 hours by default). The title given here counts as the first message's (title_source message): after the task's first completed run the gateway may replace it with a 3-6 word name, unless [tasks] auto_title is off; a later PATCH of the title is never replaced. The title given at creation is provisional: the automatic title replaces it after the first run; a rename with PATCH holds.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.
Sec-Fetch-Siteheader"same-origin"
Idempotency-KeyheaderyesstringASCII graphic characters. Scoped to the authenticated user and exact action route.

Request body

application/json: CreateConversation

Responses

StatusMeaningBody
201Successful operationConversation
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversation; template_unavailable: the template exists but is not offered now (disabled, not yet verified, or refused by a check); profile_unusable: the profile names a route, template, server or connector the install lacks, disables or does not offer (details name the field)Error
413Request body limit exceededError
422Idempotency key reused with a different canonical body; unknown_template: no such template; unknown_reference (profile): no profile the caller can see; set_by_profile: the request names another route or template than its profile setsError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Read permitted conversation metadata​

GET /api/v1/conversations/{id}

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)

Responses

StatusMeaningBody
200Successful operationConversation
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Rename a conversation or choose the route for its next run​

PATCH /api/v1/conversations/{id}

Owner only. At least one of pinned, title (1-200 characters, trimmed; it sets title_source to person, so the gateway never renames the task) and route (a route the user may use, as at creation). A route change while a run is active is refused with 409 run_active and nothing changes; a rename is always allowed. When a runtime link is live it receives the link-only session.update with the new route snapshot, and the relay then accepts only the stored route. Idempotency-Key is required; a replay returns the first response.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.
Sec-Fetch-Siteheader"same-origin"
Idempotency-KeyheaderyesstringASCII graphic characters. Scoped to the authenticated user and exact action route.

Request body

application/json: PatchConversation

Responses

StatusMeaningBody
200Successful operationConversation
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409run_active (a route change during an active run; nothing changes), idempotency route conflict or deleted conversationError
413Request body limit exceededError
422Idempotency key reused with a different canonical body; set_by_profile: a server or connector outside the profile's set, or another route than the profile'sError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Delete a task: gone at once, its data purged within minutes​

DELETE /api/v1/conversations/{id}

Owner only. The task answers 404 to every read, stream, files call and action from the delete on, and an open event stream ends; its runtime token is revoked and one content-free audit record is written. Its events, stored outputs, held messages and run snapshots are purged in the background within minutes; its workspace and files stay, and its usage still counts for its owner. Deleting a task already deleted answers 204 again and records nothing, until it is purged; then 404. A create retried with the same Idempotency-Key after the task is purged makes a new task.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.
Sec-Fetch-Siteheader"same-origin"
with_helpersquerybooleanDeleting a lead with helpers (member tasks not deleted, in any team state) deletes them and their own copies too; without it the delete is 409 has_helpers.

Responses

StatusMeaningBody
204Successful operation
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversation; has_helpers (no details: the page reads the helpers from the team) for a lead with helpers without with_helpers=trueError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Read a page or replay and stream durable events​

GET /api/v1/conversations/{id}/events

With stream=1&protocol=1, omit limit. The optional after cursor is used only when Last-Event-ID is absent; the header takes precedence on native reconnect. Subscribe before taking the durable watermark, replay through it, then drain live frames while discarding only the replay overlap. session.ready and unsequenced errors are ephemeral. Lag closes with seq_gap. Foreign origins are rejected.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
afterqueryinteger 0 or moreExclusive sequence cursor. On streams, used only when Last-Event-ID is absent; duplicates and non-decimal values are invalid.
limitqueryinteger 1–1000Paged reads only; rejected when stream=1.
streamquery0, 1
protocolqueryintegerRequired for stream=1; supported value is 1.
Last-Event-IDheaderstringExclusive replay cursor; must fit signed bigint. Takes precedence over the after query cursor.
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.

Responses

StatusMeaningBody
200Successful operationEventPage; string (text/event-stream)
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Submit a user message​

POST /api/v1/conversations/{id}/messages

Only accepted actions are cached. The canonical request body must match for key replay; a changed body returns 422 idempotency_key_reused. Default retention is 24 hours from acceptance; queued actions remain until delivered or failed. Acceptance persists the queued frame before 202. Replay preserves the original response body; the execution header reports its current status. A new attempt requires a new key. When no slot is free the message is still accepted (202) and waits in a queue that is fair across users; the stream reports session.ready with state queued and queue.ahead until it starts. queue.reason says why: slot (no free sandbox slot) or workspace (another task holds the workspace write lease; with busy_policy = wait it starts when that task's run ends). 429 remains only for the per-conversation action queue bound. A message sent while the task's run is in progress waits on the gateway (held: true) and goes out when the run ends; every message held meanwhile goes out as one user turn, texts joined in order with a blank line. A run that fails or is stopped drops them (see /messages/queued).

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.
Sec-Fetch-Siteheader"same-origin"
Idempotency-KeyheaderyesstringASCII graphic characters. Scoped to the authenticated user and exact action route.

Request body

application/json: Message

Responses

StatusMeaningBody
202Durably accepted; execution status is separate from the immutable response bodyMessageAccepted
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict, deleted conversation, workspace_not_ready (the workspace is still forking or failed), workspace_quota (the workspace is over its quota), or workspace_busy (busy_policy = refuse and another task is running on the same workspace; nothing is queued), or decision_engine_unavailable (the conversation's profile names a decision engine the install no longer has or has disabled)Error
413Request body limit exceededError
422Idempotency key reused with a different canonical bodyError
429The conversation's pending-action bound is reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

The messages that waited behind the task's run, or still wait for a slot​

GET /api/v1/conversations/{id}/messages/queued

Oldest first: held (still waiting), dropped (the run failed or was stopped, or the task's environment never started for the message; reason) and sent (sent_at), the last two for the idempotency retention. Readers of the task. Clients learn of each change through the unsequenced message.queue stream frame, a failed start's drop included.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)

Responses

StatusMeaningBody
200Successful operationQueuedMessages
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Cancel a held message or one waiting for a slot, or dismiss a dropped one​

DELETE /api/v1/conversations/{id}/messages/queued/{message_id}

Cancels a held message or one waiting for a slot, or dismisses a dropped one (a run's drop or a failed start's). Only the message's author or the task's owner; 409 message_sent once it went out; 409 team_turn for an agent team's wake (team_wake) or a member's first turn (lead_brief), which no one may cancel.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
message_idpathyesstring
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.
Sec-Fetch-Siteheader"same-origin"

Responses

StatusMeaningBody
204Successful operation
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Request run cancellation​

POST /api/v1/conversations/{id}/runs/{run_id}/cancel

Only accepted actions are cached. The canonical request body must match for key replay; a changed body returns 422 idempotency_key_reused. Default retention is 24 hours from acceptance; queued actions remain until delivered or failed. Acceptance persists the queued frame before 202. Replay preserves the original response body; the execution header reports its current status. A new attempt requires a new key.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
run_idpathyesstring
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.
Sec-Fetch-Siteheader"same-origin"
Idempotency-KeyheaderyesstringASCII graphic characters. Scoped to the authenticated user and exact action route.

Request body

application/json: Cancel

Responses

StatusMeaningBody
202Durably accepted; execution status is separate from the immutable response bodyAccepted
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
422Idempotency key reused with a different canonical bodyError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

List model routes available for conversation creation​

GET /api/v1/models

Every authenticated user may create a conversation with any registered route. Only public capabilities are returned, sorted by route name.

Sign-in: A signed-in session or an API token.

Responses

StatusMeaningBody
200Successful operationModels
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

List environment templates available to the authenticated user​

GET /api/v1/templates

Ordered by default first, then display name. Image references and digests are not returned.

Sign-in: A signed-in session or an API token.

Responses

StatusMeaningBody
200Successful operationTemplates
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409Bootstrap closed, idempotency route conflict or deleted conversationError
413Request body limit exceededError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

Choose the environment for the next run​

PUT /api/v1/conversations/{id}/environment

Owner only. Stores the selected template and retires the previous sandbox asynchronously. Files and history stay; running processes stop. Same template is a successful no-op. While a run is active returns run_active; an unknown template returns unknown_template, and one that is not offered now returns template_unavailable. The runtime emits environment.changed at the next start. Idempotency-Key is required.

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
OriginheaderstringMust equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted.
Sec-Fetch-Siteheader"same-origin"
Idempotency-KeyheaderyesstringASCII graphic characters. Scoped to the authenticated user and exact action route.

Request body

application/json: ChangeEnvironment

Responses

StatusMeaningBody
200Successful operationConversation
400Invalid request or unsupported protocolError
401Authentication requiredError
403Origin, ownership or role deniedError
404Record not foundError
409run_active: an active run prevents switching; template_unavailable: the template exists but is not offered now (disabled, not yet verified, or refused by a check); no change is appliedError
413Request body limit exceededError
422unknown_template: unknown or disallowed template; no change is applied; set_by_profile: the conversation's profile sets another templateError
429Rate or capacity limit reachedError
503Database unavailable or gateway restartingError
504I/O deadline exceededError

A task's key uses​

GET /api/v1/conversations/{id}/key-uses

The task's keyed calls by run, newest first: each row is one run's uses of one key at one address with one outcome, counted. The key's name only when you are the row's sender (null for anyone else, administrators included). Never a value or a placeholder. Readable by whoever may read the task's events (ADR-0037 §2).

Sign-in: A signed-in session or an API token.

Parameters

NameInRequiredTypeDescription
idpathyesstring (uuid)
limitqueryinteger 1–100
beforequerystring (uuid)

Responses

StatusMeaningBody
200Key uses, newest firstTaskKeyUses
400Invalid pagingError
401Authentication requiredError
403Ownership or role denied: another member's task, as its events answerError
404Record not found: no such taskError