Send a message
POST /v1/agents/message
View as MarkdownSends a task to Sai on one computer. Returns at once with wait: false, or streams the turn with wait: true.
Request
{
"message": "Open Notepad, type hello, save it to the desktop as hello.txt",
"machineId": "m_7f2a",
"wait": false,
"attachments": [
{
"path": "uploads/report-1790000000000.pdf",
"name": "report-1790000000000.pdf",
"mime": "application/pdf",
"size": 48213,
"fileId": "f_3kd9"
}
]
}Response with wait: false
202 Accepted:
{ "sessionId": "cs_01HZY", "machineId": "m_7f2a", "queued": false }Refusals on this path are plain JSON, not stream events. A message the agent could not take (for example, the computer is unavailable) returns 409 { "error": "..." }. A message that was handled without starting a task, such as a plain acknowledgement, returns 200 { "error": "..." } with the reply text in error and no sessionId.
Response with wait: true
200 with Content-Type: text/event-stream. Each frame is data: {...} followed by a blank line; the stream ends with data: [DONE].
data: {"type":"start","messageId":"msg_1"}
data: {"type":"data-session","data":{"sessionId":"cs_01HZY"}}
data: {"type":"text-start","id":"t_1"}
data: {"type":"text-delta","id":"t_1","delta":"Opening Notepad."}
data: {"type":"data-approval-request","data":{"approvalId":"ap_7Qw","title":"Command Approval Required","description":"","approvalType":"exec","isLinkOnly":false,"approvalUrl":"https://sai.simular.ai/approval/3fA9kQ2xYz/ap_7Qw?from=api","command":"notepad.exe"}}
data: {"type":"text-end","id":"t_1"}
data: {"type":"finish","finishReason":"stop"}
data: [DONE]The stream stays open while an approval is pending. Answer it with /approve from another connection. The full frame list is on the Events page.
Errors
When machineId is omitted and several computers qualify, the 400 lists them:
{
"error": "Several computers are linked to this account. Pass machineId. See GET /v1/agents/machines.",
"machines": [
{ "machineId": "m_7f2a", "name": "Work Desktop" },
{ "machineId": "m_9c1e", "name": "Sai cloud computer" }
]
}name is absent for a computer without one. A paid account with no computer at all gets a 400 asking you to create one in the Sai app or the portal.
Gotchas
- Attachments need a
fileId. Upload first; do not build attachment objects by hand. - The default is
wait: true. A coding agent or a script should sendwait: falseexplicitly. - On a free account the first request of the day starts the computer. Expect about two minutes before the first event.
Note
wait: falseand optionalmachineIdare available from October 1. Today's staging streams every message and requiresmachineId.