Retries and idempotency
A network can fail after ShipBill acted but before you heard back. An Idempotency-Key makes repeating a request safe: the same key never acts twice.
How it works
Send Idempotency-Key with any POST: 1 to 255 visible characters, unique to the thing you're doing — your order's ID and the step, say.
curl https://api.shipbill.io/v1/checkout/sessions \
-H "Authorization: Bearer $SHIPBILL_SECRET_KEY" \
-H "Idempotency-Key: order_1001-checkout" \
-H "Content-Type: application/json" \
-d '{ "amount": 4900, "currency": "USD", "description": "Consulting" }'- The same key and the same request within 24 hours returns the first answer, with
Idempotent-Replayed: true, instead of acting again — even when the first is still running. - The same key with a different request is refused with
idempotency_key_reused. - An error is replayed too; a request without a key always runs.
With the libraries
@shipbill/node sends a key with every POST — yours if you pass { idempotencyKey }, otherwise one it makes — and keeps it across its own retries. It retries after a network failure, a rate limit, or a server error, with backoff.
await shipbill.checkout.sessions.create(params, { idempotencyKey: `order_${order.id}-checkout` });Rate limits
A secret key may make 50 requests a second and 250 every 10 seconds. A publishable key allows each visitor 20 requests every 10 seconds. Every answer carries RateLimit-Limit, RateLimit-Remaining, and RateLimit-Reset; a 429 carries Retry-After.