Skip to content

Build and operate

Idempotency and external references

Make payment, transfer, bulk payout and invoice requests safe to retry with the Idempotency-Key header and durable external references.

Send an Idempotency-Key

Add an Idempotency-Key request header (1 to 128 printable characters) to the requests that move money: Mobile Money Collection, Initiate Transfer, Create bulk payout and Create invoice. Use a value that identifies the business action, such as payout-77, or a random UUID you store with the order.

The first request runs normally and its final response is stored for 24 hours. Repeat the request with the same key and the same body and you get that stored response back, with "replayed": true added to its meta object (meta.replayed) and no second operation. The same key with a different body returns IDEM01 (HTTP 409 in strict mode). While the first request is still running a repeat returns IDEM02: wait a moment and send it again.

Without the header nothing changes: the external reference rules below still apply.

CodeMeaning
IDEM01The Idempotency-Key was reused with a different request. Use a new key for a new request.
IDEM02A request with this key is still being processed. Wait, then resend the identical request.
IDEM03The key is empty, longer than 128 characters or contains control characters.

curl https://api.moolre.com/open/transact/transfer \  -H "Content-Type: application/json" \  -H "X-API-USER: $MOOLRE_USER" -H "X-API-KEY: $MOOLRE_KEY" \  -H "Idempotency-Key: payout-77" \  -d '{"type":1,"channel":"MTN","currency":"GHS","amount":"25.00","receiver":"0240000001","externalref":"PAYOUT-77","accountnumber":"1000000000001"}'

Use one durable reference per business action

Create an external reference before you make a payment or transfer request. Store it alongside the business record and reuse it when you retry the same action after a timeout or uncertain response.

Do not generate a new reference after a network failure. A new reference can turn a retry into a second financial instruction.

Reconcile uncertain outcomes

When a request times out, keep the operation pending and check its status or wait for the related callback. Mark it complete only when the final state is confirmed.

Keep references unique

External references should be unique within your integration and meaningful enough to trace back to your own order, invoice, or transfer record.