Run (Streaming)
POST /api/v1/teams/:teamId/run-stream — execute a team and stream the response as Server-Sent Events.
Runs a team the same way as /run-sync, but streams the response as it's
generated instead of waiting for the full reply.
POST /api/v1/teams/{teamId}/run-streamPath parameters
| Parameter | Type | Description |
|---|---|---|
teamId | string (UUID) | The team to run. |
Request body
Identical to /run-sync: message (required), session_id,
user_id.
Response
200 OK, Content-Type: text/event-stream. Each event is a data: <json>\n\n line. Every event
carries a common base — event, runId, teamId, teamName, sessionId, userId, createdAt
(unix seconds) — plus event-specific fields.
Event sequence
RunStarted → ModelRequestStarted → RunContent (×N) → ModelRequestCompleted → RunContentCompleted → RunCompleted| Event | Extra fields | Description |
|---|---|---|
RunStarted | — | The run has been accepted and started. |
ModelRequestStarted | — | The lead's model call has begun. |
RunContent | content | One chunk of generated text. Emitted once per token/delta — expect many of these per run. |
ModelRequestCompleted | — | The model call finished. |
RunContentCompleted | — | All content chunks have been emitted. |
RunCompleted | content (full text), metrics | Terminal event. content is the complete reconstructed response; metrics has the same shape as /run-sync's response (inputTokens, outputTokens, latencyMs, model, failoverUsed). |
data: {"event":"RunContent","runId":"b7e1...","teamId":"3f9c...","teamName":"Support Escalation Team","sessionId":"a1c4...","userId":"d92e...","createdAt":1732550123,"content":"Hello"}
data: {"event":"RunCompleted","runId":"b7e1...","teamId":"3f9c...","teamName":"Support Escalation Team","sessionId":"a1c4...","userId":"d92e...","createdAt":1732550124,"content":"Hello! How can I help you today?","metrics":{"inputTokens":12,"outputTokens":9,"latencyMs":842,"model":null,"failoverUsed":false}}This is the same fixed 6-event public sequence the agent stream
emits — a Team's own internal events are narrower than an Agent's, and one event type has no slot
in this sequence: tool_call events are dropped. A member or lead calling a tool mid-run
doesn't produce a public event; only the run's final content and terminal outcome are streamed.
Error event
If the run fails at any point, an error event replaces the rest of the sequence — it's always
terminal, and no further events follow it:
data: {"event":"error","runId":"b7e1...","teamId":"3f9c...","teamName":"Support Escalation Team","sessionId":"a1c4...","userId":"d92e...","createdAt":1732550124,"reason":"Team runtime closed the connection before completing the run"}Disconnect and cancellation
If you close the connection (abort the fetch, close the response stream) before RunCompleted or
error arrives, Elizon detects the disconnect and cancels the in-flight run upstream — there's no
need to call the cancel endpoint separately in that case.
TypeScript example
const response = await fetch(`https://api.elizon.com/api/v1/teams/${teamId}/run-stream`, {
method: 'POST',
headers: {
'X-API-Key': 'elz_your_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: 'A customer is asking about a refund on order #4821' }),
})
const reader = response.body!.getReader()
const decoder = new TextDecoder()
let fullContent = ''
while (true) {
const { done, value } = await reader.read()
if (done) break
const chunk = decoder.decode(value, { stream: true })
for (const line of chunk.split('\n')) {
if (!line.startsWith('data: ')) continue
const event = JSON.parse(line.slice(6))
if (event.event === 'RunContent') fullContent += event.content
if (event.event === 'RunCompleted') {
console.log('Complete response:', fullContent)
console.log('Metrics:', event.metrics)
}
if (event.event === 'error') {
console.error('Run failed:', event.reason)
}
}
}Errors
Before the stream opens, the same validation and scope errors as /run-sync
apply:
| Status | error | When |
|---|---|---|
400 | validation error ({ "errors": [...] }) | message missing/empty, or another field fails validation |
403 | forbidden | The team belongs to a different project than your project-scoped key |
404 | team_not_found | No team with that ID exists in your organization |
502 | bad_gateway | The team runtime is unreachable |
Once the stream has started, failures are reported as an error event instead of an HTTP error
status — check the status code of the initial response, then watch for an error event for
anything that goes wrong mid-stream.