---
title: "Stream events"
description: "Follow session events over SSE and resume after a disconnect."
url: "https://www.thecompany.company/docs/api/streaming"
---

# Stream events

> Follow session events over SSE and resume after a disconnect.

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 [#open-a-stream]

Set `API_BASE`, `TCC_ACCESS_TOKEN`, and `SESSION_ID` as in the [quickstart](/docs/api/quickstart). Streaming requires `sessions:read` and read access to the session.

```bash
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"
```

| Frame | How to handle it |
| --- | --- |
| `message` | Parse the event in `data`. Save its SSE `id` when present so you can resume. |
| `ping` | Treat it as a heartbeat, not a transcript event. |
| `live` | The backfill is finished. Its data carries the durable head ID. |

## Resume or skip history [#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.

```bash
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 [#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](/docs/api/common-flows#create-and-address-a-side-chat-thread).
- 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](/docs/api/rate-limits#handle-a-429) before opening another stream.
