Skip to content

Follow view bindings live over one SSE stream

GET
/views:watch
curl --request GET \
--url https://example.com/api/v1/views:watch

Streams the rows that land for every binding, and a changed notice for every topic a write moved, as Server-Sent Events, one connection for all of them (ADR-1830, ADR-2731). Each binding resumes after its own cursor (the /views:run result’s), so history and live rows meet with no gap and no duplicate. A rows event carries each binding’s matching rows and has the cursor after them as its id; a mark event advances that position when nothing matched; a reconnecting EventSource sends it back as Last-Event-ID and every binding resumes from it or its own cursor, whichever is later. A reset event names bindings whose cursor the tail no longer holds (too old, or from before a server restart), and the stream ends: the client re-runs their history and reconnects. The tail is the ingest landing point of this server, not a poll; rows a calc or rule derives are not on it. Gated by view:read, with each binding’s :read and scope as /views:run: the selector resolves once at connect, and the stream carries only rows of the entities it resolved to. A stream is bounded so that scope never goes stale: it ends at its lifetime (15 minutes, or duration_seconds) with its position, and on each 15 second heartbeat it rechecks its caller, ending once the session no longer resolves or the caller’s grants changed; the client reconnects from its cursor, and the reconnect authenticates and resolves again. A topic (kind:ref, a component or a system) needs :read and resolves in scope at connect as a literal ref does, an out-of-scope one the same 404; a changed event names it when a write moved its state (its health recomputed, a slot or member changed), at most once each 250 milliseconds, and carries no data: the client refetches the route it reads. The topics resume after topics_cursor (else Last-Event-ID, else now); a position the tail no longer holds is a reset with topics set, and the client refetches what they show. An event bears the stream’s position only once every changed notice before it has gone out, so a reconnect from any id misses no change. One user holds at most 16 watches open; past it the open is a 429. On server shutdown each stream ends with a final mark.

bindings

The bindings followed, as a JSON array: each the body of a /views:run binding plus its cursor (the result’s cursor it resumes after; unset follows from now). Give bindings, topics, or both

string
<= 32768 characters

The bindings followed, as a JSON array: each the body of a /views:run binding plus its cursor (the result’s cursor it resumes after; unset follows from now). Give bindings, topics, or both

topics

The entities whose changes the stream names, comma separated, each kind:ref (component or system, by name, uuid or dotted address; at most 32). A changed event says one moved: refetch its route. Give bindings, topics, or both

string
<= 8192 characters

The entities whose changes the stream names, comma separated, each kind:ref (component or system, by name, uuid or dotted address; at most 32). A changed event says one moved: refetch its route. Give bindings, topics, or both

topics_cursor

The position the topics resume after: the last event id the client received. Unset, Last-Event-ID; unset too, the topics follow from now

string
<= 64 characters

The position the topics resume after: the last event id the client received. Unset, Last-Event-ID; unset too, the topics follow from now

duration_seconds

Ends the stream after this many seconds, for a script or the CLI reading a bounded tail. Unset, or past it, the stream ends at its 900 second lifetime, and the client reconnects from its position

integer format: int64
>= 1 <= 900

Ends the stream after this many seconds, for a script or the CLI reading a bounded tail. Unset, or past it, the stream ends at its 900 second lifetime, and the client reconnects from its position

Last-Event-ID

The last event id the client received, sent by an EventSource on reconnect: every binding resumes from it or its own cursor, whichever is later, and the topics from it

string
<= 64 characters

The last event id the client received, sent by an EventSource on reconnect: every binding resumes from it or its own cursor, whichever is later, and the topics from it

The event stream

Media type text/event-stream
Server Sent Events

Each oneOf object is one possible event, serialized as UTF-8 text per the Server-Sent Events specification.

Array
One of:
Event mark
object
data
required
object
cursor
required

The stream’s position: every binding has every row up to it

string
event
required

The event name

string
Allowed value: mark
id

The cursor after the event, the resume point; absent on reset

string

Error

Media type application/problem+json
object
$schema

A URL to the JSON Schema for this object.

string format: uri
detail

A human-readable explanation specific to this occurrence of the problem.

string
errors

Optional list of individual error details

Array<object> | null
object
location

Where the error occurred, e.g. ‘body.items[3].tags’ or ‘path.thing-id’

string
message

Error message text

string
value

The value at the given location

instance

A URI reference that identifies the specific occurrence of the problem.

string format: uri
status

HTTP status code

integer format: int64
title

A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

string
type

A URI reference to human-readable documentation for the error.

string format: uri
default: about:blank

Example

{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "about:blank"
}