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
| Limit | Value | Exceeding it |
|---|---|---|
| Events per request | 500 (MAX_EVENTS_PER_BATCH) | 413 with code payload_too_large, field events |
| Request body | 1 MiB (MAX_BODY_BYTES, 1,048,576 bytes) | 413 with code payload_too_large, field null |
| Events per request (minimum) | 1 | 400 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
| Status | When | Body |
|---|---|---|
202 Accepted | Every submitted event was accepted (or replayed as a duplicate) | The results object |
207 Multi-Status | At least one submitted event was rejected | The results object |
413 Request Entity Too Large | The batch or the body is over a limit | The error envelope |
400 Bad Request | The wrapper itself is malformed | The error envelope |
403 Forbidden | The key may not emit at all (a read-scope key) | The error envelope |
429 Too Many Requests | A team ceiling was hit | The 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"}
]
}
resultsalways holds exactly one entry per submitted event, in submitted order, withindexmatching the position in theeventsarray. A rejected entry never shifts the indexes of the entries after it.statusisaccepted,duplicateorrejected. Aduplicateentry replays an event that the same idempotency key already produced (see Idempotency); it counts towardaccepted.- An accepted or duplicate entry carries the event's
id; a rejected entry carrieserrorwith the samecode,messageandfieldshape as the single-event error envelope. See Errors for the reserved codes. Note that a per-event problem — including atrailthe key is not scoped to (trail_not_allowed) — is reported here as a rejected item inside a207, not as a403for the whole request. acceptedcounts everything that was not rejected, soacceptedplusrejectedalways 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.