API reference

Work messages and decisions

Follow a Work as it works and talk with it: read its log (or keep a live stream open beside it), send it a message now, interrupt its current loop, queue messages for when it finishes, hand it context (a note, a link or a file), and answer the decisions it waits for - its questions, the approvals of a tool call, and its plan. 10 endpoints. Add your API key in the authentication panel to send test requests from this page.

Hand a Work context

POST/api/external/v1/works/{workId}/context

Gives the Work something to take into account, as the Work Center's attach does: kept as one of its files (shared with its sub-Works), announced in its log, and a waiting or sleeping Work wakes for it.

As JSON: note (what it is or what to do with it) and/or url (an http or https link it is told about, with fileName and mimeType to describe it; a link into this platform's upload store is refused - send the file itself). As multipart/form-data: file (stored as your own upload, with the app's size and type limits) and an optional note.

Answers 201 with the file as the Work's files list it.

Errors: 400 MISSING_FIELD, 400 INVALID_URL, 404 WORK_NOT_FOUND, 413 (the file is too large), 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired
  • notestringquery

Request body application/json

  • notestring
  • urlstring
  • fileNamestring
  • mimeTypestring

Responses

  • 200OK

Answer a Work's decision

POST/api/external/v1/works/{workId}/decisions/{eventId}/respond

Answers the decision the Work waits for (its log row of kind INPUT_REQUESTED, NODE_INPUT_REQUESTED, APPROVAL_REQUESTED or PLAN_APPROVAL_REQUESTED, by its id), as the Work Center's decision panel does; the Work goes on with it (queued again, or held SCHEDULED while all your Work slots are in use).

