Skip to content

Pagination and polling

Paginated list endpoints take page and limit query parameters and return the records in data, with paging details in meta.pagination:

{
"data": [{ "id": "…" }],
"meta": {
"pagination": {
"page": 1,
"limit": 50,
"total": 132,
"totalPages": 3,
"hasNext": true,
"hasPrev": false
}
}
}
  • page starts at 1.
  • limit is the number of records per page. The default and maximum depend on the endpoint (see the table below).
  • A limit above the endpoint’s maximum is refused with 400 Bad Request and the code validation_error. It is not lowered to the maximum for you, so check your limit if you see this error.
  • Keep requesting the next page while hasNext is true.
Endpoint Default limit Maximum limit Sorting updatedAfter / updatedBefore
GET /events 50 1000 sort, dir Yes
GET /action-items 20 100 Newest created first, or fieldSort; oldest updated first when polling Yes
GET /metrics 100 1000 Always by updatedAt, oldest first Yes
GET /events/metrics/bulk 100 1000 Always by updatedAt, newest first Yes
GET /workflows 50 1000 — —
GET /workflows/{workflowId}/runs 50 1000 — —

GET /assets, GET /locations, GET /users and GET /equipment-types are not paginated: they return every matching record in data in one response.

GET /events takes sort (a field name such as eventDate, createdAt or updatedAt) and dir (asc or desc). By default events are sorted by eventDate, newest first.

To keep another system in sync, don’t re-download everything. Ask for records that changed since your last sync with updatedAfter, and save the newest updatedAt you received as the starting point for the next sync.

This works on GET /events, GET /action-items, GET /metrics and GET /events/metrics/bulk, and the two parameters mean the same on all of them:

  • updatedAfter returns records updated strictly after the time you send, and updatedBefore records updated strictly before it. A record updated exactly at either time is not included.
  • Send an ISO 8601 date and time with Z (2026-09-01T00:00:00Z) or with a timezone offset (2026-09-01T02:00:00+02:00). The API converts it to UTC. In a URL, encode + as %2B. A value that isn’t a date and time returns 400 with validation_error.
  1. On the first run, choose a starting time, for example the start of today, in ISO 8601 UTC: 2026-09-01T00:00:00Z.
  2. Request ?updatedAfter=<cursor>&page=1. When updatedAfter or updatedBefore is set, events and action items come back sorted by updatedAt, oldest first. On GET /events, send sort=updatedAt&dir=asc as well, so the order stays right if you add other options.
  3. Page through with page=2, 3, … until hasNext is false, and process each record.
  4. Once you have read the last page, save the largest updatedAt you saw as the new cursor.
  5. Wait, then repeat from step 2, sending the new cursor minus 5 minutes as updatedAfter (see Tips for reliable syncing).
Terminal window
curl "https://safe-api.safetyradar.com/v2/events?updatedAfter=2026-09-01T00:00:00Z&sort=updatedAt&dir=asc&limit=100&page=1" \
--header "Authorization: Bearer $SAFETY_RADAR_API_KEY"
  • Poll with an overlap. A change can become visible with an updatedAt slightly older than the newest one you already hold. Send updatedAfter as your saved cursor minus 5 minutes, so a late change is not missed.
  • Insert or update by id. With the overlap, records you already have come back again. Make your processing safe to repeat.
  • Only move the cursor after the last page. Several records can share the same updatedAt. Because updatedAfter is exclusive, a cursor taken from the middle of a run can skip the records on later pages that share that time.
  • Compare timestamps as UTC ISO strings as returned by the API. Strings in this format sort in time order.
  • Bulk event metrics are a time window. GET /events/metrics/bulk returns one row per event, newest first, so the last record on a page is not a cursor. Page through the whole window, then use the largest updatedAt you received as the next updatedAfter.
  • Poll at a sensible interval. Every few minutes is plenty for most integrations and stays well within the rate limit.

Version bd999fd · Released November 23, 2026