> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agntix.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming events (SSE)

> Subscribe to real-time session, message, and usage events over Server-Sent Events.

<Note>
  Every endpoint on this page requires either a Clerk-issued JWT (`Authorization: Bearer <token>`) or
  an organization API key (`x-api-key: pk_…`). Anonymous calls return `401 Unauthorized`. See
  [Authentication](/authentication) for the full setup.
</Note>

Agntix exposes a single Server-Sent Events stream per organization at `GET /v1/chat/events/stream`. Use it to update dashboards, push notifications, or trigger downstream automation.

## Connect

```javascript theme={null}
const es = new EventSource(
  "https://api.agntix.ai/v1/chat/events/stream",
  { withCredentials: true } // or use ?token=… for environments without cookie support
);

es.addEventListener("message.added", (e) => {
  const payload = JSON.parse(e.data);
  console.log("new message in", payload.sessionId, payload);
});
```

## Event types

| Event                     | Triggered when                                       |
| ------------------------- | ---------------------------------------------------- |
| `session.started`         | A new chat or voice session is created               |
| `session.updated`         | Session state, agent assignment, or analytics change |
| `session.ended`           | Session is closed (manually, expired, or call ended) |
| `message.added`           | A new message is added to a session                  |
| `usage.updated`           | Usage metrics for the org change                     |
| `subscription.updated`    | Plan change, cancel, or resume                       |
| `knowledge_store.updated` | A knowledge store document finishes processing       |
| `heartbeat`               | Sent every 30s; use to detect a dead connection      |

## Reconnecting

The browser's `EventSource` reconnects automatically with the `Last-Event-ID` header. Keep your client side-effect-free with respect to event order — at least one delivery is guaranteed, ordering is not.

<Tip>
  Looking for at-least-once delivery with replay? Subscribe via [Webhooks](/webhooks/overview) instead.
  SSE is fire-and-forget; webhooks are durable.
</Tip>
