OrdersService
Modify Order
Modify a single open order by order ID or client order ID. Supports amend-or-replace behavior policies, price and quantity updates, and attached risk updates.
Request
curl --request POST \ \
--url 'https://api.testnet.polyester.com/v1/orders/modify' \
--header 'Accept: */*' \
--header 'X-API-KEY-ID: YOUR_API_KEY_ID' \
--header 'X-API-TIMESTAMP: YOUR_API_TIMESTAMP' \
--header 'X-API-SIGNATURE: YOUR_API_SIGNATURE' \
--header 'Content-Type: application/json' \
--data '{
"behavior": "AMEND_OR_REPLACE",
"newAttachedRisk": {
"oco": false,
"stopLoss": {
"child": {
"marketIoc": {}
},
"triggerPrice": "61000.25",
"triggerPriceSource": "LAST_PRICE"
},
"takeProfit": {
"child": {
"marketIoc": {}
},
"triggerPrice": "61000.25",
"triggerPriceSource": "LAST_PRICE"
}
},
"newClientOrderId": "cli-ord-20250101-001",
"newPrice": "61000.25",
"newQtyScaled": 100000,
"orderId": "5USXJZmk",
"requestId": "request_01J0EXAMPLE",
"subaccountId": "45LUmqjT",
"symbol": "BTC-USDT"
}'Responses
{
"actionTaken": "AMENDED",
"code": "INVALID_ORDER_STATE",
"finalOrderId": "5USXJZmk",
"oldOrderId": "5USXJZmk",
"stopLossTriggerId": "4U4q9P7z",
"takeProfitTriggerId": "2ZodcFeg",
"trailingStopTriggerId": "24cncW7T",
"ts": "2025-01-01T00:00:00Z",
"tsNs": "1735689600000000000"
}Modify behavior policy. MODIFY_BEHAVIOR_UNSPECIFIED is treated as AMEND_OR_REPLACE.
Client order ID to resolve within the caller account.
If true, the take-profit and the configured stop leg (stop-loss or trailing stop) are linked and shown as one-cancels-the-other. Requires a take-profit and exactly one stop leg. The legs of every parent share one position and end together as described on RiskPolicy, so this setting does not change when exits are submitted. It decides what canceling an exit order ends: with oco set, canceling one leg's exit ends both legs; without it, only that leg ends and the other keeps protecting the remaining position. Changing only this setting with ModifyOrder keeps the existing legs, with their IDs, arming and a trailing stop's tracked peak; changing a leg's terms, such as its trigger price, limit price or trailing distance, still replaces that leg. Default is false.
Limit price as a decimal string in quote asset units per base asset unit, for example '61000.25'.
Market child with implicit IOC behavior.
Trigger price as a decimal string in quote asset units per base asset unit, for example '60000'.
Price the stop-loss watches. Unspecified or LAST_PRICE watches the last traded price. INDEX_PRICE watches the market's index price; on a market without an index price the order is rejected with terminal reason INDEX_PRICE_UNAVAILABLE before any fill, and a modify that adds such a leg is refused with ERROR_CODE_TRIGGER_PRICE_SOURCE_UNSUPPORTED, leaving the order and its legs unchanged. MARK_PRICE is not supported. A modify naming another source replaces the leg.
Limit price as a decimal string in quote asset units per base asset unit, for example '61000.25'.
Market child with implicit IOC behavior.
Trigger price as a decimal string in quote asset units per base asset unit, for example '60000'.
Price the take-profit watches. Unspecified or LAST_PRICE watches the last traded price. INDEX_PRICE watches the market's index price; on a market without an index price the order is rejected with terminal reason INDEX_PRICE_UNAVAILABLE before any fill, and a modify that adds such a leg is refused with ERROR_CODE_TRIGGER_PRICE_SOURCE_UNSUPPORTED, leaving the order and its legs unchanged. MARK_PRICE is not supported. A modify naming another source replaces the leg.
Optional activation price as a decimal string in quote asset units per base asset unit, for example '62000': trailing only starts after this price is reached. If omitted, trailing starts immediately after the parent order fills.
Maximum price of a trailing stop that buys back, as a decimal string in quote asset units per base asset unit, for example '65000': the most its exit pays, at which the quote it may spend is reserved. Required when the parent order sells; must be omitted when the parent order buys.
Maximum allowed slippage in basis points (1 bp = 0.01%), from 1 to 9999 whichever side the exit trades. An order whose trailing stop sets 10000 is rejected with ERROR_CODE_MAX_SLIPPAGE_INVALID, because a 100% cap would leave an exit that sells no positive price to sell at.
Positive maximum absolute price delta in Q9 execution-price ticks (1 tick = 1e-9 quote units).
Trailing distance as a decimal price delta in quote asset units, for example '0.5'.
Trailing distance in basis points (1 bp = 0.01%).
Price the trailing stop watches and trails: its peak or trough, activation and fire all follow this price. Unspecified or LAST_PRICE watches the last traded price. INDEX_PRICE watches the market's index price; on a market without an index price the order is rejected with terminal reason INDEX_PRICE_UNAVAILABLE before any fill, and a modify that adds such a leg is refused with ERROR_CODE_TRIGGER_PRICE_SOURCE_UNSUPPORTED, leaving the order and its legs unchanged. MARK_PRICE is not supported. A modify naming another source replaces the leg.
Optional new client order id when replace path is taken.
New limit price as a decimal string in quote asset units per base asset unit, for example '28334.99'. Omit to keep the current price.
Target total quantity after modify/replace, scaled by the pair's base_quantity_scale from GetSpotConfig.
Order ID as fixed64.
Idempotency key (required). Outstanding modifications retain this key; identical retries replay the final result for 60 seconds after the answer.
Optional public subaccount ID. When omitted, subaccount-scoped API keys use their bound subaccount; other callers use their authenticated root account.
Trading pair symbol, e.g. BTC-USDT.
Action applied; unspecified when rejected.
AMENDEDError code if rejected.
INVALID_ORDER_STATEFinal active order ID; same as old_order_id for amendments.
5USXJZmkOriginal order ID that was amended or replaced.
5USXJZmkTrigger ID for attached stop-loss after modification, when configured.
4U4q9P7zTrigger ID for attached take-profit after modification, when configured.
2ZodcFegTrigger ID for attached trailing stop after modification, when configured.
24cncW7TServer timestamp.
2025-01-01T00:00:00ZServer timestamp as epoch nanoseconds (for bots).
1735689600000000000| Key | HTTP status | Connect code | Error | When |
|---|---|---|---|---|
| unauthenticated | 401 | unauthenticated | Unauthenticated | Authentication required. |
| permission-denied | 403 | permission_denied | Permission Denied | Permission denied. |
| invalid-argument | 400 | invalid_argument | Invalid Argument | Invalid argument. |
| not-found | 404 | not_found | Not Found | Not found. |
| unavailable | 503 | unavailable | Unavailable | Service unavailable. |