> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mitu.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mitu.ai/_mcp/server.

# 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.

```json
{
  "statusCode": 400,
  "message": "Send exactly one of recipientId or recipient",
  "error": "Bad Request"
}
```

When a request fails validation on several fields, `message` is a list with one entry for each problem.

| Status | Meaning                                                                                                                              | Recommended action                                                |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- |
| 400    | The request is invalid.                                                                                                              | Correct the request using the message. Do not retry it unchanged. |
| 401    | The API key is missing or invalid.                                                                                                   | Check the key and the environment it belongs to.                  |
| 404    | The resource does not exist.                                                                                                         | Check the identifier and the environment in which it was created. |
| 409    | The request conflicts with the current state, such as cancelling a paid invoice or reusing an idempotency key with a different body. | Retrieve the resource to see its current state.                   |
| 410    | The resource is no longer available, such as a cancelled invoice.                                                                    | Create a new one if it is still needed.                           |
| 429    | Too many requests.                                                                                                                   | Wait, then retry with increasing delays.                          |
| 5xx    | A temporary problem on the Mitu side.                                                                                                | Retry with increasing delays, using the same idempotency key.     |

## 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](/platform/webhooks/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](/platform/webhooks/delivery-and-retries) describes the schedule.

## Error handling practices

1. **Log the full error response**\
   Record the status and message of every error, so failures can be diagnosed without reproducing them.
2. **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.
3. **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.