Use SSE, an HTTP connection carrying server events, to update a screen when State changes. Multiple Machines can share one subscription. It does not provide a complete historical read.

## Select a fixed set of targets

Send Unit IDs to `POST /api/1/units/states/stream`. Supported targets are `machine-*` and your own `account-*` Unit. Read permission and access to every target are required.

```json
{
  "unit_ids": ["machine-<Machine ID>", "account-<Account ID>"],
  "keys": ["temperature"],
  "include_current": true
}
```

| Field | Value |
| --- | --- |
| `unit_ids` | Required, 1–1,000 entries |
| `keys` | Omit for all keys, or specify 1–32 keys shared by all Units |
| `include_current` | Defaults to false; true requests current values at startup |
| `last_event_id` | Last fully processed event ID, for reconnection |

The JSON body must fit within 256 KiB. If any target is missing or inaccessible, the whole request returns 404. To subscribe to search results, first use [Machine search](machine-search) to choose IDs. Newly matching Machines are not automatically added; reconnect to change targets.

The browser's built-in `EventSource` only supports GET. Use streaming `fetch` or a compatible [browser SDK](../integration/browser-apps) for this POST API. For one Unit, `GET /api/1/units/{unit_id}/states/stream` is also available.

## Distinguish snapshots from changes

`unit_state.snapshot` replaces current values within its stated scope. A `unit_state.batch` contains only changed keys in `changes`, not the entire State. Use each item's `unit_id` to route multi-Unit data.

Do not count a snapshot as proof that a Machine communicated after monitoring began. A State event does not itself guarantee receipt of a radio packet. Check the monitored key and the receive timestamp stored in its value.

## Recover after disconnection

Save the SSE `id` only after fully processing the event. Send it as `last_event_id` on reconnection; a `Last-Event-ID` header takes precedence if both are supplied. `include_current: true` prioritizes current values over replay from the cursor.

If a cursor has expired, `unit_state.reset` is followed by a snapshot. Handle this recovery snapshot even with `include_current: false`. Add a delay before reconnecting and close subscriptions when leaving the screen.

Connections end after at most one hour. Replay is limited by the default retention of ten minutes or 100,000 entries. Connection and buffer limits also apply, and permissions are rechecked during a connection. The 1,000-target limit does not guarantee performance at arbitrary update rates. Request only the keys you need.
