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.
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
all | query | boolean | ||
cursor | query | string | The next_cursor of the previous page; opaque. A cursor this gateway did not issue is 400 with details reason cursor_invalid. | |
limit | query | integer 1–1000 | ||
q | query | string | Search text in your own titles; empty is no search. | |
scope | query | "top" | top leaves agent-team members out (their lead carries them). Ignored with q, and filters nothing while agent teams are off. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | ConversationPage |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. | |
Sec-Fetch-Site | header | "same-origin" | ||
Idempotency-Key | header | yes | string | ASCII graphic characters. Scoped to the authenticated user and exact action route. |
Request body
application/json: CreateConversation
Responses
| Status | Meaning | Body |
|---|---|---|
| 201 | Successful operation | Conversation |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap 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 |
| 413 | Request body limit exceeded | Error |
| 422 | Idempotency 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 sets | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
Read permitted conversation metadata
GET /api/v1/conversations/{id}
Sign-in: A signed-in session or an API token.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | Conversation |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. | |
Sec-Fetch-Site | header | "same-origin" | ||
Idempotency-Key | header | yes | string | ASCII graphic characters. Scoped to the authenticated user and exact action route. |
Request body
application/json: PatchConversation
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | Conversation |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | run_active (a route change during an active run; nothing changes), idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 422 | Idempotency 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's | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. | |
Sec-Fetch-Site | header | "same-origin" | ||
with_helpers | query | boolean | Deleting 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
| Status | Meaning | Body |
|---|---|---|
| 204 | Successful operation | |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap 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=true | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
after | query | integer 0 or more | Exclusive sequence cursor. On streams, used only when Last-Event-ID is absent; duplicates and non-decimal values are invalid. | |
limit | query | integer 1–1000 | Paged reads only; rejected when stream=1. | |
stream | query | 0, 1 | ||
protocol | query | integer | Required for stream=1; supported value is 1. | |
Last-Event-ID | header | string | Exclusive replay cursor; must fit signed bigint. Takes precedence over the after query cursor. | |
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | EventPage; string (text/event-stream) |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. | |
Sec-Fetch-Site | header | "same-origin" | ||
Idempotency-Key | header | yes | string | ASCII graphic characters. Scoped to the authenticated user and exact action route. |
Request body
application/json: Message
Responses
| Status | Meaning | Body |
|---|---|---|
| 202 | Durably accepted; execution status is separate from the immutable response body | MessageAccepted |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap 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 |
| 413 | Request body limit exceeded | Error |
| 422 | Idempotency key reused with a different canonical body | Error |
| 429 | The conversation's pending-action bound is reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | QueuedMessages |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
message_id | path | yes | string | |
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. | |
Sec-Fetch-Site | header | "same-origin" |
Responses
| Status | Meaning | Body |
|---|---|---|
| 204 | Successful operation | |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
run_id | path | yes | string | |
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. | |
Sec-Fetch-Site | header | "same-origin" | ||
Idempotency-Key | header | yes | string | ASCII graphic characters. Scoped to the authenticated user and exact action route. |
Request body
application/json: Cancel
Responses
| Status | Meaning | Body |
|---|---|---|
| 202 | Durably accepted; execution status is separate from the immutable response body | Accepted |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 422 | Idempotency key reused with a different canonical body | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | Models |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | Templates |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | Bootstrap closed, idempotency route conflict or deleted conversation | Error |
| 413 | Request body limit exceeded | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
Origin | header | string | Must equal public_origin; when absent, Sec-Fetch-Site: same-origin is accepted. | |
Sec-Fetch-Site | header | "same-origin" | ||
Idempotency-Key | header | yes | string | ASCII graphic characters. Scoped to the authenticated user and exact action route. |
Request body
application/json: ChangeEnvironment
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Successful operation | Conversation |
| 400 | Invalid request or unsupported protocol | Error |
| 401 | Authentication required | Error |
| 403 | Origin, ownership or role denied | Error |
| 404 | Record not found | Error |
| 409 | run_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 applied | Error |
| 413 | Request body limit exceeded | Error |
| 422 | unknown_template: unknown or disallowed template; no change is applied; set_by_profile: the conversation's profile sets another template | Error |
| 429 | Rate or capacity limit reached | Error |
| 503 | Database unavailable or gateway restarting | Error |
| 504 | I/O deadline exceeded | Error |
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
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | yes | string (uuid) | |
limit | query | integer 1–100 | ||
before | query | string (uuid) |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Key uses, newest first | TaskKeyUses |
| 400 | Invalid paging | Error |
| 401 | Authentication required | Error |
| 403 | Ownership or role denied: another member's task, as its events answer | Error |
| 404 | Record not found: no such task | Error |