> This page is for version Preview.
> For other versions, use one of these documentation indexes:
> - Current (default): https://docs.paid.ai/current/llms.txt
> - Preview: https://docs.paid.ai/preview/llms.txt

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

# Idempotency

> Retry POST and PATCH requests safely with an Idempotency-Key.

A network error or timeout can leave you unsure whether a request reached Paid. Send an `Idempotency-Key` header on `POST` and `PATCH` requests and you can retry them without creating a second customer, order or credit grant: Paid runs the request once and returns the same response to every retry.

## Sending a key \[#sending-a-key]

Generate a unique key for each operation, such as a UUID, and send it in the `Idempotency-Key` header. Keep the key with the operation so a retry sends the same one.

```bash
curl https://api.paid.ai/v1/customers \
  -X POST \
  -H "Authorization: Bearer $PAID_API_KEY" \
  -H "Idempotency-Key: 5f0c7a2e-8d4b-4c1e-9a3f-2b6d8e1f4a70" \
  -H "Content-Type: application/json" \
  -d '{"name": "Acme Inc"}'
```

A key is 1 to 255 printable ASCII characters with no spaces. Any other value returns `400` with the [`invalid_idempotency_key`](/preview/developers/api/errors#invalid_idempotency_key) code.

The header is optional, and Paid ignores it on `GET` and `DELETE`, which are already safe to repeat.

## Retrying a request \[#retrying-a-request]

When a request arrives with a key Paid has already seen, the result depends on the first request:

| First request                           | Retry with the same key and body                                                                                                                                     |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Finished with a `2xx` or `4xx` response | Returns that stored response, with the `Idempotent-Replayed: true` header. The operation does not run again.                                                         |
| Still running                           | Returns `409` with the [`idempotency_request_in_progress`](/preview/developers/api/errors#idempotency_request_in_progress) code. Wait, then retry with the same key. |
| Failed with a `5xx` or `429` response   | Runs the request again, as if the key were new.                                                                                                                      |

A replay returns the original status code, body and `Paid-Version`, even if your account's default version has changed since.

Validation errors are stored like any other response, so fixing the request body means sending a new key.

## Reusing a key \[#reusing-a-key]

A key belongs to one request. Sending it with a different method, path or body returns `409` with the [`idempotency_key_reused`](/preview/developers/api/errors#idempotency_key_reused) code, and the new request does not run.

Keys are scoped to your organization, so two organizations can use the same key without colliding.

## Key expiry \[#key-expiry]

Paid keeps a key and its response for 24 hours from the first request. After that the key is forgotten, and a request that sends it runs as new. Retry within that window.