Skip to main content

Chat jobs

MethodPathDescription
POST/api/projects/{id}/chat-sessions/{sessionId}/jobs/chatSend a message.
GET/api/projects/{id}/chat-sessions/{sessionId}/jobs/chat/{chatJobId}Poll a job.
POST/api/projects/{id}/chat-sessions/{sessionId}/jobs/chat/{chatJobId}/cancelStop a running turn.

Send body:

FieldTypeNotes
contentstringThe message. Required unless diffCommentsContext is present.
modelstringOptional override for this turn.
previewContextobject{ frontendName, path }, pinning the message to a page in the preview.
diffCommentsContextarrayUp to 50 diff comments to hand the agent as review feedback.
retryFailedJobIduuidRetry a failed job.
steerTargetJobIduuidThe run you meant to steer, so a stop that lands in the same window can be told apart from a turn that simply ended.

The response says how the message was delivered:

json
{ "data": { "delivery": "job", "chatJobId": "…", "jobNumber": 3 } }
{ "data": { "delivery": "steer", "steerId": "…" } }

Polling returns:

json
{
"data": {
"job": {
"id": "…",
"status": "running",
"jobNumber": 3,
"buildCompleted": false,
"error": null,
"errorCode": null,
"createdAt": "…",
"startedAt": "…",
"completedAt": null
}
}
}

Statuses are pending, running, awaiting_response, completed, failed, cancelled. awaiting_response means the agent asked a question and is waiting: send the answer as an ordinary message.

This endpoint needs the session's sandbox to exist, and returns 404 if it does not. A session created with a first message already has one. For any other session, ask for its preview first, which starts it.