Skip to content

Subscriptions and connections

A subscription (sub_) says “when an event of these types happens, deliver it there, like this”. A connection (con_) says “deliveries through me are signed by this service account, and can be paused together”. The fan-out reads subscriptions to create dispatch jobs; the delivery callback reads the connection to decide who signs each delivery.

Field Meaning
code, name, description Identity. The code is unique within its application and client.
eventTypes One or more event-type patterns, compared segment by segment; * matches one segment (orders:sales:order:*).
endpoint The URL deliveries are sent to (target in definition sync). Checked against the outbound guard when saved.
connectionId The connection deliveries go through (optional).
serviceAccountId An explicit signer that overrides the connection’s (optional, rarely needed).
dispatchPoolId The dispatch pool that paces deliveries. Without one, the client’s default pool.
mode IMMEDIATE, NEXT_ON_ERROR (the default) or BLOCK_ON_ERROR: how the message group treats a failure. Definition sync treats the mode you declare as the source of truth: it is applied on create and on update, so a mode changed in the console is overwritten by the next sync that carries one. A definition that leaves the mode out keeps the stored mode (a new subscription takes the default). A value that is not one of the three is refused with the validation code INVALID_MODE.
sequence The subscription’s place among other subscriptions’ jobs in the same message group; lower goes first. Default 99.
maxRetries, timeoutSeconds Delivery attempts in all (default 3) and the per-attempt timeout (default 30 seconds).
dataOnly Send the payload as is, or wrapped in the JSON envelope. Defaults to false, the envelope. See delivery.
delaySeconds, maxAgeSeconds Hold each delivery until delaySeconds after the event, and give up (the job becomes EXPIRED) when it is still undelivered maxAgeSeconds after the event. Default age limit 24 hours. Fixed on each job when the event fans out; editing the subscription affects later events only.
queue DEFAULT or HIGH_PRIORITY: which of the client’s two queues the jobs travel on.
clientId Absent for a global subscription; set for a client-scoped one.
status ACTIVE or PAUSED.
source CODE or API (definition sync and the API), UI (the console), or FUNCTION (created when a function is promoted).

A global subscription receives matching events of every client; a client-scoped one receives only its client’s events. Each subscription that matches an event gets its own job, so two subscribers never share a delivery, a retry or a failure.

Messages for one subscription are ordered separately from every other subscription’s: the job’s message group is <subscription id>:<event group>, so a BLOCK_ON_ERROR failure holds only that subscriber’s later jobs. See ordering.

A subscription may name a pool in any status except ARCHIVED: saving one that does is refused with 409 POOL_ARCHIVED. See pools.

A connection has no endpoint of its own. It holds:

Field Meaning
code, name, description, externalId Identity. The code is unique within its application and client.
serviceAccountId Required. The service account whose bearer token and HMAC signing secret go on every delivery through this connection.
status ACTIVE or PAUSED.
clientId Absent for a global connection; set for a client-scoped one.
applicationCode Absent for a shared connection; set for an application-owned one.
source CODE, API or UI, as for subscriptions.

Many subscriptions can share one connection, and a job created directly (by the API or by a function’s fn.dispatch) can name a connection itself.

Two words describe scope, and they are not interchangeable:

No value A value
Client global: usable for every client client-scoped: bound to one client
Application shared: usable by any application application-owned: belongs to one application

A connection can be global and application-owned (one application’s credentials for all clients), or client-scoped and shared, or any other combination. Because the connection’s service account signs deliveries, a connection named by id must be global or of the same client, and shared or of the same application. Definition sync and the dispatch-job APIs refuse a mismatch with CONNECTION_SCOPE_MISMATCH; a lookup by code searches only the allowed connections in the first place.

The two pause switches do different things, and the difference matters:

Paused Effect
A subscription The fan-out stops creating jobs for it. Events that happen while it is paused are not delivered to it later; resuming only affects new events.
A connection Jobs are still created, but the dispatch scheduler holds them PENDING. When the connection is active again (picked up within a minute), they are delivered, in order.

Pause a connection to hold deliveries while a consumer is down or being changed. Pause a subscription to stop a consumer from receiving a kind of event at all.

The delivery callback picks the signing service account in this order. The first rule that names an account decides, and there is no fall-through past it:

  1. The subscription’s own serviceAccountId, when set.
  2. The subscription’s connection’s service account. This is the normal case.
  3. For a job with no subscription that names a connection itself, that connection’s service account.
  4. The application’s oldest active service account, found through the subscription’s application or, for a direct job, the first segment of the job’s code.
  5. Nobody: the delivery goes out unsigned, and the reason is recorded on the attempt.

An account that is named but inactive, or that has no webhook credentials, makes the delivery go out unsigned with a reason; the platform never signs with some other account instead. A consumer that verifies signatures then refuses it with 401, and the job fails at once with the reason in the attempt. A job’s own serviceAccountId does not choose the signer.

Why the connection signs. The connection is where an operator chooses an account: the connection form requires one, the subscription form does not ask. The consumer is configured with that account’s secret. Signing with any other account (the application’s, say) would make every delivery fail verification with a credential nobody chose.

Applications usually declare connections and subscriptions with definition sync, and the platform makes its rows match:

  • POST /api/applications/{appCode}/connections/sync creates, updates and (with removeUnlisted) removes the application’s own connections. Every synced connection’s service account is the application’s provisioned service account, the one whose secret the application verifies deliveries with.
  • POST /api/applications/{appCode}/subscriptions/sync does the same for subscriptions.

Rules that keep a sync safe:

  • Ownership. A sync touches only rows of that application, that client (or no client), with source CODE or API. A row made in the console is never changed or removed by a sync.
  • Client scope. A sync can name a client (clientId, by id or identifier slug); it then sees only that client’s rows. Without one it manages the global rows.
  • Connections by code, not id. A subscription names its connection with connectionCode. A bare code means a connection owned by this application; sharedConnection: true means a shared one. There is no fallback from one namespace to the other: if a later deploy created an application-owned connection with the same code as a shared one, a fallback would silently switch which credentials sign the deliveries.
  • Removal is guarded. A connection sync whose removeUnlisted would remove a connection that a subscription still uses is refused as a whole (CONNECTION_REFERENCED).

Why codes, not ids. Ids are generated per environment, so an id written into code works in one environment and nowhere else. Codes (and client identifiers) are chosen by people and are the same in development, test and production, so one definition can be synced everywhere.