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

# Idempotency and recovery

> Prevent duplicates and resolve trades whose results are unconfirmed.

Every opening and closing order requires `Idempotency-Key`: 16–128 characters using
ASCII letters, numbers, periods, underscores, colons, or hyphens. A UUID meets the format.
The key belongs to your token and one intent; use a different key for each opening
and closing order, even when they share an account and symbol.

## Before submitting

Persist the intent, route, full body, and key. Do not generate a new key for every
HTTP attempt. A retry of the same intent keeps the same route, key, and data,
including price and comment.

## Responses when reusing a key

| Situation | Result |
| - | - |
| Missing key or invalid format | HTTP 400 |
| Same content and response already stored | Returns the stored response without resubmission |
| Key reused with different content | HTTP 409: `Idempotency-Key was already used for another request` |
| Reservation still pending | HTTP 409: `A trade with this Idempotency-Key is already pending` |

Permissions and account authorization are also checked when repeating a request.
A stored response is the submission response, not final execution confirmation.

## Timeout, disconnection, or error after submission

1. Stop automatic POST retries and mark the intent as uncertain.
2. If you know the MT5 ID, query [its result](/trading/results).
3. Query account positions and orders to reconcile the state.
4. Keep the key, exact body, UTC time, and identifiers for support.
5. If you cannot confirm the result, request a provider review before creating
   a new intent that could duplicate the previous one.

An HTTP 5xx response does not prove that MT5 did not receive the request.
A reservation can remain pending after an error, including during closing validation.
The partner API does not expose recovery by key, reservation cancellation, or manual
unlocking. Elapsed time does not mean it is safe to resubmit with another key.

Do not assume repeating the POST will update the price: changing it alters the intent
and can produce a conflict. Resolve the previous trade before preparing another one.

Pending orders also require a key. For automatic market pricing, the intent stores
the submitted body without changing quotes; a completed retry does not query or
submit again. Do not switch between explicit and automatic mode with the same key.
