# Live updates

URL: https://heaven.dev/docs/reference/live-updates
Updated: 2026-11-22

`GET /v1/events` keeps API reads current over one stream. Heaven sends each read's current response and sends it again when the response changes.

## Open a stream

Use an [HTTP credential](https://heaven.dev/docs/reference/authentication#http) that can make the reads. Each `read` is a URL-encoded key with the method and path, such as `GET /v1/computer/`. For a read with a query, sort the query names and encode their values as form data before encoding the whole key as a `read` value.

```sh
curl --no-buffer --get 'https://heaven.dev/v1/events' \
    -H "Authorization: Bearer $HEAVEN_API_KEY" \
    --data-urlencode 'read=GET /v1/computer/?computer=my-site' \
    --data-urlencode 'read=GET /v1/pool/'
```

A stream holds 1 to 16 distinct reads. `logs`, `terminal`, `desktop` and reads with `wait` can't be in one. An invalid stream request gets a JSON error before any events. Opening a stream counts each read against your [request rate](https://heaven.dev/docs/limits#request-rates), and updates after that don't count.

## Events

The response uses [server-sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html) with `Content-Type: text/event-stream`.

| Event | Data |
| --- | --- |
| `hello` | The stream's first event. Its data contains the dashboard's `build` and the `user` ID the reads run as. |
| `read` | The read's `key`, HTTP `status`, JSON `body` and `tag`. Replace the saved response for that key with this one. Read errors arrive here too. |
| `signed-out` | An empty object. Heaven closes the stream because the credential no longer works. |

The `hello` and `read` IDs have the form `TOKEN.N`. `TOKEN` identifies the stream and `N` starts at zero for `hello`. The stream suggests a two-second reconnect delay and sends a `: ping` comment every 20 seconds. Reconnect when the stream closes, at most 30 minutes after it opens.

## Resume a stream

Reconnect with the same credential and send the ID of the last event you processed in `Last-Event-ID` or the `last` query field. The header takes precedence. Heaven can resume for up to two minutes after the previous stream closes. On resume, it sends the current answers that differ from the ones it knows you hold. If Heaven can't resume, the connection starts a new stream.

If you already have a response from a regular GET, send its `Heaven-Read-Tag` as a `tag` on open. Supply one `tag` per `read`, in the same order, using an empty value where you have no saved response. Heaven omits any initial response that matches its tag. With `last`, supplied tags describe what your client holds now. With `Last-Event-ID`, Heaven uses the resume state in preference to the tags from the original URL.

## Change the reads

Send `POST /v1/events/reads` with the same credential. Set `stream` to the token before the dot in the current stream's event IDs. Set `reads` to the complete new list of keys. To reuse a response you hold for a newly added read, include its key and tag in the optional `tags` object.

This body keeps the Computer read and removes the pool read. Use the token from your own stream.

```json
{"stream":"STREAM_TOKEN","reads":["GET /v1/computer/?computer=my-site"]}
```

Heaven forgets removed reads. It sends the initial responses for added reads whose tags don't match before returning the `data.added` and `data.removed` counts. Added reads count against your request rate. If the stream has ended or the credential doesn't match, Heaven returns `not_found`. Open a stream with the desired reads if the old one has closed.
