API reference
Abort
POST /v1/agents/abort
Stops a running task. Safe to call when nothing is running. A turn stopped before it answered ends failed with reason_code: aborted.
Request
Recommended for API callers: name the session you started.
Stop a session's task
curl -s "$SAI_API_URL/v1/agents/abort" \
-H "Authorization: Bearer $SAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "sessionId": "cs_01HZY" }'Or name the computer and the channel:
Stop the running task on a computercURL
curl -s "$SAI_API_URL/v1/agents/abort" \
-H "Authorization: Bearer $SAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machineId": "m_7f2a",
"channel": "api"
}'Response
A task was stopped:
200 OK · Task stoppedJSON
{ "ok": true, "aborted": true }Nothing to stop:
200 OK · Nothing to stopJSON
{ "ok": true, "aborted": false, "reason": "session already idle or aborting" }reason is no active session or session already idle or aborting.
Errors
Gotchas
- Use
sessionId. It needs no machine lookup, so it also works on a free account's computer between claims. - With
machineIdand nochannel, an API key or a Tenant token stops its ownapiconversation. ThesaiCLI sendschannel: "cli". - Pending approvals on the aborted task are resolved as denied, so nothing is left waiting.