# Modify pending order (TRADE)

## API Description

Changes a resting pending order. Cannot modify a market order (there is nothing to modify) or a
position (use [`PUT /v1/position`](/trade/modify-position-sltp.md)).

## HTTP Request

```http
PUT /v1/order
```

## Request Weight

1 (1 against `ORDERS`)

## Request Parameters

| Name | Type | Mandatory | Description |
| - | - | - | - |
| `login` | LONG | YES | |
| `orderId` | LONG | conditional | The pending order ticket. Send this or `origClientOrderId`. Any pending order on the login can be addressed by ticket, including one this API did not place. |
| `origClientOrderId` | STRING | conditional | The `newClientOrderId` the order was placed with. See [Known limitations](/known-limitations.md#modify--cancel--query-by-origclientorderid-does-not-find-a-pending-order). |
| `price` | DECIMAL | NO | New trigger price. |
| `stopLimitPrice` | DECIMAL | NO | New limit price. Stop-limit orders only — `-1106` on any other order. |
| `sl` | DECIMAL | NO | New stop loss. `0` clears. |
| `tp` | DECIMAL | NO | New take profit. `0` clears. |
| `timeInForce` | ENUM | conditional | New expiration mode. **Mandatory when the service cannot determine the order's current one** — see below. |
| `expiration` | LONG | conditional | New expiration, Unix ms. Mandatory if `timeInForce` is or becomes `GTD` or `GTD_DAY` and the current value is not determinable. |
| `newClientOrderId` | STRING | NO | Idempotency key **for this modification**. Must differ from the original order's id. |
| `recvWindow`, `timestamp`, `signature` | | | |

Exactly one of `orderId` / `origClientOrderId` (`-1128` if both or neither). An identifier that does
not resolve to an order currently resting on this `login` is `-2013`. At least one field to change
(`-5005` if the request contains no changes).

On a **stop-limit** order the service cannot always read back both current prices; if either is
undeterminable and you did not send it, the request is `-1102` — send both `price` and
`stopLimitPrice` when modifying a stop-limit order.

> **Omitted fields are left unchanged.** The service reads the order's current values and writes
> them back alongside your changes. Send `0` to clear an `sl` or `tp`; omitting it preserves it.

> **`timeInForce` may be mandatory.** MT5 rewrites every field of an order in one operation,
> including its expiration mode, so a modify always sends one. When you omit `timeInForce` the
> service uses, in order: the value **it last sent for this ticket** (from the order's own placement
> or an earlier modification through this API), then the trade server's own value where the order
> record carries one. If neither can answer — typically an order this API did not place — the
> request is refused with `-1102` rather than guessing, because a guess would silently turn a `DAY`
> order into a `GTC` one. Send `timeInForce` explicitly in that case. The same rule applies to
> `expiration` when the resolved mode requires one.

## Response Example

```json
{
  "login": 100123,
  "clientOrderId": "bot-002-mod-1",
  "origClientOrderId": "bot-002",
  "orderId": 44412350,
  "symbol": "XAUUSD",
  "side": "BUY",
  "type": "BUY_LIMIT",
  "volume": "0.10",
  "status": "NEW",
  "price": "2323.00",
  "sl": "2315.00",
  "timeInForce": "GTC",
  "mt5RetCode": 10009,
  "transactTime": 1789012400112
}
```

The fields are those of [`POST /v1/order`](/trade/new-order.md) plus `origClientOrderId`, the id the order was
placed with (absent for an order this API did not place). `clientOrderId` is this modification's own
id — yours, or a generated one. `status` stays `NEW` while the order rests.

An order inside `freezeLevel` of the market cannot be modified (`-4021`). Prices must be multiples of
`tickSize` (`-4008`).
