# Retry freely. Pay once.

> Send an Idempotency-Key header on any Dizo POST. Retries with the same key within 24 hours are never charged twice, so timeouts stop costing you.

Networks drop, agents loop and jobs restart. Put an `Idempotency-Key` header on every POST and a retry within 24 hours is never charged twice.

## Highlights
- **One header.** Add an `Idempotency-Key` header with your own id to any POST request. No other change.
- **24-hour window.** Retries that reuse a key within 24 hours are never charged twice.
- **Built for agents.** Models repeat tool calls. The key turns a repeat into a free no-op on billing.
- **Pairs with retry hints.** Errors tell you `retryable` and `retry_after`, so you know when a retry is safe.
- **Works on batch and lists.** Protects large async submissions as well as single lookups.
- **Free.** There is no charge for sending the header.

## Steps
1. **Generate a key per operation** — One unique id for each logical request, such as a UUID or your record id.
2. **Send it on the POST** — Add the `Idempotency-Key` header.
3. **Retry with the same key** — On a timeout or a retryable error, resend the identical request and header.
4. **Use a new key for new work** — Different records or a different request means a fresh key.

## APIs used
| API | Endpoint | Credits | Charged | Reference |
|---|---|---|---|---|
| Email finder | `POST /v1/email/find` | 1 credit | Only if found | [docs](https://dizo.ai/docs/email-find.md) |
| Phone finder | `POST /v1/phone/find` | 10 credits | Only if found | [docs](https://dizo.ai/docs/phone-find.md) |
| Batch | `POST /v1/batch` | Same as each item | Per item, same rules | [docs](https://dizo.ai/docs/batch.md) |
| Lists | `POST /v1/lists` | Search + lookup rates | Per row, only data found | [docs](https://dizo.ai/docs/lists.md) |


## The double-charge problem

Every API client eventually meets the same situation. You send a request, the connection times out, and you do not know whether the server processed it. If you retry and it had succeeded, you may have done the work twice. For a free endpoint that is harmless. For a paid lookup it means paying twice for one answer, and for a phone lookup at 10 credits, or a batch of thousands of items, that adds up quickly.

Agents make it worse. A language model in a tool-calling loop will sometimes call the same tool again with the same arguments, because a response was slow, because it lost track of what it already did, or because a framework retried on its behalf. Workflow tools retry failed steps automatically. A cron job that crashes halfway may rerun from the top.

Dizo solves this with an `Idempotency-Key` header. Send one on every POST, reuse it when you retry, and retries within 24 hours are never charged twice.

## How it works

An idempotency key is an identifier you choose for a single logical operation. You put it in the `Idempotency-Key` HTTP header. When Dizo sees a second request with the same key inside the 24-hour window, it treats it as a retry of the first rather than as new work, and you are not billed again.

That is the whole contract, and it is deliberately simple. You do not register keys in advance, there is no extra endpoint, and the header costs nothing. The Dizo agent rules put it plainly: send an `Idempotency-Key` header on every POST; retries within 24 hours are never charged twice.

The rule covers POST requests, which is where nearly all billable Dizo calls live: search, people and company search, email and phone finder, enrich, reverse lookups, lists, monitors and batch. A couple of lookups are GETs, such as `GET /v1/companies/{domain}` and the org chart. For those, cache results on your side so you are not looking up the same domain repeatedly.

## Choosing good keys

The key must be unique per operation and stable across retries of that operation. Those two properties pull in different directions, so it helps to think about what one operation means in your system.

For a one-off call from a script, a random UUID generated just before the request is fine, as long as you keep it in a variable and reuse it on retry. Generating a new UUID inside the retry loop defeats the purpose.

For pipelines that process records, deterministic keys work better. Build the key from things that identify the work: for example the CRM record id, the endpoint and the date, such as `crm-0042-email-find-run17`. If the job crashes and restarts, it produces the same keys for the same records, so anything already charged is not charged again. Change part of the key, such as the run number, when you deliberately want fresh lookups.

- Unique per logical request: one record, one endpoint, one intent.
- Stable across retries: store it before sending, reuse it after a failure.
- Opaque to Dizo: any string you control, such as a UUID or a composite id.
- Never shared across different request bodies.

## A worked example: a flaky nightly sync

Take a hypothetical nightly job that finds mobile numbers for 400 new opportunities. Phone finder costs 10 credits per number found, and the team expects about half to have a mobile, so a normal night uses around 2,000 credits, which is $42 at the Builder rate of $0.021.

One night the job runner loses its network connection after 300 requests and restarts from the beginning. Without idempotency keys, the first 300 records are looked up again. About 150 of them had found numbers, so the rerun charges another 1,500 credits, or $31.50, for data the team already had. Over a month of occasional restarts, that waste becomes a line item.

With deterministic keys built from the opportunity id and the run date, the restarted job sends the same keys for the first 300 records. None of those retries are charged twice, and the job carries on with the remaining 100 as new work. The total for the night stays at roughly 2,000 credits.

## Retries done right

Idempotency keys make retries safe. They do not tell you when to retry. For that, Dizo errors carry `error.retryable` and `error.retry_after`. The rule is: retry only if `retryable` is true, wait at least `retry_after` seconds, and resend the identical request with the identical key. If `retryable` is false, read `error.fix` and change something before trying again. The [error codes](/features/error-codes) page explains the fields.

Some outcomes are not errors to retry at all. A `404 not_found` from the email finder means Dizo looked and found nothing, which is free. Retrying it with the same body will not produce a different answer. A `402 monthly_cap_reached` means the account hit its spending ceiling; retrying will keep failing until a person raises the cap or the month rolls over.

For timeouts with no response, a retry with the same key is always the right move inside the 24-hour window. Either the first request never landed and this one does the work, or it did land and this one is recognised as a repeat.

## Idempotency for agents and MCP

If you build your own agent loop on the REST API, generate the key in your tool wrapper, not in the model. The model decides what to call; your code attaches a key derived from the arguments and the task id. If the model calls `email/find` twice with the same person and company within the same task, the wrapper produces the same key and the second call is not billed again.

This keeps the protection where it is reliable. Asking a model to invent and remember idempotency keys adds a failure mode for no benefit. A small helper that hashes the endpoint, the normalised body and a task id is enough.

Frameworks such as [LangChain](/integrations/langchain) let you wrap HTTP tools in your own functions, which is the natural place for this helper. When you connect over the [MCP server](/mcp), keep your other controls in place too: `max_credits` on each call and per-key caps still bound what any loop can spend.

## Batch, lists and webhooks

Large submissions are where a double charge hurts most. A `POST /v1/batch` can carry up to 10,000 items, and a list job can enrich thousands of rows. Put an idempotency key on those submissions so that a client that times out while submitting can resubmit safely. Then track the job by its id through `GET /v1/batch/{id}`, which is free, rather than submitting again.

Inside a batch, each item is charged like the underlying endpoint, and misses are still free. Combine that with a `dry_run` quote before submission and `max_credits` as a ceiling, and a large job has three separate protections: you know the cost, you cannot exceed it, and you cannot accidentally pay for it twice. See [batch](/docs/batch) for the parameters.

Webhooks work in the other direction. Dizo retries deliveries with backoff for 24 hours, so your handler may see the same event more than once. Make your handler idempotent too, for example by recording which events you have already processed.

## Edge cases and limits

The window is 24 hours. A request with a reused key after that is treated as new and charged normally. For daily jobs, include the date in deterministic keys so each day is deliberately fresh.

Keep each key tied to one request body. If you change the body, for example adding `"include": ["phone"]` to a search that previously asked only for email, use a new key. Reusing a key for different work makes your own logs ambiguous even when billing is unaffected.

Idempotency protects billing, not data freshness. If you want an updated email for someone you looked up last week, that is new work with a new key. And idempotency is not a cache for reads: store the results you get back so you do not need to ask again.

Finally, log the key alongside the `x-dizo-request-id` header and the `x-dizo-credits-used` value from each response. When someone asks why a job cost what it did, those three values let you match every charge to the record and the attempt that caused it, and they give you the request id you need if a result later turns out to be wrong and you report it through `POST /v1/feedback`.

## FAQ

### What does the Idempotency-Key header do?
It marks a POST request as one logical operation. Retries that reuse the same key within 24 hours are never charged twice.

### How long does the protection last?
24 hours. A request with the same key after that is treated as new work.

### Which requests should carry a key?
Every POST. That covers search, lookups, enrich, lists, monitors and batch. For GET lookups such as domain to company, cache the results on your side.

### What should I use as the key?
Any string unique to the operation and stable across its retries: a UUID stored before sending, or a composite of record id, endpoint and run date for pipelines.

### Should I retry every error with the same key?
No. Retry only when `error.retryable` is true, after `error.retry_after` seconds. A `404 not_found` is a free miss and a `402 monthly_cap_reached` needs a human.

### Does the header cost anything?
No. Sending an idempotency key is free.
