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

# Server-Sent Events

> Subscribe to a connected account's live activity over HTTP.

Open an SSE stream and receive events as they happen — no WebSocket client or
public webhook receiver required.

```
GET /v1/accounts/{id}/events
Authorization: Bearer <api-key>
Accept: text/event-stream
```

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
const es = new EventSource(
  `https://api.onlyfanskit.dev/v1/accounts/${accountId}/events`,
  { headers: { authorization: `Bearer ${apiKey}` } }
);

es.addEventListener("message", (e) => {
  const { data } = JSON.parse(e.data); // new chat message payload
});
es.addEventListener("subscribed", (e) => { /* new subscriber */ });
es.addEventListener("tips", (e) => { /* tip received */ });
```

## Event shape

Each SSE message's `event:` field is the OnlyFans event name (`message`,
`subscribed`, `stream`, `postPublished`, …) and `data:` is
`{ data, meta, ts }`. The stream also emits:

* `ready` — once, on connect.
* `heartbeat` — periodically, to keep the connection alive.

## Resuming

The server sets `id:` on every event. A client that reconnects with the
standard `Last-Event-ID` header (or `?last_event_id=`) replays everything it
missed:

```
GET /v1/accounts/{id}/events?last_event_id=1700000000-0
```

Without a resume id, the stream delivers only events that arrive **after**
connecting (the live tail).

<Note>
  Requires the `accounts:read` scope. The account must be owned by the calling
  key.
</Note>
