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.
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.
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.