> ## 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.

# Errors and support

> Interpret HTTP status codes, MT5 results, and verification responses.

## Two levels of results

Check both the HTTP status and content. Some queries preserve the MT5 envelope,
for example `{"retcode":"0 Done","answer":{}}`; the shape of `answer` depends on the route.
Transport success is not confirmed trade execution.
A failed password verification may return HTTP 200 with `valid:false`.

## HTTP errors

| Status | Common cause | Action |
| - | - | - |
| 400 | Missing or invalid idempotency key | Check the 16–128 character format |
| 401 | Missing, invalid, expired, or revoked token | Check the secret or request a replacement |
| 403 | Unauthorized route, account, IP, request, or position; trading disabled | Check `detail`, permissions, and verification |
| 409 | Key reused with different data or reservation pending | Reconcile; do not blindly generate another key |
| 413 | Request body too large | Reduce it to supported fields |
| 422 | Invalid body, JSON, or parameters; incompatible close | Check constraints and current position |
| 429 | Request limit or password failures | Wait and reduce frequency; do not keep retrying passwords |
| 500 | Internal error | Keep identifiers; reconcile if this was a trade |
| 502 | MT5 rejected the request | Review `retcode` and context with support |
| 503 | MT5, authorization, or position lookup unavailable | Retry reads with a delay; reconcile writes |

Service validation errors are simplified to `{"detail":"Invalid request"}` to
avoid returning sensitive data. Do not depend on `detail` containing a list of fields
or the submitted value. Closing may also return a specific message when parameters
do not match the position.

An MT5 error may return:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "MT5 rejected the request", "retcode": "MT5_CODE"}
```

The code is a string and is filtered before being returned. An execution rejection
can also appear inside the asynchronous result with HTTP 200.

## Recovery

GET queries can be retried with a delay and a maximum number of attempts. Do not
automatically apply the same policy to opening and closing orders. Follow
[idempotency and recovery](/trading/idempotency) for uncertain results.
A `Retry-After` header is not guaranteed; do not invent a fixed server waiting period.

If you receive HTML or a proxy block instead of JSON, treat it as an invalid response
for your workflow. Keep HTTPS validation enabled and confirm state before trading.

## Information for support

Keep the method, route, UTC time, HTTP status, `X-Request-ID`, `X-Audit-ID` when present,
login, MT5 request ID, and idempotency key for trades.
Responses generated by the application include `X-Request-ID`; an earlier proxy or
network failure may not include it. `X-Audit-ID` depends on the audit record being stored.
Never send tokens, passwords, or the verification body in a report.
