Daily history sync
A nightly job that copies every finished tracking item of an organization into your own storage - for reporting, billing reconciliation or archiving. History keeps finished tracking items for a limited time only, so sync what you need regularly.
How the window works
GET /get-all-tracking-items?type=history returns tracking items with status done (or doneEld for
ELD and Hybrid) whose expiration date is inside fromDate < expDate <= toDate,
oldest first, in pages of up to 500.
Pending installation tracking items the driver never accepted are billed but never appear in history.
A tracking stopped early with stop-tracking keeps its original expDate, which can be days in the
future. To catch those too, do not set toDate - and upsert by trackingId, so a tracking seen twice
is simply overwritten.
The job
- Read the watermark the previous run saved (start with 7 days ago).
- Request pages with
fromDate= watermark and notoDate, followingpagination.nextCursoruntil it isnull. - Upsert every item by
trackingId. - Save the new watermark as the start of this run minus a safety overlap (for example 3 days), so tracking items that finished late are picked up again.
Code
Getting more detail
List items are slim, and history items have driverCoords: null (a position is published only while
a tracking is live). For each new tracking you need in full (email settings, driver files), call
GET /get-tracking - pace these calls (for example 5 per second) rather than firing them all at once.
A location sample about every 15 minutes while the driver moved is available with GET /get-reports.
Notes
- Keep the same
fromDate/toDatefor every page of one run. The cursor is only valid for the window it was issued for. - Retry a failed page with the same cursor - it is safe.
- Test keys return a single page of at most
limititems (default 100), andnextCursoris alwaysnull. - History keeps finished tracking items for a limited time only - run the sync regularly and do not pause it for long.

