Skip to main content

Event definitions

An event definition is a team's declaration that an action name exists, which target types it may act on, and — once a schema version is published — what its metadata must look like. Definitions turn the API from "accept anything" into "accept what you declared", which is what makes an audit log trustworthy at the producer end: a typo in an action name becomes a rejection instead of a silently unsearchable event.

Enforcement is opt-in​

Nothing is enforced until you declare something:

  • A team with no definitions is unaffected: every action is accepted.
  • Once the team has at least one definition, an action that has no active definition is rejected with unknown_action — a 400 for a single event, or that item's entry in a 207 batch response — and field set to event. Matching is exact and case-sensitive, exactly like the event filter on Search events — no normalisation, no prefix matching.
  • A definition with no published schema version still only enforces the action name and its allowed target types. Drafts are never enforced.
{
"error": {
"code": "unknown_action",
"message": "Action 'invoice.voded' is not defined for this team.",
"field": "event"
}
}

Relayed and backfilled events are exempt from all of this: those sources carry traffic the producer already generated, so they are stored verbatim rather than validated against the current catalog.

Allowed target types​

A definition's allowed_target_types is a list of target types. When the list is not empty, every target in the envelope must have one of those types, and a violation is rejected with schema_validation_failed whose field names the offending position, for example targets.0.type. When the list is empty, any target type is accepted.

Metadata schemas​

A published schema document is a JSON Schema (draft 2020-12). It validates one synthesised object built from the envelope, containing exactly:

  • metadata — the event's own map;
  • actor.metadata — the actor's map;
  • targets[].metadata — each target's map, in order.

data and context are free-form by contract and are never constrained, and target types are owned by allowed_target_types rather than the document, so a schema cannot set two conflicting rules for one thing.

One event produces at most one rejection, chosen deterministically: the deepest failing path wins, with ties broken by path and message. A required failure names the first missing property in sorted order, so the field always points at something the producer has to send.

Say you define invoice.voided and publish a schema requiring metadata.amount to be a string of digits. The two bodies below are trimmed to the fields the schema looks at; a real request also carries created_at, actor and targets — see The event envelope. This event satisfies the schema and is indexed with 201 Created:

{
"event": "invoice.voided",
"trail": "billing",
"organization_id": "org_acme",
"metadata": { "amount": "4200" }
}

This one does not — 42.00 is not a run of digits — and is rejected:

{
"event": "invoice.voided",
"trail": "billing",
"organization_id": "org_acme",
"metadata": { "amount": "42.00" }
}
{
"error": {
"code": "schema_validation_failed",
"message": "'42.00' does not match '^[0-9]+$'",
"field": "metadata.amount"
}
}

The same code covers a missing required property (the field names it), a nested target violation (targets.1.metadata.x), and a broken schema version pin. See Errors for the envelope and for how a single rejected item appears inside a batch response.

Versions​

Schema versions are numbered per action, one past the highest number ever used, so a deleted draft never frees its number. Publishing is what starts enforcement:

  • Drafts do not enforce, and can be edited. A version that is not published is ignored by ingest. Change a draft in place in the app or over the API until you publish it.
  • Published versions are immutable. A published document, its number and its definition are frozen, so what producers validated against cannot be rewritten later. To change one, start a new draft from it.
  • Unpinned producers follow the newest published version that is not deprecated; if every published version is eventually deprecated, the newest one still applies, because a lone deprecated schema should keep being enforced rather than silently becoming a no-op.
  • Publishing a new version deprecates its predecessor, which starts a grace window. Producers pinned to the old version keep being accepted until the deadline: 90 days after deprecation.

Pin a version by sending schema_version in the envelope. A pin is refused with schema_validation_failed and field set to schema_version when the version is not a positive integer, has no published schema for that action, is past its grace deadline, or when the action has no schema at all. Events that pass a schema record the version that validated them; a rejected event records none.

Standard events​

Santati ships a catalog of recommended actions (Standard events) that admins install from Add standard events, or over the API.

Installing copies a standard action's schema into your catalog as its own published v1. From then on it is your schema: edit it like any custom one, add, rename or remove fields, and publish the result. Nothing checks it against the standard document. standard is a reserved action name.

List definitions​

GET /api/v0/event-definitions/ (Event definitions list) lists your team's definitions, ordered by action name, with the same cursor pagination as every other list endpoint (limit defaults to 100, capped at 1000; no count). Any team key may read it.

FieldMeaning
actionThe exact event type this definition declares.
descriptionFree-text note about the action.
allowed_target_typesTarget types the action may act on; empty means any.
is_activeWhether the definition enforces anything. An inactive definition is not matched at ingest.
created_atWhen the definition was created.
updated_atWhen it last changed.
curl -sS "https://api.santati.io/api/v0/event-definitions/?limit=100" \
-H "Authorization: Api-Key $SANTATI_API_KEY"
{
"next": null,
"previous": null,
"results": [
{
"action": "invoice.voided",
"description": "An invoice was voided before payment.",
"allowed_target_types": ["invoice"],
"is_active": true,
"created_at": "2026-09-12T08:41:02.771004Z",
"updated_at": "2026-09-30T11:07:55.318762Z"
}
]
}

Definitions and their schema versions are managed in the app, on the team's Actions & Schemas tab (team admins), and over the API with a manage key that is not limited to named trails. Every operation below needs that key; reads accept any scope.

Manage definitions​

OperationRequest
Define an actionPOST /api/v0/event-definitions/
RetrieveGET /api/v0/event-definitions/{action}/
Update or renamePATCH /api/v0/event-definitions/{action}/
DeleteDELETE /api/v0/event-definitions/{action}/

PATCH changes only the fields you send. Sending a new action renames the definition, and its schema versions go with it; events already stored keep the name they were written with. An action that is already defined, reserved or malformed answers 400 with the message under action. A delete removes every schema version too, and deleting your last definition turns enforcement off.

Manage schema versions​

OperationRequest
ListGET /api/v0/event-definitions/{action}/schema-versions/
Create a draftPOST /api/v0/event-definitions/{action}/schema-versions/
RetrieveGET .../schema-versions/{version}/
Replace a draft's documentPUT .../schema-versions/{version}/
Delete a draftDELETE .../schema-versions/{version}/
PublishPOST .../schema-versions/{version}/publish/
DeprecatePOST .../schema-versions/{version}/deprecate/
Check a documentPOST .../schema-versions/check/

A version carries status (draft, published or deprecated) and its whole JSON Schema in schema. Fields are added, renamed and removed by editing that document: read the draft, change properties and required, and PUT the whole document back.

Every single-version response carries an ETag. Send it back as If-Match on the PUT and a draft that changed in between answers 412 instead of being overwritten; without the header the last write wins. A published version cannot be changed or deleted (409): create a new draft with your edit applied, then publish it. The check endpoint runs a document against your newest 50 stored events and stores nothing, so you can see what a change would reject before you publish it.

The ETag header arrives quoted; send it back unchanged as If-Match, quotes included.

curl -sS -X PUT "https://api.santati.io/api/v0/event-definitions/invoice.voided/schema-versions/2/" \
-H "Authorization: Api-Key $SANTATI_API_KEY" \
-H "If-Match: $ETAG" \
-H "Content-Type: application/json" \
-d '{"schema": {"type": "object", "properties": {"metadata": {"type": "object", "properties": {"invoice_number": {"type": "string"}}, "required": ["invoice_number"]}}}}'

To install the standard actions over the API, POST /api/v0/standard-events/install/ with {"packs": ["agents"]} (reference). Installing twice is safe: actions you already define are skipped.