POST /v1/events:bulk with the TypeScript
SDK. The same pattern works for a nightly import from a door system or a training app.
Set up the location and its equipment first
A visit names a location by itsexternal_id, so the location must exist before its history
arrives. PUT creates it or updates it in place, and the equipment calls replace the whole
list each time, so a rerun leaves the same state.
locations:write for these calls and events:write for the history.
Key every event by what it is
Give each event a key built from the teammate and the thing it records, never a random one. A visit is keyed by the teammate and the day; a set by the teammate, the day and the set. Run the import again and every event answersduplicate, so nothing is stored twice.
atis an RFC 3339 time with an offset. Work it out from the location’s own time zone, so a 7 o’clock visit counts at 7 o’clock there.locationis theexternal_idof one of your locations. See Locations and equipment.- A logged set is keyed by its
source.routeandsource.record_idinstead of an idempotency key. See Sending events.
Send it and read the results
sendBulk checks every event first, then splits the list into requests within the count and
size limits. Each event gets its own result.
accepted for each event. A second run with the same history answers
duplicate for each one. A rejected event carries its reason, such as unknown_location
or consent_required; fix it and send that event again with the same key.