Idempotency
Retry without fear. The same Idempotency-Key never collects or pays twice.
A network can drop right after you send a payout. Did it go through or not? With Idempotency-Key it doesn't matter: you resend the same request with the same key and get the original result, with no second effect.
curl https://api-sandbox.caibopay.app/v1/payouts \
-H "Authorization: Bearer $CAIBO_API_KEY" \
-H "Idempotency-Key: payout-order-5531" \
-H "Content-Type: application/json" \
-d '{ "beneficiary_id": "ben_...", "quote_id": "quo_..." }'How it behaves
| You send | You receive |
|---|---|
| A new key | 201 and the created resource. |
| The same key with the same request | 200, the same resource in its current state, and the Idempotent-Replayed: true header. Nothing is repeated. |
| The same key with a different request | 409 idempotency_key_reused. |
| No key, where it's required | 400 idempotency_key_required. |
If two requests with the same key arrive at the same time, the second waits for the first and returns its result.
Where it's required
On every create call that moves money or locks in a price:
POST/v1/customers POST/v1/quotes POST/v1/payouts POST/v1/payouts/{id}/cancel POST/v1/payout-batches POST/v1/withdrawals POST/v1/remittances POST/v1/funding-accounts POST/v1/refunds POST/v1/hosted-sessionsAll other operations ignore the header. Registering the same beneficiary or the same destination account twice already returns the existing record.
Best practices
- One key per business operation, derived from your own identifier:
payout-order-5531,payin-invoice-F-2201. That way a retry, even days later or from another process, uses the same one. - Between 8 and 128 characters from
A-Z a-z 0-9 . _ : -. - Keys don't expire. A used key stays bound to its original request forever.
- A rejected request (
4xx) doesn't consume the key: fix it and resend with the same one. - On
500or503, retry with the same key.
A payout without funds does consume its key
If your balance isn't enough, POST /v1/payouts responds 201 with status: failed and failure_code: insufficient_funds. That payout exists and its key has been used. To retry once you have funds, use a new key (and a new quote if you used one).