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

# Idempotency

> Use Idempotency-Key for safe public V1 writes.

Public write endpoints accept an `Idempotency-Key` header. Use it to make retries safe when a network timeout or uncertain `5xx` response leaves the mutation outcome unknown.

## Behavior

* New key: Sellfern processes the mutation and stores the response.
* Same key with the same request: Sellfern replays the original response without repeating the mutation.
* Same key with a different request: Sellfern returns `422 idempotency_conflict`.

Idempotency keys are retained for 24 hours. After that window, reusing the same key may be treated as a new request.

## Example

The endpoint below is illustrative. Use the V1 API Reference to confirm which write endpoints are available for your integration.

```bash theme={null}
curl https://api.sellfern.com/products \
  -H "x-api-key: $SELLFERN_API_KEY" \
  -H "Idempotency-Key: product-create-001" \
  -H "Content-Type: application/json" \
  -d '{"sku":"TSHIRT-BLACK-M","title":"Classic T-Shirt"}'
```

## Agent guidance

AI agents should create one idempotency key per logical write action. If a retry is needed for the same action, reuse the same key. If the user asks for a different action, generate a new key.
