Send Message (Assist Mode)
POST /api/v1/managed-agents/sessions/{sessionId}/messages
Sends a user message into the session and streams the agent’s reply back as Server-Sent Events.
Override the model configured on the agent for this turn only.
Response
Content-Type: text/event-stream
Cache-Control: no-cache
Connection: keep-alive
The stream carries a sequence of JSON events covering turn-run state changes, incremental text/token chunks, and tool calls made by the agent as it works.
const response = await fetch(
`https://suite.sundaypyjamas.com/api/v1/managed-agents/sessions/${sessionId}/messages`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: 'What did you find in the report?' }),
}
);
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
console.log(decoder.decode(value));
}
Returns 400 with "message is required" if message is missing. Returns 429 if the workspace has hit its managed-agent rate limit.
Get Session Timeline
GET /api/v1/managed-agents/sessions/{sessionId}/events
Returns the full ordered history of a session — messages and turn runs interleaved, sorted ascending by created_at.
events
(MessageEvent | TurnRunEvent)[]
POST /api/v1/managed-agents/sessions/{sessionId}/tool-results
When an agent needs to call a tool your integration owns, it pauses and emits a pending tool call in the event stream. Execute the tool on your side, then report the result back here so the agent can continue.
The ID of the pending tool call, taken from the event stream.
The tool’s return value. Provide this on success.
Error message if the tool failed. Provide either result or error, not both.
curl -X POST https://suite.sundaypyjamas.com/api/v1/managed-agents/sessions/sess_44bc.../tool-results \
-H "Authorization: Bearer spj_ai_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{ "toolCallId": "tc_991a...", "result": { "status": "ok", "rows": 12 } }'
{
"accepted": true,
"sessionId": "sess_44bc...",
"toolCallId": "tc_991a...",
"status": "completed"
}
Returns 403 with "toolCallId does not belong to session" if the tool call belongs to a different session, and 404 with "Unknown toolCallId" if it doesn’t exist.
Cancel Run
POST /api/v1/managed-agents/sessions/{sessionId}/cancel
{
"runId": "run_8a21...",
"status": "cancelled"
}
Returns 400 with "Run is {current_status}" if the run isn’t currently running (e.g. already completed).