Idempotency
Requests
Section titled “Requests”orderId is the idempotency key when you create invoices, standalone deposits, and withdrawal quotes. Generate it in your system so it identifies your own object, such as an order number, payment attempt, or withdrawal request. A request with an orderId that was already used never creates a second object.
| Operation | Repeat with the same orderId |
|---|---|
POST /invoice | Returns 409 Conflict |
POST /deposit | Returns 409 Conflict |
POST /withdrawal/quote | Returns the same quote. After that quote is committed, returns 409 Conflict |
Invoice orderId values must be unique across your organization; deposit and withdrawal values must be unique per account. orderId is not an idempotency key for other endpoints.
Retrying safely
Section titled “Retrying safely”Use a new orderId for each new invoice, deposit, or withdrawal. Reuse it only when retrying after a timeout or an uncertain response:
- Invoices and deposits. If the retry returns
409, the first request succeeded. Fetch the object byorderId, for exampleGET /invoice?orderId=…, instead of creating a new one. - Withdrawals. Repeat the quote with the same
orderIduntil you get aquoteId, then commit it once. A singleorderIdcan back at most one committed withdrawal.
Webhooks
Section titled “Webhooks”Duplicate events and replay protection
Section titled “Duplicate events and replay protection”The webhook signature proves the body was signed with your signing key, but it doesn’t stop replays: someone who captures a valid request could send it again. Make your handler idempotent and do at least one of the following:
- Reject old events. Compare the signed
timestampfield in the body with your clock, for example rejecting events older than 5 minutes. Don’t use thex-webhook-timestampheader for this, because it isn’t signed. - Deduplicate deliveries by the
x-webhook-idheader. Retries and manual resends of one delivery always carry the same id, so store the ids you have processed and skip repeats. - Deduplicate status transitions. Two different deliveries can still describe the same transition, for example if a status event is emitted twice. Use the event name, the resource id, and the status as a key, such as
invoice.statusChanged+data.id+data.status.
If you have already processed the transition, return 200 OK and don’t repeat the action.