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

# Recover an interrupted request

> Retry a prediction without starting duplicate work or paying twice.

A timeout does not tell you whether a prediction finished. Keep the original
request and its `Idempotency-Key`, then send both again to recover the recorded
result.

## Keep the operation together

Create one key per logical prediction and save it alongside the request body.
Use the key for every attempt to retrieve that prediction’s outcome.

```text theme={null}
One prediction
├── one request body
├── one Idempotency-Key
└── one saved result and charge
```

For the [support example](/examples/customer-support), rerun just the `curl`
command after a timeout. Keep `prediction.json` and `D1_OPERATION_KEY` unchanged.

## Handle the result

| Result                              | Next step                                                                   |
| ----------------------------------- | --------------------------------------------------------------------------- |
| `200`                               | Use the saved answer. The charge is committed.                              |
| `409 request_in_progress`           | Wait for `Retry-After`, then retry the same operation.                      |
| `409 idempotency_conflict`          | Check which body belongs to this key. The input differs from the original.  |
| `409 idempotency_expired`           | The replay window has closed. Do not treat the old key as a new prediction. |
| Connection timeout or lost response | Keep the body and key. Replay to resolve the outcome.                       |

An accepted terminal failure replays as the same uncharged failure. A deliberate
new attempt needs a new key. A validation or insufficient-credit rejection before
acceptance does not consume the key.

## Know the replay window

Completed results are available for 24 hours by default. After that, a tombstone
prevents the same key from starting new work until 30 days from acceptance.
Never recycle keys: once a tombstone expires, an old key can be accepted as a new
operation.

See [API behavior](/api#idempotency-deadlines-and-retries) for deadlines, retention,
and error handling.
