# SSE Events

> Subscribe to MyStocks Server-Sent Events for order, wallet, KYC, dividend, market, and incident updates.

`GET /stream` is a Server-Sent Events feed for partner-facing state changes. Use it for live application updates; use signed webhooks for durable server-to-server processing and reconciliation.

## Connect

The stream uses the same partner base URL and authentication model as REST:

```javascript
const source = new EventSource(
  'https://mystocks.africa/api/v1/partner/stream?access_token=ms_oauth_<short-lived-token>'
);

source.onmessage = (message) => {
  const event = JSON.parse(message.data);
  console.log(event.eventId, event.event, event.data);
};
```

For browser clients, prefer a short-lived OAuth token over exposing a long-lived partner key. For server clients, send the normal `Authorization: Bearer` header.

## Resume and reconnect

Each frame carries a numeric stream cursor. Persist the last `id:` value and reconnect with `Last-Event-ID` or `?since=` after a network interruption. The connection may close after approximately 110 seconds; reconnect is expected. Heartbeat comments are sent periodically and should reset your idle timer.

```text
id: 1842
data: {"eventId":"evt_...","event":"order.filled","data":{...}}
```

## Delivery semantics

- Events are at-least-once and can be duplicated.
- Events can arrive out of order; derive state from the event payload and current REST state.
- Deduplicate by `eventId`, not by cursor alone.
- SSE is not a tick-by-tick market-price stream.
- A stream reconnect does not replace daily reconciliation.

The same business events can be delivered through [signed webhooks](/partners/docs/webhooks). See [Trading lifecycles](/partners/docs/lifecycles) for order transitions and [Daily Reconciliation](/partners/docs/daily-reconciliation) for the durable operating record.
