Stream events

Use server-sent events (SSE) to follow Co’s work without polling. The session stream returns 200 OK with Content-Type: text/event-stream. With curl, use -N to disable output buffering.

Open a stream

Set API_BASE, TCC_ACCESS_TOKEN, and SESSION_ID as in the quickstart. Streaming requires sessions:read and read access to the session.

curl --fail-with-body --silent --show-error -N \
  -H "Authorization: Bearer $TCC_ACCESS_TOKEN" \
  -H 'Accept: text/event-stream' \
  "$API_BASE/sessions/$SESSION_ID/events/stream"
FrameHow to handle it
messageParse the event in data. Save its SSE id when present so you can resume.
pingTreat it as a heartbeat, not a transcript event.
liveThe backfill is finished. Its data carries the durable head ID.

Resume or skip history

Set after to a numeric cursor to replay events strictly after it. If you also send Last-Event-ID, the header takes precedence.

curl --fail-with-body --silent --show-error -N \
  -H "Authorization: Bearer $TCC_ACCESS_TOKEN" \
  -H 'Accept: text/event-stream' \
  -H "Last-Event-ID: $LAST_EVENT_ID" \
  "$API_BASE/sessions/$SESSION_ID/events/stream"

To skip replay and start at the live head, use ?from=live. It overrides both resume cursors, except with deltas=true, which opens by cursor and needs the replay. Use types for a comma-separated filter of up to 64 payload types, such as message.created,session.status.

Good to know

  • Transient deltas are off by default. Set deltas=true to see incremental text, reasoning, and tool input. Use durable events to restore state after a disconnect, not transient deltas.
  • The SSE endpoint has no threadId query filter: it follows the session across threads. Filter received events by their threadId in your client, or use GET /v1/sessions/{id}/events?threadId=... for a thread-filtered durable read as in the thread flow.
  • A connection can fail after the HTTP response starts. Handle the SSE failure event effect/http-api/stream/failure as well as HTTP errors on the initial request.
  • If a connection attempt returns 429, wait for the retry delay before opening another stream.