POST times out you can’t tell whether it ran. Send an Idempotency-Key header and you can retry it without starting a second top-up or paying an invoice twice.
topup-2026-10-week-42.
Which requests use it
Without the header, a required endpoint returns
400 idempotency_key_required. PUT replaces the whole set it targets, so repeating it is already safe.
How it works
Keys are scoped to your API key: two different API keys can use the sameIdempotency-Key without colliding.
- First request. ChargeExpress records the key with a hash of the method, path and JSON body, runs the request, and stores the response.
- Same key, same request. You get the stored status code and body again, with the header
Idempotent-Replayed: true. Nothing runs a second time. TheX-Request-Idheader is new on each call. - Same key, different request. If the method, path or body differ, you get
422 idempotency_key_reused. Use a new key. - Same key while the first is still running. You get
409 idempotency_key_in_progress. Wait a moment and retry with the same key.
What is stored, and for how long
- Responses with a status below 500 are stored for 24 hours, apart from
429. That includes4xxerrors: retrying a request that failed validation with the same key returns the same error. Fix the request and use a new key. 5xxand429responses are not stored. The key is released, so retrying with the same key runs the request again.- If the connection drops before a response is produced, the key is also released.
- After 24 hours the key can be used again as if it were new.
Top-ups and the idempotency key
ForPOST /wallet/fundings and POST /invoices/usage/pay, the Idempotency-Key also determines the funding’s id (wallet-…). This protects against double payment even after the 24-hour window:
- Sending the same key again for a funding that is still
pendingreturns that same funding and itscheckout_url. - Sending the same key again for a funding that has completed or failed returns
409 conflict. - Sending the same key with a different amount returns
422 idempotency_key_reusedwithin 24 hours, and409 conflictafter that.
Recommendations
- Generate the key before the first attempt and persist it with the operation, so a restarted worker retries with the same key.
- Retry network errors,
409 idempotency_key_in_progress,429and5xxwith exponential backoff, keeping the same key. - Don’t reuse keys across different operations.

