# Idempotency

A retry never sends a letter twice.

Every call that makes something you could pay for (`send_letter`, `start_account`) needs an idempotency key: your own unique string, up to 255 printable characters. Over REST it is the `Idempotency-Key` header; over MCP, the `idempotency_key` argument; in the CLI, `--idempotency-key`; in the [TypeScript SDK](sdk.md), the `idempotencyKey` option.

## What we do with it

- The first call with a key does the work and stores the answer, with a hash of the parameters.
- A retry with the same key and the same parameters gets the first answer back, and nothing new happens. Over REST the answer carries `Idempotent-Replayed: true`.
- A retry with the same key and different parameters is refused `idempotency_key_reused`.
- A retry while the first call is still being worked on gets `request_in_progress` with a `retry_after`. Wait and repeat the same call.
- Keys are kept for 24 hours.

A "not yet" answer is stored too: a retry of a send that waits for approval gets the same letter and the same link, not a second letter.

`create_approval_link` takes a key too. Its answer holds a secret (the link's url), so we keep only the link's id against the key and make the url again on a retry. If the link has been used, revoked or has run out by then, the retry is refused `approval_link_gone` rather than handed a link that no longer works. See [Sending for your customers](platforms.md).

A group is one send with one key. A retry returns the same group and the same letters, however far the first call got: the group and its letters are written together or not at all. Each letter's record counts the retry. See [One letter to several people](several-recipients.md).

## Choosing keys

Make the key from what the letter is, not from when you sent it: `rent-review-2026-tenancy-4471`, not a random value made fresh on each attempt. Then a retry after a timeout, a crash or a lost answer is always the same key.

If you are not sure whether an earlier attempt went through, either repeat it with the same key, or look first with [`list_letters`](reference/list_letters.md) (by `reference` or recipient) before sending anything new.

## What it does not cover

An idempotency key stops the same call twice. It does not stop a second, different call for the same letter: a new quote sent with a new key is a new letter. The duplicate catch (identical letters to the same person and address within 7 days wait for a person, as `possible_duplicate`) is a safety net, not a substitute.
