iBOX API

Building reliably

Idempotency

Retry a booking safely: the same key always gives back the same parcel.

A booking puts a real parcel into the network: a label, a courier, a compartment. If a request times out you cannot tell whether it was booked, so send an Idempotency-Key with every POST /v1/shipments and retry with the same key.

bash
curl -X POST https://api.iboxdelivery.com/v1/shipments \
  -H "Authorization: Bearer $IBOX_API_KEY" \
  -H "Idempotency-Key: order-5501" \
  -H "Content-Type: application/json" \
  -d @shipment.json
  • Same key, same body: you get the original response again, with the header Idempotency-Replayed: true. No second parcel.
  • Same key, different body: refused with 422 and code: "idempotency_key_reused", so a key can never hand back the parcel for a different order.
  • Keys are yours alone: another merchant using the same key does not collide with you.
  • Up to 255 characters. Your own order number makes a good key; a random UUID per order works too.
  • Only a successful booking is remembered. A request that failed validation can be fixed and sent again under the same key.