Body:

  • response (required): for APPROVAL_REQUESTED, APPROVE (as the request asks), APPROVE_ONCE (this call only), APPROVE_RUN (for the rest of this Work) or REJECT - an approval of access to a Space is recorded as yours; for PLAN_APPROVAL_REQUESTED, APPROVE (the plan becomes the Work's plan) or REJECT; for a question, your answer in words or the label of one of its payload.choices;
  • note: a line that goes to the Work with an approval.

Only the decision the Work waits for now can be answered, and only when it is yours to take: a Work whose decisions a supervisor agent or another designated approver takes is answered by them. A task the Work assigned (AGENT_TASK_ASSIGNED) is completed by its assignee, not here. Answers 200 with the Work.

Errors: 400 MISSING_FIELD, 400 INVALID_RESPONSE, 404 WORK_NOT_FOUND, 404 DECISION_NOT_FOUND (no decision of this Work has that id), 409 DECISION_NOT_OPEN (answered already, or the Work moved on), 409 NOT_YOURS_TO_DECIDE, 409 WORK_BUSY, 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired
  • eventIdinteger (int64)pathRequired

Request body application/json

object

Responses

  • 200OK

Read a Work's log

GET/api/external/v1/works/{workId}/events

What the Work did and was told, oldest first, as the Work viewer shows it: its messages and progress notes, the tools it called and what came back, its plan, its questions and approvals and the answers, status changes, files it produced, messages from channels it joined. Each row: id (increasing), workRunId, channel, eventKind, payload (its content, by kind), authorType (WORK or HUMAN), createdAt. The model's own internal turns are left out.

A decision the Work waits for is a row of kind INPUT_REQUESTED, NODE_INPUT_REQUESTED, APPROVAL_REQUESTED (payload.toolName, payload.args; payload.access when it asks for access to a Space) or PLAN_APPROVAL_REQUESTED (payload.phases); answer it with /decisions/{eventId}/respond.

Page with since: pass the previous page's next; poll with the last next to follow a running Work (or open /events/stream to know when to). hasMore is true when the page was full. channel: the Work's own log (default), ALL_SUBSCRIBED (its own and every channel it joined), or one channel it joined.

Errors: 404 WORK_NOT_FOUND, 404 CHANNEL_NOT_FOUND (it did not join that channel), 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired
  • sinceinteger (int64)query

    Only rows after this id (the previous page's `next`).

  • channelstringquery

    ALL_SUBSCRIBED, or a channel the Work joined; its own log when left out.

  • limitinteger (int32)query

    Rows read per page, 1 to 100 (50 by default).

Responses

  • 200OK

Follow a Work live

GET/api/external/v1/works/{workId}/events/stream

A server-sent event stream beside the log, as the Work viewer keeps one open. It carries no content of its own: ready when it is open, nudge ({cursor}: there are rows past it - read them with /events?since=), signal (throwaway progress, e.g. the model is thinking or a tool started) and, only with deltas=true, delta/delta_end (text being written, replaced by the real row moments later). Comment lines keep it alive. A client that never connects sees the same by polling /events.

The stream closes after 30 minutes; open it again with the last cursor you read. At most 5 streams per account are open at a time on one server.

Errors: 404 WORK_NOT_FOUND, 429 TOO_MANY_STREAMS, 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired
  • deltasbooleanquery

    true: also the text being written, as it is written.

Responses

  • 200OK

Interrupt a Work with a message

POST/api/external/v1/works/{workId}/interrupt

Stops the Work's current loop and has it read the message before it does anything else, as the Work Center's Interrupt does: a running or queued Work is halted (keeping its slot) and resumed with the message; a waiting one takes it as a normal message; an ended one reopens. Body: message (required). Answers 200 with the Work.

Errors: 400 MISSING_FIELD, 400 BLOCKED_CONTENT, 404 WORK_NOT_FOUND, 409 WORK_BUSY, 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired

Request body application/json

object

Responses

  • 200OK

Queue a message for after the loop

POST/api/external/v1/works/{workId}/queue-message

Keeps a message until the Work's current loop ends, then delivers it (reopening the Work with it), as the Work Center's Queue does. Several queue up in order; they are the Work's queuedMessages. Body: message (required). Answers 200 with the Work.

Errors: 400 MISSING_FIELD, 400 BLOCKED_CONTENT, 404 WORK_NOT_FOUND, 409 WORK_BUSY, 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired

Request body application/json

object

Responses

  • 200OK

Change a queued message

PUT/api/external/v1/works/{workId}/queue-message/{index}

Rewrites a message still waiting in the Work's queue. index: its place in queuedMessages (from 0). Body: message (the new words, required) and expected (the message as you read it at that place, required: the queue moves up when its first message is delivered, so an index alone could name another). Answers 200 with the Work.

Errors: 400 MISSING_FIELD, 400 BLOCKED_CONTENT, 404 WORK_NOT_FOUND, 409 QUEUE_CHANGED (that message is no longer there), 409 WORK_BUSY, 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired
  • indexinteger (int32)pathRequired

Request body application/json

object

Responses

  • 200OK

Take a queued message back

DELETE/api/external/v1/works/{workId}/queue-message/{index}

Removes a message still waiting in the Work's queue. index: its place in queuedMessages (from 0); expected (query parameter or body): the message as you read it there - when it no longer is, nothing is removed and 409 answers. Without expected, the message at that place is removed, and a place past the end removes nothing. Answers 204.

Errors: 404 WORK_NOT_FOUND, 409 QUEUE_CHANGED, 409 WORK_BUSY, 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired
  • indexinteger (int32)pathRequired
  • expectedstringquery

    The message as you read it at that place.

Request body application/json

object

Responses

  • 200OK

Send a queued message now

POST/api/external/v1/works/{workId}/queue-message/{index}/send-now

Takes a message out of the queue and sends it as an ordinary message, read at the Work's next step instead of after its loop, as the Work Center's Send now does. Body: expected (the message as you read it at that place, required). Answers 200 with the Work.

Errors: 400 MISSING_FIELD, 404 WORK_NOT_FOUND, 409 QUEUE_CHANGED, 409 WORK_BUSY, 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired
  • indexinteger (int32)pathRequired

Request body application/json

object

Responses

  • 200OK

Send a Work a message

POST/api/external/v1/works/{workId}/steering

A message to the Work, read at its next step, as typing in the Work Center's chat does: a waiting or sleeping Work wakes for it (the first message of a flow that waits for one is its prompt, and names it), and an ended Work reopens to go on with it. Body: message (required). Answers 200 with the Work.

Errors: 400 MISSING_FIELD, 400 BLOCKED_CONTENT, 404 WORK_NOT_FOUND, 409 WORK_BUSY (its own step saved it first: send again), 403 FEATURE_NOT_ENABLED.

Parameters

  • workIdstring (uuid)pathRequired

Request body application/json

object

Responses

  • 200OK