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

# Retries and idempotency

> How to repeat a request after a lost answer without paying twice.

A network can drop an answer after we have already acted. These rules let you retry safely.

## Submitting a search

Every submission needs an `Idempotency-Key`: a UUID that you generate, one per search.

| You send                               | You get                                                                                  |
| -------------------------------------- | ---------------------------------------------------------------------------------------- |
| A new key                              | A new search, charged once                                                               |
| The same key and the same objective    | The same `request_id` and its current status, `202`. Nothing is charged and nothing runs |
| The same key and a different objective | `409`, code `4091`                                                                       |

A replay answers `202` for a search in any status. That includes a search that already failed: it
returns the failed search, and a new attempt needs a new key.

**If your submission times out or the connection drops, send it again with the same key.** You get
your search back, or you start it if it never arrived, and you are charged once either way.

The objective is compared after trimming. Two requests that differ only in leading or trailing
spaces count as the same objective.

## Buying results

Buying needs no key: the `request_id` is the key. Calling [Buy results](/api-reference/audience-search/buy-results)
again for the same search returns identical rows and the same `results_paid_at`, and charges nothing.
Parallel calls for one search charge exactly once.

## Which errors to retry

| Answer                                   | Retry?                                                                             |
| ---------------------------------------- | ---------------------------------------------------------------------------------- |
| `429`                                    | Yes, after `Retry-After` seconds                                                   |
| `503` with code `5030`                   | Yes, after a few seconds                                                           |
| `503` with code `5031`                   | Yes, the same request. You are not charged again                                   |
| `500`                                    | Yes, the same request. A submission with the same key is safe                      |
| `502`                                    | Yes, after a few seconds. See [Billing and refunds](/documentation/guides/billing) |
| `400`, `401`, `403`, `404`, `409`, `422` | No. Fix the cause first                                                            |