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
}'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). |
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. |
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).
