Skip to main content

Batching

POST /api/v0/events/ accepts either one envelope object or a batch:

{"events": [ { "event": "invoice.voided", "trail": "billing", "organization_id": "org_acme" } ]}

A batch is the better choice for backfills and for producers that emit several related events at once: one HTTP request, one round trip, one entry against your request ceiling.

Limits​

LimitValueExceeding it
Events per request500 (MAX_EVENTS_PER_BATCH)413 with code payload_too_large, field events
Request body1 MiB (MAX_BODY_BYTES, 1,048,576 bytes)413 with code payload_too_large, field null
Events per request (minimum)1400 with code invalid_envelope, field events

Both ceilings are checked before any row is written, so a refused batch costs nothing and writes nothing. An empty events array is refused, and so is an events value that is not an array. A batch body may not carry any sibling key next to events: an extra key returns 400 invalid_envelope with field set to that key and events set to [...] — note that a batch reports an unknown top-level key as invalid_envelope, while a single envelope reports it as unknown_field.

A batch needs an API key with the write or manage scope. See Authentication.

Responses​

StatusWhenBody
202 AcceptedEvery submitted event was accepted (or replayed as a duplicate)The results object
207 Multi-StatusAt least one submitted event was rejectedThe results object
413 Request Entity Too LargeThe batch or the body is over a limitThe error envelope
400 Bad RequestThe wrapper itself is malformedThe error envelope
403 ForbiddenThe key may not emit at all (a read-scope key)The error envelope
429 Too Many RequestsA team ceiling was hitThe error envelope; see Rate limits

The results object is the same for both success statuses:

{
"accepted": 2,
"rejected": 1,
"results": [
{"index": 0, "status": "accepted", "id": "01J9Z6K3M4QX8RT2VN5B7HCWDA"},
{"index": 1, "status": "rejected", "error": {"code": "invalid_actor_type", "message": "…", "field": "actor.type"}},
{"index": 2, "status": "accepted", "id": "01J9Z6M9QF3T1C8V0H4R5XW2NB"}
]
}
  • results always holds exactly one entry per submitted event, in submitted order, with index matching the position in the events array. A rejected entry never shifts the indexes of the entries after it.
  • status is accepted, duplicate or rejected. A duplicate entry replays an event that the same idempotency key already produced (see Idempotency); it counts toward accepted.
  • An accepted or duplicate entry carries the event's id; a rejected entry carries error with the same code, message and field shape as the single-event error envelope. See Errors for the reserved codes. Note that a per-event problem — including a trail the key is not scoped to (trail_not_allowed) — is reported here as a rejected item inside a 207, not as a 403 for the whole request.
  • accepted counts everything that was not rejected, so accepted plus rejected always equals the number of submitted events.

Example​

Three events, the middle one with an actor type the API does not accept:

curl -X POST https://api.santati.io/api/v0/events/ \
-H "Authorization: Api-Key $SANTATI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"event": "invoice.voided",
"trail": "billing",
"created_at": "2026-09-29T14:03:11.482Z",
"organization_id": "org_acme_logistics",
"actor": {"type": "user", "id": "usr_123"},
"targets": [{"type": "invoice", "id": "inv_555"}]
},
{
"event": "invoice.paid",
"trail": "billing",
"created_at": "2026-09-29T14:03:12.006Z",
"organization_id": "org_acme_logistics",
"actor": {"type": "robot", "id": "r2"}
},
{
"event": "invoice.created",
"trail": "billing",
"created_at": "2026-09-29T14:03:12.480Z",
"organization_id": "org_acme_logistics",
"actor": {"type": "system", "id": "billing-worker"}
}
]
}'

The response is 207 Multi-Status: the two good events are stored, and only the middle one is reported as rejected.

{
"accepted": 2,
"rejected": 1,
"results": [
{"index": 0, "status": "accepted", "id": "01J9Z6K3M4QX8RT2VN5B7HCWDA"},
{
"index": 1,
"status": "rejected",
"error": {
"code": "invalid_actor_type",
"message": "actor.type must be one of: user, system, agent, anonymous",
"field": "actor.type"
}
},
{"index": 2, "status": "accepted", "id": "01J9Z6M9QF3T1C8V0H4R5XW2NB"}
]
}

Retry only the rejected indexes. Give every event its own id (or its own envelope idempotency_key) before retrying: the unique (team, trail, id) constraint resolves a re-sent event back to the stored row, and its own key makes the retry a duplicate instead of a second write. Do not send one Idempotency-Key header with a multi-event batch — the first keyless event on a trail claims the key and every later one replays it, so only that first event is written while the batch still reports the rest as accepted. See Idempotency.