Skip to content

Idempotency

Networks fail. If a POST times out, you can’t tell whether Fleet created the object. An idempotency key makes the retry safe: send the same Idempotency-Key header with the same request, and Fleet runs it at most once.

Terminal window
curl https://api.get-fleet.com/v1/fuel_logs \
-H "Authorization: Bearer $FLEET_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 9d6a1c2e-6a0b-4b5e-8f1e-2c7d3b9a4e10" \
-d '{"vehicle_id": "6f1c…", "date": "2026-11-01", "quantity": 45.2, "unit_price": 196.5}'

How it works:

  • Keys are per API key and last 24 hours. Generate a new one (a UUID is ideal) for each distinct operation, and reuse it only to retry that operation.
  • A retry with the same key and the same request returns the original response, with Idempotent-Replayed: true. Nothing runs twice.
  • The same key with a different body or path is refused: 422 idempotency_key_reused.
  • If the first request is still running, the retry gets 409 idempotency_request_in_progress. Wait and retry.
  • Server errors (5xx), rate limits (429) and conflicts (409) are not stored, so retrying them really retries.

Idempotency keys work on POST, PATCH and DELETE. GET is always safe to repeat.

Some resources also deduplicate on your own identifiers, which protects you even across days:

  • Meter entries: send external_id (for example your telematics event id). Sending the same external_id again returns the existing entry.
  • Fuel logs: filter by receipt_number before importing to skip transactions you already sent.