# Event Data

# Event Data

`GET /external/api/v1/event-data` returns every raw telemetry event for your account in a
time window, with all of FleetTrack's event fields. See the
[API Reference](/api/event-data) for every parameter and field.

## A first request

```bash
curl --compressed -H "Authorization: Bearer $FLEETTRACK_API_KEY" \
  "https://api.fleettrack.com/external/api/v1/event-data?account_id=YOUR_ACCOUNT&from=2026-09-01T00:00:00Z&to=2026-09-01T23:59:59Z"
```

Add `device_id=...` to restrict the results to one vehicle.

## Paging through a window

Events come back oldest first, up to `page_size` per response (default and maximum
1000). While `next_cursor` is not `null`, request again with `cursor=<next_cursor>` and
the same other parameters, or simply follow `next`, which is that URL in full:

```python
import requests

url = "https://api.fleettrack.com/external/api/v1/event-data"
params = {"account_id": "YOUR_ACCOUNT",
          "from": "2026-09-01T00:00:00Z", "to": "2026-09-07T23:59:59Z"}
headers = {"Authorization": f"Bearer {api_key}"}

events = []
while url:
    page = requests.get(url, params=params, headers=headers, timeout=60)
    page.raise_for_status()
    body = page.json()
    events.extend(body["results"])
    url, params = body["next"], None  # `next` already carries every parameter
```

Page **sequentially**. Parallel requests for the same account are capped (see below), and
cursors are only valid in order.

## Staying complete: re-pull the last 72 hours

Events are selected by when they happened (`timestamp`), not when FleetTrack received
them (`creation_time`). A vehicle that loses coverage buffers its events and uploads them
when it reconnects, sometimes hours later, so a window you have already fetched can gain
events afterwards. Nothing reports this; the earlier pull is simply incomplete.

So on every sync, **re-pull the last 72 hours**, not just the period since your last
sync, and store each event under the key that identifies it:

`account_id` + `device_id` + `timestamp` + `status_code`

A re-pulled event then overwrites its earlier copy instead of duplicating it, and the
late arrivals fill in.

## Compression

Send `Accept-Encoding: gzip` (most HTTP clients do by default; with curl, add
`--compressed`). Each event is about 3 KB of JSON, mostly field names repeated on every
row, so compression cuts a page roughly tenfold.

## Correcting an event

When an event is wrong -- an odometer reading that went backwards, a position from a GPS
glitch -- correct it in place with `PATCH`, naming the event by its key and sending only the
fields to change:

```bash
curl -X PATCH --compressed \
  -H "Authorization: Bearer $FLEETTRACK_WRITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"odometer_km": 48211.6}' \
  "https://api.fleettrack.com/external/api/v1/event-data/truck-12/2026-09-30T14:03:22Z/61714?account_id=YOUR_ACCOUNT"
```

The response is the event after the change, the fields that changed, and an `audit_id`.

- **It needs a write key.** Your normal key is read-only and gets `403 forbidden`. Ask
  FleetTrack for a key with the `eventdata:write` scope, and keep it apart from the read key.
- **The key fields never change.** `account_id`, `device_id`, `timestamp`, `status_code`,
  `creation_time`, `creation_millis` and `attach_data` are read-only; a body naming any of
  them is refused with `400 immutable_field` and nothing changes.
- **Every correction is recorded** with the event's previous values, so it can be reviewed
  and reversed. Quote the `audit_id` if you need one undone.
- **Reports catch up within minutes.** Trips, idle time and speeding already calculated
  from the event are recalculated automatically for the day of the event and the days either
  side, a few minutes after the correction (corrections to the same day are batched).

## Limits

| Limit | Value | When exceeded |
|---|---|---|
| Window per request | 31 days | `400 window_invalid` |
| Requests per API key | 120 per minute, Event Data and other routes combined | `429 rate_limited`, with `Retry-After` |
| Corrections (`PATCH`) per API key | 30 per minute | `429 rate_limited`, with `Retry-After` |
| Requests in flight per account | 4 | `429 too_many_concurrent_requests`, with `Retry-After` |
| Time per page | about 25 seconds | `503 query_timeout`: narrow the window, add `device_id`, or lower `page_size` |

On any `429`, wait for the `Retry-After` seconds before retrying.

## Postman

Download the [FleetTrack External API Postman collection](/FleetTrack-External-API.postman_collection.json)
and import it into Postman (**File → Import**). In the collection's **Variables** tab, set
`apiKey` and `accountId` (use the *Current value* column so your key isn't synced). Then
send **Event Data**, followed by **Event Data: next page** until the console reports the
last page.
