Home/Documentation

Change Streams (SSE)

Subscribe to real-time document changes via Server-Sent Events. Pro plan only.

info
Change streams are available on the Pro plan only. Free tier users will receive a 403 response.

Subscribe to Changes

GET/v1/db/{ns}/{collection}/_stream

Opens an SSE connection that emits events when documents change.

Path Parameters

NameTypeDescription
nsrequiredstringNamespace name (e.g. 'default')
collectionrequiredstringCollection name (e.g. 'users')

Query Parameters

NameTypeDescription
eventsstringComma-separated event types: created, updated, deleted. Default: all events.
filter[field]stringOnly stream events for documents matching this filter.

Headers

NameTypeDescription
AcceptrequiredstringMust be 'text/event-stream'
AuthorizationrequiredstringBearer token (API key)
Last-Event-IDstringResume from this event ID after reconnection
curl -N https://api.jsondb.cloud/v1/db/default/users/_stream \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: text/event-stream"

Event Format

Each event follows the SSE standard format with an event type, unique ID, and JSON data payload.

event: document.created
id: evt_a1b2c3d4e5f6
data: {"event":"document.created","timestamp":"2026-02-24T14:30:00Z","collection":"users","namespace":"default","document":{"_id":"usr_a1b2c3d4","name":"Alice","email":"[email protected]","_version":1}}

Resumability

When a connection drops, clients can reconnect with the Last-Event-ID header to replay missed events. Events are retained for up to 5 minutes.

curl -N https://api.jsondb.cloud/v1/db/default/users/_stream \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: text/event-stream" \
  -H "Last-Event-ID: evt_a1b2c3d4e5f6"
info
The SDK handles reconnection and event replay automatically. You don't need to manage Last-Event-ID manually.

Limits

LimitFreePro
Change streamsNot availableIncluded
Concurrent connections per key-10
Event retention (for resume)-5 minutes
Heartbeat interval-30 seconds