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

# Modify orders and positions

> Complete workflow for changing pending prices and account protection.

## Choose endpoint and ticket

| Resource | Endpoint | Ticket | Editable fields |
| - | - | - | - |
| Pending order | `POST /api/v1/orders/{order}/modify` | `Order` from active orders | `price`, `sl`, `tp`; `stop_limit_price` for stop-limit only |
| Open position | `POST /api/v1/positions/{position}/modify` | `Position` from open positions | `sl`, `tp` |

Never use a request ID or deal ID as the ticket. Modification does not change
volume, symbol, direction or expiration. Position entry price is unchanged;
use `/close` to reduce position volume.

## Request body

Send `login` and at least one editable field. Levels are absolute prices, not pips
or distances. These prices are illustrative:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"login":104205,"price":1.09,"sl":1.08,"tp":1.12}
```

This example modifies a pending order. For positions, send only `login` and `sl`
and/or `tp`, for example `{"login":104205,"tp":1.12}`.

| Input | Effect |
| - | - |
| Omitted field | Preserve its value. |
| Positive SL/TP | Add or replace the level. |
| `sl: 0` or `tp: 0` | Remove only that level. |
| `null` | Reject with 422. |
| `price`, `stop_limit_price` | Must be positive; zero is invalid. |

For stop-limit, `price` triggers the order and `stop_limit_price` sets the subsequent
limit price. Retained stops must remain valid after an entry change; correct them
in the same body if needed. Precision, tick size, minimum distances and freeze
levels are checked. MT5 makes the final acceptance decision.

## Submit and confirm

1. Verify the account. Use its broker token with the appropriate scope:
   `POST:/api/v1/orders/*/modify` or `POST:/api/v1/positions/*/modify`.
2. Persist body, route and a new 16–128 character `Idempotency-Key` per intent.
   The API checks ticket ownership and enabled trading.
3. Submit POST with Bearer and that key. Save `answer.id` or `answer.ID`.
   The response confirms submission, not final modification.
4. Query `GET /api/v1/trading/requests/{request_id}`: `10009` confirms success;
   `10025` means no changes. Respect `Retry-After` while pending.
5. Read orders or positions for current levels. Stored results are historical
   and do not fetch the current position.

`summary.operation` is `modify_order` or `modify_position`. Serialize dependent
changes to the same ticket. If a pending order fills first, modification may
fail; its resulting position is not modified. After a timeout, reuse the same
key and body. Never use a new key for an uncertain intent; reconcile the account first.

Python client, using already persisted keys:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
client.modify_pending_order(123456, {"login": 104205, "price": 1.09},
                            idempotency_key=order_key)
client.modify_position(987654, {"login": 104205, "sl": 0},
                       idempotency_key=position_key)
```

## Migration from `/stops`

Position modification now uses `/modify`; `/stops` no longer accepts requests.
Update the URL, scope and Python helper (`modify_position`). Old explicit scopes
are not automatically expanded. Historical result queries remain available and
may retain `operation=modify_stops`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.