tpSl action creates take-profit (TP) and stop-loss (SL) trigger orders for an existing position. Unlike regular orders, TP/SL orders do not consume margin when created — they sit dormant and automatically place a real closing order when the market reaches the trigger price.
You can set a TP only, an SL only, or both in a single request. For position-level TP/SL (isPositionTpsl: true), the closing direction is determined automatically from the position side — you don’t need to specify it. The position must already exist before you create position-level TP/SL orders.
Endpoint
Request
All requests must include an ECDSA signature and a millisecond-precision nonce.Action fields
string
required
Fixed value:
"tpSl".int32
required
The contract ID the TP/SL orders apply to.
int8
Identifies the position side:
0 = ONE_WAY, 1 = LONG, 2 = SHORT. Defaults to 0.boolean
When
true, creates position-level TP/SL orders that automatically close the position when triggered. When false, creates standalone trigger orders. Defaults to false.string
The side of the order placed when the trigger fires:
"B" = buy, "S" = sell. Used only for standalone trigger orders (isPositionTpsl = false); for position-level TP/SL the closing direction is inferred automatically.boolean
When
true, the triggered order is marked reduce-only and will only execute if it reduces an open position. Defaults to false.string
Trigger price for the take-profit leg. Set to
"0" to skip the TP leg. At least one of tpPrice or slPrice must be greater than "0".string
Trigger price for the stop-loss leg. Set to
"0" to skip the SL leg. At least one of tpPrice or slPrice must be greater than "0".string
Execution price used once the TP triggers. Must be greater than zero. With
tpOrderType set to limit it is the resting price of a GTC order; with market it is the price the IOC order may cross to, computed as mark price ± your slippage allowance.string
Execution price used once the SL triggers. Must be greater than zero, with the same meaning as
tpLimitPrice.string
The position size to close when the TP triggers.
"0" = close the entire position.string
The position size to close when the SL triggers.
"0" = close the entire position.int8
The price feed used to evaluate the TP trigger:
0 = mark price, 1 = oracle price. Defaults to 0. Only these two values are accepted — any other value is rejected with invalid tp/sl trigger type.int8
The price feed used to evaluate the SL trigger:
0 = mark price, 1 = oracle price. Defaults to 0. Same restriction as tpTriggerType.int8
Type of order placed when the TP triggers:
1 = limit, 2 = market. Required whenever tpPrice is greater than "0", and must be omitted or 0 when the TP leg is unset.int8
Type of order placed when the SL triggers:
1 = limit, 2 = market. Required whenever slPrice is set, with the same rule as tpOrderType.Response
Success
Rejection
A rejected request still returns HTTP 200 withstatus: "ok", carrying errorCode and errorMessage inside response.data. Common causes are no open position, both tpPrice and slPrice at "0", not being enrolled in the market deployer, and an unknown contract.
Response fields
int64
The order ID assigned to the take-profit trigger order. Returns
0 if the TP leg was not set (i.e., tpPrice was "0").int64
The order ID assigned to the stop-loss trigger order. Returns
0 if the SL leg was not set (i.e., slPrice was "0").