Idempotency Keys
Use an Idempotency-Key header when creating payments. This lets your backend retry a request after a timeout or network interruption without accidentally creating multiple payment requests for the same order.
When to use one
Send an idempotency key for every POST /v1/btc/payments request in production. Payment creation usually sits inside checkout, where retries are common and duplicate payment instructions would be confusing for customers.
Recommended key format
Use a stable value tied to your own order:
order-10042-create-payment
Do not generate a new random value for each retry. The whole point is that the retry uses the same key as the original attempt.
Backend flow
- Create or load your own order record.
- Build a stable idempotency key from that order ID.
- Call
POST /v1/btc/paymentswith theIdempotency-Keyheader. - Store the returned Manatee payment ID next to your order ID.
- On webhook delivery, use the payment ID to find the order.
Webhooks are also at-least-once
Idempotency is not only for payment creation. Webhook delivery can be repeated, so your webhook handler should also be idempotent. Store X-Event-ID and ignore events that were already processed.