Base protocol
Encoding
All messages are UTF-8 JSON objects. A server and a client MUST accept messages up to max_message_bytes (default 1 MiB) and MUST reject larger ones. Field names are snake_case.
Messages are sent over one of the transports in Transports. The message layer is the same on each.
Envelopes
A message is exactly one of three envelopes.
Request (client to server):
{"id": "1", "op": "subscribe", "body": {"conversation_id": "conv_…"}, "trace": {"traceparent": "…"}}
idMUST be unique on the connection while the request is pending.opMUST be one of the operations below.bodydepends on the operation.traceis OPTIONAL and carries W3C trace context for transports without headers.
Response (server to client, answering a request with the same id):
{"id": "1", "ok": true, "result": {…}}
{"id": "1", "ok": false, "error": {"code": "unknown_conversation", "message": "…"}}
Push (server to client, unsolicited):
{"push": "frames", "body": {…}}
A client MUST NOT answer a push. The server MUST NOT send a response with no request.
Operations
| Operation | Body | Result |
|---|---|---|
initialize | protocol_versions, conversation_versions, client, capabilities | protocol_version, conversation_versions, server, principal, capabilities, agreed, downgrades |
command | a command (Commands) | a receipt |
subscribe | conversation_id, optional cursor | a snapshot, or an acknowledged resume with cursor |
read_after | conversation_id, cursor, optional limit | frames, cursor, up_to_date, or resnapshot_reason |
get_receipt | command (the same command, to compare its payload) | the stored receipt |
unsubscribe | conversation_id | empty |
unsubscribe releases a subscription. It never cancels work that the server is doing for the conversation.
A client MUST call initialize once per connection before any other operation. A server MUST reject other operations before initialize with invalid_command.
Pushes
| Push | Body | Meaning |
|---|---|---|
frames | conversation_id, frames, optional up_to_date | One or more frames of one conversation, in cursor order |
resnapshot_required | conversation_id, reason | The stream cannot continue; subscribe again from a snapshot |
Identifiers
| Identifier | Scope | Format |
|---|---|---|
Request id | one connection | a string chosen by the client |
command_id | one sender and one conversation | a string chosen by the client; protocol.NewID creates one |
| Conversation, participant, event IDs | global | prefixed strings such as conv_…, par_…, evt_… |
| Projection ID and epoch | one conversation | identify the journal a cursor belongs to |
Clients MUST generate command_id values that are unique for their sender and conversation. They MAY reuse a command_id only to retry the same command.
Limits
The server advertises its limits in the initialize result. These are the version 1 defaults:
| Limit | Default | Meaning |
|---|---|---|
max_message_bytes | 1 MiB | Largest message on the wire |
max_event_bytes | 64 KiB | Largest event |
max_parts | 32 | Parts in one message |
max_mentions | 32 | Mentions in one message |
max_relations | 8 | Relations on one event |
page_size | 50 | Events per page of a timeline read |
A server MUST refuse a command that exceeds a limit with payload_too_large. A client SHOULD read the limits from initialize rather than hard-code them.
Errors
An error has a code, an optional message, and optional retryable and retry_after_ms fields. The codes are listed in Commands and Delivery. A client MUST NOT retry an error that is not retryable with the same request unless the cause has changed.
Next steps
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.