> For the complete documentation index, see [llms.txt](https://docs.iexexchanger.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iexexchanger.com/get-started/exchanger-api/kak-ustroen-api/idempotency.md).

# Защита от дублей через Idempotency-Key

`Idempotency-Key` нужен, чтобы повтор одного и того же write-запроса не создал дубль.

Главный пример: создание заявки. Если клиент отправил запрос, но соединение оборвалось, он может повторить запрос с тем же ключом. API вернет тот же результат, а не создаст вторую заявку.

## Header запроса

```http
Idempotency-Key: create-order-user-42-001
```

## Где использовать

Используйте `Idempotency-Key` для:

* `POST /private/exchange/orders`;
* `POST /private/exchange/orders/{order}/confirm`;
* `POST /private/exchange/orders/{order}/cancel`;
* `POST /private/files/upload-intents/{intent}/commit`;
* `POST /private/webhooks`;
* любых write-запросов, где повтор опасен.

## Как выбирать ключ

Хороший ключ:

```
create-order-user-42-001
confirm-order-TRK8K2LQ-001
webhook-production-create-001
```

Плохой ключ:

```
123
test
random
```

Ключ должен быть уникален для одной бизнес-операции. Для повтора той же операции используйте тот же ключ.

## Что будет при повторе

Если тот же запрос повторился с тем же ключом, API вернет сохраненный ответ и может добавить header:

```http
Idempotency-Replayed: true
```

Если тот же ключ отправлен с другим body или другим endpoint, API вернет конфликт.


---

# 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://docs.iexexchanger.com/get-started/exchanger-api/kak-ustroen-api/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.
