Listen API reference
Reference documentation for the Listen HTTP endpoint.
The listen endpoint can be used to receive events whenever documents are modified. This endpoint follows the server-sent events protocol using the mime-type text/event-stream. The backend will hold the connection open and stream events as they occur for any documents matching the GROQ query.
In most cases, you should use the Live Content API instead for new projects.
Authentication
- Any requests to private datasets must be authenticated.
Base API server URL
Sanity API base URL
https://{projectId}.api.sanity.io/{apiVersion}Variables
- projectIdstringdefault:
"projectId"Project ID
- apiVersionstringdefault:
"v2025-02-19"API version
Endpoints
Stream document mutation events
/data/listen/{dataset}Streams events whenever documents matching the GROQ query are modified. This is a live API adhering to the Server Sent Events standard.
Path parameters
The dataset to stream events from
Query parameters
The GROQ-query used to filter the events. Only the top-level filter portion of the query will be used, anything else including projection, subqueries, slicing or aggregation will be ignored.
- $-paramsstring
Include the resulting document in addition to the changes.
Include the document as it looked before the change.
Include the mutations applied as part of the transaction.
Specifies whether events should be sent as soon as a transaction has been committed (transaction, default), or only after they are available for queries (query). Note that this is best-effort, and listeners with query may in certain cases (notably with deferred transactions) receive events that are not yet visible to queries. The visibility event field will indicate the actual visibility.
Send a prolog of 2056 no-op characters for compatibility with older browsers.
- effectFormatstring
If set to the only allowed value mendoza, an additional field effects is included in the returned payload with mutation effects in the Mendoza specification.
Set to true to receive draft and version documents. Requires API version 2025-02-19.
Responses
Successfully started streaming operation