Pagination, retries and idempotency

Walk long lists, retry failed requests, and never create a tracking twice.

Embed
Preview of the card
<a href="https://trackified.net/docs/pagination-retries-idempotency"><img src="https://trackified.net/docs/_api/public/orgs/e2a7773e-db9e-41cb-bd59-bd248745cac3/spaces/9d63a5d4-feb0-4803-84a5-dc68639362a6/pages/c699241c-7406-4b39-864d-2491b737b6ef/social-card.svg?v=3e7ae33eec8b" alt="Pagination, retries and idempotency" width="600" height="315"></a>

Pagination

List endpoints take limit (default 50, at most 100) and offset (default 0). The response has the page in data and the totals in pagination:

{
  "data": [{ "id": "trk_...", "status": "in_transit" }],
  "pagination": { "limit": 50, "offset": 0, "total": 1234 }
}

To get the next page, add the number of items you received to offset. Stop when a page comes back empty or offset reaches total.

Each library can walk every page for you:

curl "https://api.trackified.net/v1/trackings?status=delivered&limit=100&offset=100" \
  -H "Authorization: Bearer $TRACKIFIED_API_KEY"

The TypeScript and Python helpers fetch 100 items per page. Go, Ruby and PHP use the limit you pass, or the server default of 50. Lists of trackings are newest first, so trackings added while you walk the list can shift later pages. Filter by status, carrier, custom_id or tracking_number to keep the list short.

Retries

The libraries retry a request that fails with a network error, 408, 429 or any 5xx. They wait about 0.5 seconds, then 1, then 2, doubling up to 8 seconds, with random jitter. On 429 they wait for the Retry-After header instead. Other 4xx errors are never retried.

The default is 2 retries, so 3 attempts in all. Change it with the client option (maxRetries, max_retries, WithMaxRetries). See each library page for the exact option.

If you call the API yourself, follow the same rules: retry network errors, 429 and 5xx with backoff, and honour Retry-After.

A timeout doesn't tell you whether the request went through. Treat its outcome as unknown, and only retry a create with the same Idempotency-Key.

To see every attempt, including retries, pass the onRequest and onResponse hooks (0.2 and later). They get the attempt number, status, request_id, duration, and whether a create was a replay.

Idempotency

POST /v1/trackings accepts an Idempotency-Key header: a UUID, or your own unique reference such as an order id. For 24 hours, a request with the same key and the same body returns the tracking the first request created, with 201 and Idempotent-Replayed: true, instead of adding a second one.

curl -X POST https://api.trackified.net/v1/trackings \
  -H "Authorization: Bearer $TRACKIFIED_API_KEY" \
  -H "Idempotency-Key: order_1042" \
  -H "Content-Type: application/json" \
  -d '{"tracking_number": "1Z999AA10123456784", "custom_id": "order_1042"}'

Response

Meaning

201 with Idempotent-Replayed: true

A replay. You get the original tracking.

409 idempotency_in_progress

The first request with this key is still running. Retry in a few seconds.

422 idempotency_key_reused

The key was used with a different body.

409 idempotency_key_reused

The tracking the key created has since been stopped.

A create that's refused (a bad body, an unsupported carrier, no quota left) frees the key, so you can fix the request and retry with the same key.

The libraries send a random key with every trackings.create call and reuse it across that call's retries. Pass your own key to make retries safe across process restarts too:

await client.trackings.create(
  { tracking_number: "1Z999AA10123456784", custom_id: "order_1042" },
  { idempotencyKey: "order_1042" },
);

Bulk creates are not idempotent

POST /v1/trackings/bulk ignores Idempotency-Key. Retrying a bulk request that timed out can add the same parcels twice. Before you resend, look up what landed with GET /v1/trackings?custom_id=… or ?tracking_number=…. The bulk import guide shows the full pattern.

Without a key, find what a timed-out create made by your own reference: GET /v1/trackings?custom_id=order_1042.

Updated