Skip to main content

Event envelope

Every event you send to POST /api/v0/events/ is one envelope: a JSON object describing what happened, who did it and what it happened to. The same shape comes back from the read API after ingest, plus the server-owned fields described on this page.

Fields​

FieldTypeRequiredNotes
idstringNoYour own event identifier. When absent or empty the server assigns a 26-character ULID. Unique per (team, trail).
eventstringYesThe action name, e.g. invoice.voided. Must be a non-empty string.
trailstringYesThe trail the event belongs to. Must be a non-empty string.
created_atstringNoWhen the event happened, as RFC 3339 text. Defaults to the time the server received the event.
organization_idstringYesThe end customer (Organization) this event belongs to. A blank value is rejected; see Organizations.
idempotency_keystringNoOptional per-event idempotency key. See Idempotency.
actorobjectNoWho acted. An absent or empty actor is stored as empty actor columns.
targetsarray of objectsNoThe objects the event acted on, at most 10.
metadataobjectNoA flat string-to-string map, indexed for filtering.
schema_versionintegerNoPins the published event definition version that validates this event. See Event definitions.
dataany JSONNoFree-form detail, stored verbatim with the event.
contextobjectNoTransport facts about the request (IP address, user agent, request id).

A key that is not in this table is rejected: unknown top-level keys return 400 with code unknown_field and field set to the offending key. events is reserved at the top level — a body carrying it is a batch, never a single envelope.

Rules​

id​

When you omit id, or send it as an empty string, the server generates a ULID and echoes it back as id in every read response. An id that is not a string returns 400 invalid_envelope with field id.

An id is unique per team and trail. Re-sending an envelope whose id already exists on that trail never writes a second row; the API responds with the event that is already stored.

created_at​

created_at is the producer's timestamp — the moment the thing happened, not the moment the request arrived. It defaults to receipt time when you omit it. When you supply it, it must be RFC 3339 with a UTC offset (2026-09-29T14:03:11.482Z or 2026-09-29T16:03:11.482+02:00). A naive timestamp, an unparseable string, or any non-string value returns 400 invalid_envelope with field created_at.

The read shape exposes both ends: created_at echoes your timestamp and received_at is when the server stored the event.

actor​

FieldTypeRequiredNotes
typestringNoOne of user, system, agent, anonymous. Required as soon as actor has any other key.
idstringNoRequired unless type is anonymous.
namestringNoDisplay name. A non-string value is stored as empty.
metadataobjectNoSubject to the metadata limits below.

An agent acting for someone sets on_behalf_of_type and on_behalf_of_id in actor.metadata. See Agents acting for someone.

An actor that is absent or an empty object is accepted: the event is stored with empty actor columns. When actor carries anything, type must be one of the four values above — anything else returns 400 invalid_actor_type with field actor.type. A missing or empty actor.id on a non-anonymous actor returns 400 invalid_envelope with field actor.id.

targets​

targets is an array of objects. Each entry needs a non-empty string type and a non-empty string id; name and metadata are also accepted. An entry that is not an object, or that is missing type or id, returns 400 invalid_envelope with field targets.<index>.

An event may name at most 10 targets (MAX_TARGETS_PER_EVENT). An array of 11 or more returns 400 too_many_targets with field targets, before anything is written.

Metadata limits​

The same limits apply independently to metadata, actor.metadata and each target's metadata:

LimitValue
Keys per mapat most 50
Key lengthat most 40 characters
Allowed key charactersA-Z, a-z, 0-9, _, ., -
Value lengthat most 500 characters, after coercion to a string

Values are coerced to strings: a boolean becomes true or false, a number becomes its decimal form, and anything that is not a string, number or boolean becomes an empty string. Objects and arrays as values are rejected outright.

A violation returns 400 metadata_limit_exceeded with field naming the exact path, for example metadata.not a key or targets.0.metadata.description. The first offending key in insertion order is the one reported.

data, metadata and context​

  • data carries the payload of the event — amounts, statuses, line items. It is stored verbatim and is not indexed, so it is the right place for anything you will not filter on.
  • metadata is a flat string-to-string map, indexed for querying. Use it for the small set of values you filter by, such as metadata.amount_cents, then read them back with the metadata.<key> filter.
  • context is for transport facts about the request that carried the event: source IP, user agent, request id. It is free-form and stored with the payload.

Example​

The request below sends every optional field, including a producer-supplied id.

curl -X POST https://api.santati.io/api/v0/events/ \
-H "Authorization: Api-Key $SANTATI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "01J9Z6K3M4QX8RT2VN5B7HCWDA",
"event": "invoice.voided",
"trail": "billing",
"created_at": "2026-09-29T14:03:11.482Z",
"organization_id": "org_acme_logistics",
"actor": {
"type": "user",
"id": "usr_123",
"name": "Valentine Michael Smith",
"metadata": {"department": "finance"}
},
"targets": [
{"type": "invoice", "id": "inv_555", "name": "INV-555", "metadata": {"currency": "usd"}}
],
"metadata": {"amount_cents": "4200"},
"data": {"amount_cents": 4200, "currency": "usd", "status": "void"},
"context": {"location": "203.0.113.4", "user_agent": "acme-billing/1.4"}
}'

A 201 response carries the stored event in the read shape:

{
"id": "01J9Z6K3M4QX8RT2VN5B7HCWDA",
"trail": "billing",
"event": "invoice.voided",
"created_at": "2026-09-29T14:03:11.482000Z",
"received_at": "2026-09-29T14:03:11.913000Z",
"organization_id": "org_acme_logistics",
"actor": {
"type": "user",
"id": "usr_123",
"name": "Valentine Michael Smith",
"metadata": {"department": "finance"}
},
"targets": [
{"type": "invoice", "id": "inv_555", "name": "INV-555", "metadata": {"currency": "usd"}}
],
"metadata": {"amount_cents": "4200"},
"data": {"amount_cents": 4200, "currency": "usd", "status": "void"},
"context": {"location": "203.0.113.4", "user_agent": "acme-billing/1.4"},
"hash": "",
"schema_version": null
}

hash is empty until the event is sealed into its trail's hash chain, and schema_version is null when no event definition applies. See Chain verification for the seal, and Errors for every rejection code and status.