> For the complete documentation index, see [llms.txt](https://developers.bead.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.bead.xyz/reference-guide/core-concepts/idempotency.md).

# Idempotency

Idempotency guarantees that repeating the **same** write request (POST, PUT, PATCH) within a short window returns the original response instead of creating a duplicate object. Bead will add this feature soon; the details below describe the planned contract so you can design for it now.

### Status

Idempotency is **not yet enforced** in Sandbox or Production. Expect network retries to create duplicate records until enforcement is announced in the changelog.

### Header format

| Header          | Example value                          | Notes                            |
| --------------- | -------------------------------------- | -------------------------------- |
| Idempotency-Key | `550e8400-e29b-41d4-a716-446655440000` | Case-insensitive UUID v4 string. |

### Evaluation rules (planned)

| Condition                                                     | Server behaviour                                               |
| ------------------------------------------------------------- | -------------------------------------------------------------- |
| Same `Idempotency-Key` and identical request body within 24 h | Return the cached 2xx response (status and body).              |
| Same `Idempotency-Key` but different body                     | Return **409 Conflict** with an error explaining the mismatch. |
| Key older than 24 h                                           | Treat as a brand-new request.                                  |

Keys are stored per endpoint path; using the same key for different paths does not collide.

### Example

```bash
curl -X POST "$BEAD_API/Locations" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000" \
     -H "Content-Type: application/json" \
     -d '{ "merchantId": "mer_123", "address": {...} }'
```

If the client times out and sends the identical call again with the same key, the API responds with the original **201** body.

### Best practices

* Generate a fresh UUID v4 for each logical operation (one per new location, one per new terminal, etc.).
* Store the key client-side until the operation succeeds or fails definitively.
* Do not reuse keys across resource types or different merchants.
* If you receive **409 Conflict**, inspect the error; it means the same key was used with a modified body.
* Maintain client-side retries with exponential back-off even after idempotency is live; the feature only prevents duplication, it does not guarantee success.

### Go-live checklist for integrators

1. Implement the header now in sandbox calls; it will be ignored until launch.
2. Log any **409 Conflict** responses so you can catch accidental key reuse.
3. Watch the global changelog for the announcement that enforcement is active.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.bead.xyz/reference-guide/core-concepts/idempotency.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
