Skip to content

Events and event types

An event (evn_) is a business fact an application publishes: something that has already happened, such as “order 1042 was placed” or “invoice 77 was paid”. The platform stores it and never changes it. Delivering it to other systems is the job of subscriptions: each subscription whose event types match gets its own dispatch job.

Events follow the CloudEvents 1.0 vocabulary.

Field Meaning
id A TSID, generated by the platform unless the batch item supplies one.
type The event type code, application:subdomain:aggregate:event, for example orders:sales:order:placed. Required.
source Where it came from. Optional on the wire: when absent or blank the platform stores the type’s first two segments (orders:sales).
subject What it is about, for example sales.order.1042. Optional.
data The payload, any JSON value. Required. An SDK that writes data as a string of encoded JSON has it unwrapped once at ingest, so the stored event holds the object.
time When the event occurred. A batch item may carry its own time (RFC 3339); a value that does not parse, or lies more than 5 minutes in the future, is that item’s BAD_REQUEST. Absent or blank: the moment the platform stored the event. createdAt is always the ingest time, and is what delays, expiry and ordering are counted from.
specVersion 1.0.
messageGroup The ordering key, for example the order id. Copied onto every dispatch job the event raises. See ordering.
correlationId Ties together everything one request or business process caused. Copied onto the dispatch jobs.
causationId The id of the event or command that caused this one.
deduplicationId The idempotency key. An event whose deduplicationId is already stored is dropped. Every SDK (Go, Java, TypeScript, PHP, Rust) sets it to the outbox row id unless you set your own.
clientId / clientCode The client the event belongs to, by id or by identifier slug.
contextData Key and value pairs such as principalId and executionId. Copied onto the raised jobs as their metadata.

Applications normally publish through the outbox, whose relay calls POST /api/events/batch. A single event can also be posted to POST /api/events.

An event type (evt_) is the registered kind of an event. Its code has exactly four non-empty segments, application:subdomain:aggregate:event, and the first segment is the owning application’s code. Event types are usually declared in the application’s code and pushed with definition sync; they can also be created in the console or through the API.

An event type can carry schema versions, each with a version string (1.0, 1.1, 2.0), a schema and a schema type: JSON_SCHEMA, XSD or PROTO. A version moves through three states:

State Meaning
FINALISING Being written. Not yet published to consumers.
CURRENT Published. Finalising a version deprecates the other CURRENT version with the same major number, so 1.1 replaces 1.0 while 2.0 and 1.1 can both be current.
DEPRECATED Kept for reference; consumers should move off it.

An event type is archived only when every schema version is deprecated, and deleted only when it is archived or none of its versions was ever published.

When an event arrives, the platform checks:

  1. Permission. The caller holds the batch-events write permission (the built-in application-service role carries it).
  2. Required fields. type and data are present, and a source is present or can be derived from the type.
  3. The application prefix. A credential confined to applications (an application’s own service account) may publish only types whose first segment is one of its applications. orders cannot publish billing:....
  4. The client. The caller may act for the event’s client (403 otherwise). When no client is named, an anchor writes an event with no client, a credential that reaches exactly one client writes under that client, and anyone else is refused.

In a batch, a problem with one item (a missing field, the wrong application) is reported in that item’s result and the other items are still stored. A client refusal rejects the whole request.

Ingest does not look up the event type and does not validate data against a schema. An event of a type nobody registered is stored like any other.

An event describes something that has already been committed in the producer’s database. Refusing it at ingest would not undo the change; it would only stop the producer’s outbox, and with block-on-error relaying, every later event in the same group behind it. The schema’s real audience is the consumer: it says what the payload contains and how it changes over versions. Keeping ingest to permission and shape checks also keeps the write path cheap, which matters at high event rates.

The consequence is that consumers own their validation. A consumer should check the fields it relies on and reject or park a payload it cannot use, rather than assume the platform has already done so.

A subscription matches an event when one of its event-type patterns matches the event’s type and its client allows it:

  • Patterns compare segment by segment. * matches any single segment, and the segment count must be the same, so orders:sales:order:* matches orders:sales:order:placed but not orders:sales:order.
  • A global subscription (no client) sees every event, whatever its client.
  • A client-scoped subscription sees only events of that client. An event with no client reaches only global subscriptions.

The platform publishes events about its own changes into the same pipeline, with types under the platform: prefix (for example when a user, role or client changes). Applications subscribe to them like any other event. The platform events reference lists them with their schemas.

By default an event’s payload is stored in the event row itself, and the largest payload accepted is 1 MiB (FC_PAYLOAD_INLINE_MAX_BYTES). A payload over the limit is refused with PAYLOAD_TOO_LARGE: on a batch route it is refused in its own result slot, and on a single-event route as a whole request. A request body over the batch cap (FC_INGEST_BATCH_MAX_BYTES, 16 MiB) is refused whole with 413.

The platform also has a payload table and an optional payload store: each payload is stored once and the event and its dispatch jobs point at it, and a payload over a threshold (5 KiB by default) can live in S3 or a directory instead of the database, which raises the largest payload accepted to 5 MB (FC_PAYLOAD_MAX_BYTES). Both are off by default: FC_PAYLOAD_TABLE_WRITES is false until an operator turns it on, and only once every instance runs a release that reads both shapes. The design note (docs/payload-offload-design.md) describes the work as not deployed and not run against real S3, so treat storage in S3 as untried until you have tested it. The operator’s steps are in the environment-variable reference under “Turning payload storage on”.

An offloaded payload is not returned in lists: an event list item carries dataSize and dataOffloaded: true instead of data. Reading one event resolves the payload from the store. If the store cannot be read, or the payload is gone, the event is still returned without its data and with dataUnavailable: true (and dataSize); a dispatch job does the same with payloadUnavailable: true. A consumer that reads events through the API should check for the marker rather than assume data is present.

Events live in a table partitioned by month. Partitions older than the retention window are dropped (90 days by default, FC_STREAM_PARTITION_RETENTION_DAYS). Deduplication works across the events the platform still holds.