Synchronization
The /sync endpoint is the primary mechanism for clients to receive new events and maintain client state.
GET /sync
Parameters
Response Structure
Stream Tokens
Stream tokens are opaque strings that encode a position in the event stream. They are used for:
- Incremental sync:
sinceparameter resumes from a previous position - Pagination:
/messagesand/contextusefrom/totokens - Gap detection:
timeline.limited = trueindicates events were lost (client should re-sync)
Tokens are base64-encoded tuples of (room_id, stream_ordering).
Long-Polling
When timeout > 0, the server holds the connection open until:
- New events arrive for the user
- The timeout expires
- A keep-alive is needed
This reduces client polling frequency and latency.
Filters
Filters control which events appear in /sync:
Filters can be saved via POST /filter and referenced by ID.
Ephemeral Events
Ephemeral events are not persisted long-term but are included in /sync:
Account Data
Account data events are user-specific and included in every sync response:
Device Lists
When a user joins, leaves, or is banned from a room, the device list change notification system triggers device_lists.changed / device_lists.left entries in the sync response. This allows E2EE clients to track which devices to encrypt for.