Skip to content

Push wire format

A push is a small message an application sends to browsers, apps and field devices that are listening over server-sent events (SSE). This page is the byte-level contract the readers and hosts share. For what a push is for, and when to use it, see Push to clients.

The wire is the same wherever the push host runs: inside an application built on the framework (drivers postgres or redis), or on the platform’s push gateway, which serves the same routes under {platform}/api/push. A reader’s baseUrl is the host’s base (for the gateway, {platform}/api).

A push is sent only if its transaction commits, and every committed push is delivered to every stream subscribed to its topic, in log order, once, as long as the stream is open or resumes within the retention window. A stream that resumes from further back gets a reset event and must reload its state. The log is per host: ids from one host mean nothing to another.

A push is a signal, not state by default: say what changed ({"orderId":"ord_1","version":7}) and let the client read the state through the application’s API, which applies its normal access checks. A push may carry state when the data is fine for everyone allowed on the topic.

Part Rule
Topic {application}:{segment}(:{segment})*. The first segment is the application code ([a-z][a-z0-9-]*); each further segment matches [0-9A-Za-z_.-]+. At least two segments, at most 255 characters. Examples: orders:order:ord_0ABCDEFGH01, orders:store:12:dock.
Type [a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)*, at most 100 characters, for example order.updated. reset, auth-expired, subscribed and every type beginning fw. are reserved.
Data A JSON object, at most push.max-data-bytes (default 16 KiB, at most 64 KiB) of UTF-8, stored compact.

Every topic starts with its application’s code, so topics from different applications never collide on a shared host. Refusal codes when a push is built or published: TOPIC_INVALID, TYPE_INVALID, TYPE_RESERVED, DATA_INVALID (not JSON), DATA_NOT_OBJECT, DATA_TOO_LARGE.

There is one subscribe mode and it takes two requests.

POST {base}/push/subscriptions

{
"topics": ["orders:order:ord_1", "orders:user:prn_0ABC"],
"tickets": ["<ticket>"],
"client": "<optional client identifier>"
}

The request is authenticated the way the host authenticates its users (session cookie with its CSRF rule, bearer token, or a field token with its DPoP proof), or not at all when tickets grant every requested topic. topics holds 1 to push.max-topics (default 100) entries; duplicates are dropped. Each topic is granted when a rule allows it for the caller or a ticket grants it.

client is optional and is for callers that can act for several clients (platform users with anchor or partner reach). It must be a client the credential can use, else 403 CLIENT_FORBIDDEN. A credential with several clients and no client is 400 VALIDATION. A stream that hears every client’s pushes on a topic must name the platform client (_platform) and needs the permission platform:push:all-clients on the gateway.

Response 200:

{
"streamToken": "<opaque>",
"expiresAt": "2026-11-08T13:00:00Z",
"granted": ["orders:order:ord_1"],
"denied": [{ "topic": "orders:user:prn_0ABC", "code": "TOPIC_FORBIDDEN" }]
}

A denied topic is reported and never fails the others. denied is always present (possibly empty). Denial codes: TOPIC_FORBIDDEN (no rule allows it, or the application is unknown) and TICKET_INVALID (a ticket named the topic but is invalid, expired or for another client).

Other answers:

Status and code Meaning
400 VALIDATION Malformed body, an invalid topic, too many topics, a malformed ticket, or a bad client.
401 Credentials were given and failed, or none were given and no valid ticket came with the request.
403 NO_TOPICS Nothing was granted.
403 CLIENT_FORBIDDEN The client named cannot be used by this credential.
429 PUSH_LIMIT A stream limit was reached (below).
503 UNAVAILABLE The host is draining.

The stream token names the granted topics, the stream’s client, the principal (if any) and an expiry: the earliest of the credential’s expiry, every ticket’s stream-exp, and push.stream.max-lifetime (default 1 hour). It is signed by the host (HMAC-SHA256, shared by every instance of the host) and is a capability to listen, nothing else.

GET {base}/push/stream?st=<streamToken>, with Last-Event-ID (header, or lastEventId in the query, so a browser EventSource can resume) when resuming. The st parameter is redacted in access logs. Answers: 401 STREAM_TOKEN_INVALID or STREAM_TOKEN_EXPIRED (subscribe again), 429 PUSH_LIMIT, 503 UNAVAILABLE, or 200 text/event-stream.

The stream carries, in order:

  1. A subscribed event, without an id: {"granted": [...], "latest": <highest log id now>}.
  2. When Last-Event-ID is given and inside retention: every push after it on the granted topics, in id order. If it is older than the oldest id kept, a reset event instead. Without Last-Event-ID, nothing from the past: the client loaded its state before subscribing.
  3. The live pushes, each once, in id order.

A push:

id: 1042
event: order.updated
data: {"topic":"orders:order:ord_1","data":{"orderId":"ord_1","version":7}}

id is a positive increasing 64-bit integer, the log id. The data line is one JSON object with topic and data. The exact bytes of each event are pinned by the shared vectors (conformance/push/wire.json; see Conformance vectors).

Reserved events:

event: data When
subscribed {"granted":[...],"latest":N} First event of every stream. No id.
reset {"reason":"retention","latest":N} or {"reason":"unknown-id","latest":N}; the SSE id is latest Last-Event-ID is older than the oldest id kept (retention), higher than the host has, or not a non-negative integer (unknown-id). The client must reload its state from the API; the stream then continues live.
auth-expired {} The stream token expired, a field login family was revoked, or the user signed out. The host ends the stream. Subscribe again (new token, new tickets) and resume with the last id: nothing is lost.

