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

# Retry without starting work twice

> Repeat the same request safely after a network problem.

**Goal:** Send the same request twice and receive the same run.

**Why this helps:** a response can be lost even when Millwork accepted the
request. Reusing the same request key avoids starting and paying for the work
again.

**You are done when:** both responses contain the same `execution_id`.

## Before you begin

Set `MILLWORK_API_URL` and `MILLWORK_API_KEY` as shown in
[Check your setup](/get-started/first-api-call).

This recipe uses Echo, so it does not call an AI provider.

## Send the same request twice

```bash theme={null}
export JOB_KEY="echo-retry-$(date +%s)"

jq -n '{
  mode: "echo",
  task: {
    objective: "Check that a repeated request does not start another run."
  },
  policy: {
    data_classes: ["public"],
    budget: {
      max_cost_usd: 1,
      max_runtime_s: 30
    }
  }
}' > retry-request.json

for ATTEMPT in 1 2; do
  curl --fail-with-body \
    --request POST \
    --header "Authorization: Bearer $MILLWORK_API_KEY" \
    --header "Idempotency-Key: $JOB_KEY" \
    --header "Content-Type: application/json" \
    --data @retry-request.json \
    "$MILLWORK_API_URL/executions" > "retry-$ATTEMPT.json"
done

jq -e -s '.[0].execution_id == .[1].execution_id' \
  retry-1.json retry-2.json
```

**Expected result:** the final command prints `true`.

## If it fails

| What happened                       | What to do                                                              |
| ----------------------------------- | ----------------------------------------------------------------------- |
| `idempotency_conflict`              | The body changed. Use the original body, or use a new key for new work. |
| No response after submitting        | Send the exact same body with the same key.                             |
| You do not know which body was sent | Stop. Check the original run before creating another request.           |

## What this confirms

The same key and same body return the same accepted work.

It does not confirm that the work succeeded. Continue to poll the returned run
ID until it reaches a final status.
