Menu

Idempotency

A network can fail after Nepzio has done what you asked but before you get the answer. To retry safely, send an Idempotency-Key header with any POST:

curl https://api.nepzio.com/v1/inventory/adjust \
  -H "Authorization: Bearer $NEPZIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2a9e-3b7d-4c55-9a2e-1d8f0b7e4c21" \
  -d '{"sku": "PSH-RED", "delta": 10, "reason": "Received from supplier"}'

How it works:

  • The first request with a key does the work, and its answer is kept for 24 hours.
  • A retry with the same key and the same request gets that answer again, with the header Idempotent-Replayed: true. The work is not done twice.
  • The same key with a different request gets 422 idempotency_key_reused.
  • While the first is still running, a retry gets 409 idempotency_key_in_use. Wait and retry.
  • Errors worth retrying (429 and 5xx) aren't kept, so a retry runs again.

Keys are per API key, up to 255 characters. Use a new random value (a UUID) for each distinct request, and the same value only when retrying that request.

GET requests don't need a key: reading twice changes nothing. A PATCH sets values, so repeating it is harmless too.