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

# Close a position

> Request a full or partial close with the ticket and verified account.

`POST /api/v1/positions/{position}/close` requires a verified account, trading
permission, and a persisted `Idempotency-Key` for this closing intent.

## Full close

Select the `Position` ticket from your account's positions. Do not use the opening
request ID or order ID. Omit volume to request the entire current position volume:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"login": 104205}
```

## Partial close

Specify the volume to close in MT5 units: **10000 = 1 lot**. To close 0.5 lots:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"login": 104205, "volume": 5000, "comment": "Partial close"}
```

Volume must be positive, no greater than the current position, and comply with the
symbol minimum, maximum and step. Omitted or null volume means the full observed
volume. The optional comment is limited to 31 characters.

## Server calculations

The API searches only the verified account, resolves the symbol and volume, and
closes BUY with SELL at Bid or SELL with BUY at Ask. It derives current price,
precision and FOK/IOC using the account group's effective symbol settings. The
Dealer request includes the position ticket so it targets that specific position.
Do not send `symbol`, `side`, `price` or `digits`. Legacy bodies containing these
fields now return `422` and must be updated. Close-only symbols are supported.

## Submit and confirm

Persist the body in `closing.json` and a unique key for this intent:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --fail-with-body -X POST "$API_BASE/api/v1/positions/654321/close" \
  -H "Authorization: Bearer $MT5_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $CLOSE_KEY" \
  --data-binary @closing.json
```

Replaying the same body, ticket and key returns the original submission without
looking up the position again or sending another order. A new key is a new intent.
Save the returned request ID and [query its result](/trading/results). IOC can
execute partially even for a full-close request. Check the remaining position
before deciding on another operation; the API never automatically resubmits it.

Missing or foreign tickets return `403`. Excessive volume, invalid steps or extra
fields return `422`. Stale quotes prevent submission. Concurrent activity may
change the position; the broker validates final execution. Submission alone does
not guarantee that the position is fully closed.
