Realtime
Stream record changes over Server-Sent Events on the same GET paths as JSON:API.
You may stream record changes with Server-Sent Events (SSE) on the same URIs as the REST API. The path stays /v1/{resource} or /v1/{resource}/{id}. The Accept header chooses the response shape.
To open a collection stream:
curl -N http://127.0.0.1:3000/v1/posts \
-H "Authorization: Bearer crt_…" \
-H "Accept: text/event-stream"
| Accept | Response |
|---|---|
omitted, */*, or application/vnd.api+json |
JSON:API document (unchanged) |
text/event-stream (or preferred via q) |
SSE stream |
Permissions, row scope, and field projection match a normal GET. List query filters shape the opening snapshot and which later lifecycle events are forwarded.
Open a stream#
For one record:
curl -N http://127.0.0.1:3000/v1/posts/<id> \
-H "Authorization: Bearer crt_…" \
-H "Accept: text/event-stream"
The response uses Content-Type: text/event-stream and Cache-Control: no-cache. Charter sends comment keepalives about every 15 seconds so proxies keep the connection open.
Events#
snapshot. First event. Thedata:field is the same JSON:API document a normal GET would return (collection withmetafor lists, or one resource for retrieve).- Lifecycle. Later events use the lifecycle name as the SSE
event:field (posts.created,posts.updated,posts.replaced,posts.deleted). Thedata:JSON matches webhook payloads (event,resource,id,before,after,actor,trace). The SSEid:field is the record UUID.
Collection streams receive events for that resource. Item streams receive events for that id only. Soft-deleted rows leave the stream after the *.deleted event.
When a change crosses your row scope or list filters, Charter still sends the lifecycle event if either before or after matches, and sets the out-of-scope image to null. That matches GET: you never see attribute values for a state your filters would hide.
Info
Reconnects start over with a new snapshot. Charter does not replay from Last-Event-ID. Streams are process-local: subscribe on the same charter serve / charter dev process that handles the writes you care about. Resource MCP writes on that process feed the same bus as REST.
Browser clients#
EventSource sends Accept: text/event-stream by default. Pass the API key or access token the same way your app authenticates other /v1 calls (for example a cookie session, or a fetch-based EventSource wrapper that can set Authorization).