folkwaysDocs
Realtime API

Frame reference

Every client and server frame of the Realtime API protocol, its tag and reply, and the fields of an event.

Frames travel in packets. Each frame is { corr, body }: corr is your request ID, echoed on every reply. Use non-zero values for requests; unsolicited frames (live deliveries, TokenExpiring, SubEnded, Flow) carry corr = 0.

Tags encode direction: 1–15 either way, 16–127 from clients, 128–255 from servers. No frame carries a segment ID; the segment comes only from the token.

Client frames

FrameTagReplyNotes
Ping { nonce, ts_ms }1Pong with the same nonceEvery heartbeat_ms
Pong2none
Close { code, reason }3The connection closesA polite goodbye
Extension { code, content_type, data }4OpError { UnsupportedFeature }None are enabled yet
Hello16Welcome or CloseFirst frame; WebSocket only
Reauth { token }17OpOk, after any SubEnded, or CloseToken refresh
Publish32PubAck, OpError, or nothing (NoAck, signals)
Subscribe33[Gap] SubAck [Deliver… / Snapshot…] or OpErrorWebSocket only
Unsubscribe { topic | topic_id }34OpOkWebSocket only; always succeeds
CursorAck { acks }35noneA flow-control hint
Poll36… PollEndHTTP only

Server frames

FrameTagWhen
Ping / Pong1 / 2Pong answers your Ping
Close { code, reason, retry_after_ms }3Before the server closes the connection
Welcome128The answer to Hello
TokenExpiring { expires_at_ms }12960 seconds before the token expires
OpOk144Success with nothing to report
OpError { code, message, retry_after_ms, topic_id }145One request failed; the connection stays open
PubAck { topic_id, level, epoch, seq, duplicate, server_ts_ms, uid }146A publish receipt
SubAck { topic_id, delivery, catching_up, oldest, latest, snapshot_follows, deliveries, state_latest }147A subscription is confirmed; links the name to topic_id
Gap { topic_id, reason, requested, oldest, latest, resumed }148A cursor couldn't be honoured
Flow { action, retry_after_ms, topic_id }149Outbound pressure: Throttle, Pause or Resume publishing
PollEnd { timed_out, more }150The last frame of a poll
Deliver { topic_id, delivery, replayed, events }176Events from one topic
Snapshot { topic_id, snapshot_id, chunk, last_chunk, fence, events }177Current KV values and signals
SubEnded { topic_id, code, message }178The server ended a subscription

ServerPacket also carries server_time_ms, set when the packet holds signal expiry data, so clients can work out a signal's remaining lifetime from the server's clock.

Event

The events inside Deliver and Snapshot:

FieldMeaning
topic_idThe topic
epoch, seqThe cursor. seq is 0 for KV and signal events in a topic that carries several types
uidThe permanent ID of a stream or KV event
nameThe event name
deliveryThe event's type: Durable, LastValue or Ephemeral
publisherThe sender's verified identity
key, tombstoneKV and signals: which value, and whether it was deleted
payload, content_type, headersAs published
server_ts_msWhen the server accepted it; for display, not ordering
client_ts_msThe sender's own clock
versionThe state version of a KV or signal event in a topic with several types; 0 otherwise
expires_at_msSignals: the absolute expiry time. 0 means not set; the maximum value means no expiry

topic_id values are stable while a topic exists. A recreated topic gets a new one, so after a reconnect subscribe by name and use the ID from SubAck.

Enums

EnumValues
DeliveryUnspecified 0, Durable 1 (stream), LastValue 2 (kv), Ephemeral 3 (signal)
StartLatest 0, Oldest 1, After 2, LastN 3
On gapFromOldest 0, FromLatest 1, Fail 2
Gap reasonUnspecified 0, Expired 1, EpochLost 2
AckDefault 0, NoAck 1, Accepted 2, Committed 3
Flow actionResume 0, Pause 1, Throttle 2

The full schema is protocol.fbs.

On this page