> ## Documentation Index
> Fetch the complete documentation index at: https://kb.paymentsmojo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Safe retries

> Retry creating an invoice without creating it twice.

A request can time out after Mojo Payments has done it. Retrying blindly could then create the same invoice twice, and
email your customer twice.

To make `POST /payment-requests` safe to retry, send an **`Idempotency-Key`** header: any string up to 100 characters
that is unique to that invoice in your system, such as its own id.

```bash theme={null}
curl https://api.paymentsmojo.com/payment-requests \
  -H "Authorization: Bearer eyJ…" \
  -H "Idempotency-Key: inv-2026-1042" \
  -H "Content-Type: application/json" \
  -d '{ "merchantAccountId": "4d2a9c71-…", "invoiceNumber": "1042", "amount": 50.00, "customerEmail": "ap@buyer.example", "customerCompany": "Buyer Industries" }'
```

* The **first** request creates the invoice: `201 Created`.
* A **repeat** with the same key returns that same invoice, with `200 OK`, and sends nothing again.
* Keys are kept for good, per organization: use a new key for each new invoice.

Reading (`GET`) is always safe to retry. Sending (`POST /payment-requests/{id}/send`) sends again each time it's
called, so retry it only when you know the first call failed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.