Set SL/TP
Define stop-loss and take-profit levels for an existing position.
Define stop-loss and take-profit levels for an existing position (by UUID). Prices are USDT levels. The currency is inherited from the position.
Request
curl -X POST "https://trade.mudrex.com/fapi/v1/futures/positions/{position_id}/riskorder" \
-H "Content-Type: application/json" \
-H "X-Authentication: your-secret-key" \
-d '{
"stoploss_price": "0.10",
"takeprofit_price": "0.13",
"order_source": "API",
"is_stoploss": true,
"is_takeprofit": true,
"stoploss_client_order_id": "my-sl-123",
"takeprofit_client_order_id": "my-tp-123"
}'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
position_id | string | Yes | The unique identifier of the position (path parameter). |
stoploss_price | string | Conditional | Required if is_stoploss is true. USDT price (above liquidation for LONG). |
takeprofit_price | string | Conditional | Required if is_takeprofit is true. USDT price. |
order_source | string | No | Source of the order (e.g. "API"). |
is_stoploss | boolean | No | Whether to set a stop loss order (default: false). |
is_takeprofit | boolean | No | Whether to set a take profit order (default: false). |
stoploss_client_order_id | string | No | Optional client id for the stop-loss leg. |
takeprofit_client_order_id | string | No | Optional client id for the take-profit leg. |
Response
Status: 200 OK
{
"success": true,
"data": {
"position_id": "019ecc52-2f95-7ab5-8682-c3a0f43ccda6",
"status": "CREATED",
"message": "Risk order placed successfully"
}
}Response fields
| Field | Description |
|---|---|
position_id | ID of the position for which the risk order was set. |
status | Status of the risk order (e.g. CREATED). |
message | Status message. |
The response does not include the stop-loss or take-profit order UUIDs. Read them from Open Positions (stoploss.order_id, takeprofit.order_id). Open Orders lists each leg as an order with order_type STOPLOSS or TAKEPROFIT, trigger_type: MARKET, status: CREATED, price set to the trigger price and the supplied stoploss_client_order_id / takeprofit_client_order_id.
Closing the position sets both legs to SYSTEM_CANCELLED.
If the position already has SL/TP, the call updates them and returns {"message": "Risk order amended successfully"}.
Errors
Common errors
Position not found
{
"success": false,
"errors": [
{ "code": 404, "text": "Position not found" }
]
}Status: 404 Not Found
Position not in OPEN state
{
"success": false,
"errors": [
{ "code": 400, "text": "Position is not in OPEN state" }
]
}Status: 400 Bad Request
Risk order creation failed (SL below liquidation)
{
"success": false,
"errors": [
{ "code": 400, "text": "Risk order creation failed" }
]
}Status: 400 Bad Request — stop loss below liquidation price for a LONG position (or above for a SHORT).
Updated 5 days ago
