---
title: "Stream session events"
description: "Backfills durable events after the cursor, emits a one-shot `live` frame at the end of backfill, then tails live events. `from=live` skips the backfill and opens at the head, which the `live` frame reports. Durable frames carry the event id as the SSE id for `Last-Event-ID` resume; `ping` frames are heartbeats."
url: "https://www.thecompany.company/docs/api/sessions/stream-events"
---

# Stream session events

> Backfills durable events after the cursor, emits a one-shot `live` frame at the end of backfill, then tails live events. `from=live` skips the backfill and opens at the head, which the `live` frame reports. Durable frames carry the event id as the SSE id for `Last-Event-ID` resume; `ping` frames are heartbeats.

- **Surface:** The App API
- **Endpoint:** `GET https://api.thecompany.company/v1/sessions/{id}/events/stream`
- **Operation ID:** `sessions.streamEvents`
- **Authentication:** `Authorization: Bearer <TOKEN>`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | `path` | `string` | Yes |  |
| `last-event-id` | `header` | `string` | No |  |
| `after` | `query` | `string` | No |  |
| `types` | `query` | `string` | No |  |
| `deltas` | `query` | `string \| null` | No |  |
| `from` | `query` | `string \| null` | No |  |

## Responses

### `200` (`text/event-stream`)

Success

Schema: `object`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `$ (object).event` | `string` | Yes |  |
| `$ (object).id` | `string` | No |  |
| `$ (object).data` | `string` | Yes |  |
| `$ (object).event` | `string` | Yes |  |
| `$ (object).data` | `string` | Yes |  |
| `$ (object).event` | `string` | Yes |  |
| `$ (object).data` | `string` | Yes |  |

Example:

```text
id: 412
event: message
data: {"id":412,"type":"message.created", ...}

id: 413
event: message
data: {"id":413,"type":"session.status", ...}
```

### `401` (`application/json`)

AuthenticationError

Schema: `AuthenticationError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `reason` | `string` | Yes |  |
| `description` | `string` | No |  |

Example:

```json
{
  "_tag": "AuthenticationError",
  "reason": "invalid_session",
  "description": "string"
}
```

### `402` (`application/json`)

OrganizationUnsubscribedError

Schema: `OrganizationUnsubscribedError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `code` | `string` | Yes |  |

Example:

```json
{
  "_tag": "OrganizationUnsubscribedError",
  "code": "ORGANIZATION_UNSUBSCRIBED"
}
```

### `403` (`application/json`)

ActorUnauthorizedError | UnauthorizedError | IdentityMismatchError | RequestedOrganizationError

Schema: `ActorUnauthorizedError | UnauthorizedError | IdentityMismatchError | ...`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `$ (ActorUnauthorizedError)._tag` | `string` | Yes |  |
| `$ (UnauthorizedError)._tag` | `string` | Yes |  |
| `$ (UnauthorizedError).entity` | `string` | Yes |  |
| `$ (UnauthorizedError).action` | `string` | Yes |  |
| `$ (IdentityMismatchError)._tag` | `string` | Yes |  |
| `$ (RequestedOrganizationError)._tag` | `string` | Yes |  |
| `$ (RequestedOrganizationError).reason` | `string \| null` | Yes |  |

Example:

```json
{
  "_tag": "ActorUnauthorizedError"
}
```

### `404` (`application/json`)

SessionNotFoundError

Schema: `SessionNotFoundError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `id` | `string` | Yes | TypeID with prefix "asess_". |

Example:

```json
{
  "_tag": "SessionNotFoundError",
  "id": "asess_01jd8z3k5q0b6f2m4r7t9v1x3c"
}
```

### `410` (`application/json`)

SessionRuntimeGoneError

Schema: `SessionRuntimeGoneError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `id` | `string` | Yes | TypeID with prefix "asess_". |

Example:

```json
{
  "_tag": "SessionRuntimeGoneError",
  "id": "asess_01jd8z3k5q0b6f2m4r7t9v1x3c"
}
```

### `429` (`application/json`)

RateLimitExceededError

Schema: `RateLimitExceededError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `resource` | `string` | Yes | Rate-limited resource bucket the request was counted against. |
| `retryAfter` | `number` | Yes |  |

Example:

```json
{
  "_tag": "RateLimitExceededError",
  "resource": "string",
  "retryAfter": 1
}
```

### `500` (`application/json`)

InternalError

Schema: `InternalError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |

Example:

```json
{
  "_tag": "InternalError"
}
```

### `502` (`application/json`)

ActorActionError

Schema: `ActorActionError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `code` | `string` | Yes |  |
| `acceptedEvents` | `integer` | No |  |
| `totalEvents` | `integer` | No |  |

Example:

```json
{
  "_tag": "ActorActionError",
  "code": "string",
  "acceptedEvents": -9007199254740991,
  "totalEvents": -9007199254740991
}
```

### `503` (`application/json`)

ActorUnavailableError

Schema: `ActorUnavailableError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |

Example:

```json
{
  "_tag": "ActorUnavailableError"
}
```

## Example Request

### cURL

```bash
curl -N -X GET 'https://api.thecompany.company/v1/sessions/{id}/events/stream' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Accept: text/event-stream'
```

### TypeScript

```typescript
const response = await fetch('https://api.thecompany.company/v1/sessions/{id}/events/stream', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Accept: 'text/event-stream',
  },
});
if (!response.ok || !response.body) {
  throw new Error('HTTP ' + response.status);
}
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
for (let chunk = await reader.read(); !chunk.done; chunk = await reader.read()) {
  console.log(chunk.value);
}
```