The stream sends a heartbeat comment line and an SSE retry of 3 seconds; clients should reconnect after the retry with jitter. An empty Last-Event-ID is treated as absent.

A stream belongs to one client. It receives a push when the push’s topic is one it subscribed to and either the push’s client is the stream’s client, or the push’s client is the platform client (written as NULL), which goes to every stream on the topic. A stream opened in the platform client’s context receives the topic’s pushes of every client. The check is made for every push after the topic match, so two clients’ topics with the same name never hear each other.

Rules say who may subscribe without a ticket. They are declared in code per topic pattern and are data, not callbacks, so the gateway can apply them.

  • A pattern’s segments are literals or placeholders. {principal} must equal the caller’s principal id; {client} must equal the caller’s client; any other {name} matches one segment.
  • requires(permission) needs a permission in the caller’s context (several mean all).
  • A rule with no principal placeholder and no requires is refused when declared, so no topic is open by accident. A deliberately open topic is declared public.

Tickets let an application grant topics a rule cannot express (“this user may see order 7 but not order 8”). The application mints one after its own access check; it is short-lived. Format: JWS compact, alg EdDSA (Ed25519), header kid.

Claim Meaning
iss The application code. Every topic in the ticket must begin with it.
aud fw-push.
client The stream’s client (the platform client’s value for platform-wide).
topics Patterns as in rules; placeholders match any one segment; at most 100.
sub Optional principal, recorded in the stream token for logs.
cnf Optional {"jkt": "<thumbprint>"}: the subscribe request must then carry a field token bound to that key.
iat, exp exp at most 5 minutes after iat (minted tickets use 2 minutes).
stream-exp Optional latest end of the stream (default exp plus push.stream.max-lifetime).

The host publishes its ticket public keys at GET {base}/push/keys (a JWKS, the current and previous key during a rotation). A ticket with a bad signature, unknown kid, expired exp, a crit header, an iat more than a minute ahead, a ticket for another client, or a topic outside iss grants nothing (TICKET_INVALID). A malformed ticket is 400. Tickets from several applications can come in one request when the host is the platform gateway; each is checked against its own issuer’s keys.

Limit Default Result
push.max-streams per instance 50 000 429 PUSH_LIMIT at subscribe and at listen
push.max-streams-per-principal 20 429 PUSH_LIMIT
Per-application streams (gateway) 20 000, adjustable per application 429 PUSH_LIMIT with details: {"scope":"application","application":"..."}
push.stream.buffer 256 pushes A stream that falls further behind is ended (no event) and resumes from its Last-Event-ID
push.recent 10 000 pushes in memory Resumes inside it are served from memory; older ones read the log
push.retention 24 h (10 min to 24 h) Older than this, a resume gets reset

A draining instance ends all its streams at once and answers new subscribes and streams 503; the clients reconnect to another instance. See Environment variables for the gateway’s FC_PUSH_* settings (FC_PUSH_STREAM_SECRET, FC_PUSH_DRIVER, FC_PUSH_RETENTION and so on).

A client loads its state through an ordinary read endpoint and then listens; a change committed between the two would be missed. So the read endpoint also returns the push cursor (a log id as a decimal string, pushCursor is the recommended field name), read before the state, and the client opens its first listen with it as Last-Event-ID. A cursor that lags the log is safe (more pushes are replayed). On the gateway there is no local cursor; the client instead re-reads its state once when its stream reports subscribed.

How a push gets onto the log depends on the host.

  • A host that hosts push itself: an application writes the push in a transaction (a use case plan step, or a publish call inside a transaction it owns). Writing inserts a row in fw_push_outbox and notifies; one relay (gated by a lock) moves rows into the log in commit order. Log ids have no gaps and never reorder.
  • The platform gateway: an application writes a PUSH row to its own outbox_messages in the same transaction as its change, and the platform’s outbox processor forwards it to POST /api/push/batch.
Column Value
type PUSH
message_group The topic by default, so pushes on a topic keep their order. Ungrouped rows are sent concurrently, in no order.
payload {"topic","type","data","clientCode","pushId"}, in this order. data is the object itself, not an encoded string. clientCode is the writer’s client, absent for the platform client. pushId is the row id (up to 26 characters).

Served by the push component, not described in the platform OpenAPI document. Bearer tokens only (cookies are dropped). Permission platform:messaging:batch:push-write (held by the built-in platform:application-service role).

Request {"items": [<payload>, ...]}. Response, positional: {"results": [{"id","status","error","code"}]}, where id is the pushId. Per item, in order: topic syntax; ownership of the application (TOPIC_NOT_OWNED, forbidden, for an application-scoped caller; APPLICATION_UNKNOWN for an unscoped one); type and data (the codes above); PUSH_ID_INVALID; the client (CLIENT_FORBIDDEN). A pushId already seen (in the same request or an earlier one) answers success with code DUPLICATE and writes nothing. The valid items are written in one transaction.

A paused application, or one over its publish rate (default 500 per second with a burst of 2 000, per gateway task), answers the whole batch 429 with Retry-After, writing nothing. The outbox processor treats a 429 as “wait and retry” without spending attempts, so the pushes wait in the application’s outbox.

Pushes of one message group (by default one topic) of one application arrive in their outbox order; otherwise in the order the gateway receives them. The framework’s “log order equals commit order” holds per host.

Client-to-server messages (WebSockets), presence, mobile push notifications, ordering across hosts, and exactly-once beyond what the ids give: a client that resumes from an older id gets those pushes again and drops ids it has already applied.