Errors and recovery
Every integration encounters errors, from a missing field to a network connection that drops at the wrong moment. What matters is recovering from them safely, without charging a customer twice, losing a payment or leaving your records out of step with Mitu. This page explains how errors are reported and the practices that keep recovery reliable.
How errors are reported
The Mitu API reports each error with a standard HTTP status and a JSON body that explains what went wrong.
When a request fails validation on several fields, message is a list with one entry for each problem.
Recovering safely
Retry creations with an idempotency key
When a request that creates something times out, you cannot tell whether it succeeded. Send an Idempotency-Key header with every request that creates a resource, and retry with the same key, so a retry returns the original result instead of creating a second payment link or invoice.
Never charge twice for undelivered work
A payment can complete even if your API then fails to perform the work. Treat payment and fulfilment as separate states, and if fulfilment fails after payment, complete the work later or refund the payer, but never ask them to pay again.
Rely on events, not on redirects
A browser can close and an agent can lose its connection after paying. Determine that a payment is complete from the notification sent through events, or by retrieving the resource through the API, never from what the payer’s browser or agent reports.
Recover missed events
If your endpoint was unavailable, Mitu continues to retry each event, and any event that was still missed can be resent from Logs. Delivery and retries describes the schedule.
Error handling practices
- Log the full error response
Record the status and message of every error, so failures can be diagnosed without reproducing them. - Distinguish errors you can retry
Retry only temporary failures, such as a 429 or a 5xx status, and correct the request for every other error. - Alert on patterns, not single failures
Monitor the rate of errors over time, so that a genuine problem is noticed quickly without alerting on every isolated failure.
Handled in this way, errors become routine events your integration absorbs, rather than incidents that disrupt your customers or your records.