# Idempotency

> Retry a plan or a start as often as you need: it happens once.

Web page: https://www.signalvan.com/developers/idempotency

## How it works

Send an `Idempotency-Key` header (1 to 255 characters, a new one per request; a UUID is ideal) with `POST /searches/plan` and `POST /searches`. SignalVan keeps the first answer for 24 hours.

cURL:

```bash
curl -X POST https://api.signalvan.com/v1/searches \
  -H "Authorization: Bearer $SIGNALVAN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0b8f3a7e-1c2d-4e5f-8a9b-0c1d2e3f4a5b" \
  -d '{"plan_id": "9c1e7a52-3d8f-4b61-a2c4-7e0f5b9d1a36", "confirm": true}'
```

## What you get back

| You send | You get |
| --- | --- |
| The same key and the same body again | The first answer, with `Idempotent-Replayed: true` |
| The same key with another body | `409 idempotency_conflict` |
| The same key while the first is still running | `409` with `Retry-After: 2`; retry to get its answer |
| After a `429` or `503` | The key is let go, so the retry runs again |

> A plan also starts at most one lead search, with or without the header: starting the same plan again answers the same lead search.
