Sending a key
Pass the key in theIdempotency-Key header:
Keys are up to 255 characters and scoped to your account, so two accounts can use the same key without colliding.
How Infinity processes a key
When a request with a new key arrives, Infinity records the key with a fingerprint of the request body, performs the work, and saves the response’s status code and body against the key for 24 hours. What happens to a later request with the same key depends on its state:
Responses are saved for client errors as well as successes. A request that failed with
400 insufficient_funds returns the same 400 on retry, even after you’ve funded the wallet, because the retry is a replay, not a new attempt. Server errors are the exception: if the first attempt fails with a 5xx, its record is discarded so that a retry with the same key runs the work again. A 5xx attempt never leaves partial state behind.
Choosing keys
Generate the key once per intended operation, before the first attempt, and reuse it for every retry of that operation.- A business identifier works well when one exists:
inv-1042for paying invoice 1042,payroll-2026-10for October’s payroll run. It survives process restarts, so a retry from a different worker still deduplicates. - A V4 UUID works when there’s no natural identifier. Persist it with the pending operation so retries reuse it.
- Don’t put personal data, such as email addresses, in keys.
inv-1042-attempt-2 after fixing the request that returned 400.
Retry strategy
- Retry on timeouts, connection errors,
429,5xxand409 idempotency_key_in_use, with the same key and the same body. - Back off exponentially with jitter (for example 1 s, 2 s, 4 s, 8 s), honouring
Retry-Afterwhen it’s present. - Stop on any
2xx, and on any other4xx; those are final answers. - If you exhaust your retries, look the payout up with
GET /payoutsbefore you consider sending it again under a new key.