Developers · Idempotency

Idempotency

Network calls fail and clients retry. Idempotency keys make it safe to retry a payment request without ever charging or transferring twice.

How it works

Every payment-creating request (payments, transfers, payouts, deposits, quotes) requires an Idempotency-Key header. Generate a unique key per logical operation — a UUID v4 works well — and reuse the exact same key when retrying that operation. The backend, not the frontend, is the source of truth for whether a payment already succeeded.

Example

curl https://sandbox.amnenpay.com/v1/payments \
  -X POST \
  -H "Authorization: Bearer sk_test_51H8xExampleSandboxKeyOnly" \
  -H "Idempotency-Key: idmp_8f14e45fceea167a5a36dedd4bea2543" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 2500, "currency": "ETB", "recipient": "rcp_9x8y7z" }'

Behaviour

ScenarioResult
First requestProcessed normally. The result is stored against the key.
Retry, same key + same bodyThe original stored response is replayed. No duplicate payment is created.
Retry, same key + different bodyRejected with 409 conflict — a key cannot be reused for a different request.
Key expiryKeys are retained for 24 hours, after which they may be reused.