Guides
Guides

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

ParameterTypeRequiredDescription
position_idstringYesThe unique identifier of the position (path parameter).
stoploss_pricestringConditionalRequired if is_stoploss is true. USDT price (above liquidation for LONG).
takeprofit_pricestringConditionalRequired if is_takeprofit is true. USDT price.
order_sourcestringNoSource of the order (e.g. "API").
is_stoplossbooleanNoWhether to set a stop loss order (default: false).
is_takeprofitbooleanNoWhether 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

FieldDescription
position_idID of the position for which the risk order was set.
statusStatus of the risk order (e.g. CREATED).
messageStatus 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).