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

# Idempotency

> Make create requests safe to retry without double-charging.

Network blips happen. To retry a create safely, send an **`Idempotency-Key`** header: a repeat with
the same key returns the **original** job instead of starting (and charging for) a new one.

```bash theme={null}
curl -X POST https://app.dafty.ai/api/v1/images/generate \
  -H "x-api-key: $DAFTY_API_KEY" \
  -H "Idempotency-Key: 9f1c0b3a-batch-42" \
  -H "Content-Type: application/json" \
  -d '{ "prompt": "A calm mountain landscape" }'
```

Rules:

* Use a unique key per logical operation (a UUID works well). Max 255 characters.
* Keys are scoped to your API key and retained \~24h.
* A retry with the same key returns the same job (`202`) - no second generation, no second charge.
* A different key always creates a new job.

Supported on all create endpoints: `POST /images/generate`, `/images/edit`, `/images/resize`,
`/images/upscale`, and `/styles/extract`.

<Note>
  Idempotency protects sequential retries (timeout → retry). If you fire two identical requests truly
  in parallel before either is recorded, you may still get two jobs - generate the key once and reuse
  it on retries.
</Note>
