Skip to main content
POST /api/v1/positions/tpsl

Operation Type (for Signing)

Header FieldTypeContent
"type"string"set_position_tpsl"

Request Body

FieldTypeNeedDescriptionExample
”account”stringrequiredUser’s wallet address42trU9A5…
“signature”stringrequiredCryptographic signature5j1Vy9Uq…
“timestamp”integerrequiredCurrent timestamp in milliseconds1716200000000
”symbol”stringrequiredTrading pair symbolBTC
”side”stringrequiredOrder side (bid/ask)bid
”take_profit”objectoptional (if there is SL)Take profit stop order configurationSee next five rows
”stop_price”stringrequiredStop trigger price55000
”limit_price”stringoptionalLimit price for the triggered order54950
”client_order_id”Full UUID stringoptionalClient-defined order ID for the stop ordere36ac10b-58cc-4372-a567-0e02b2c3d479
”trigger_price_type”stringoptionalPrice type used to trigger the stop order. Defaults to last_trade_price. Options: mark_price, last_trade_price, mid_pricemark_price
”amount”stringoptionalOrder amount for the triggered order. If omitted, the full position size is used0.1
”stop_loss”objectoptional (if there is TP)Stop loss order configurationSee next five rows
”stop_price”stringrequiredStop trigger price48000
”limit_price”stringoptionalLimit price for the triggered order47950
”client_order_id”Full UUID stringoptionalClient-defined order ID for the stop orderd25ac10b-58cc-4372-a567-0e02b2c3d479
”trigger_price_type”stringoptionalPrice type used to trigger the stop order. Defaults to last_trade_price. Options: mark_price, last_trade_price, mid_pricemark_price
”amount”stringoptionalOrder amount for the triggered order. If omitted, the full position size is used0.1
”agent_wallet”stringoptionalAgent wallet address69trU9A5…
“expiry_window”integeroptionalSignature expiry in milliseconds30000
”builder_code”stringoptionalBuilder program code (3-16 alphanumeric characters)MYCODE
{
  "account": "42trU9A5...",
  "signature": "5j1Vy9Uq...",
  "timestamp": 1716200000000,
  "symbol": "BTC",
  "side": "bid",
  "take_profit": {
    "stop_price": "55000",
    "limit_price": "54950",
    "client_order_id": "e36ac10b-58cc-4372-a567-0e02b2c3d479",
    "trigger_price_type": "mark_price"
  },
  "stop_loss": {
    "stop_price": "48000",
    "limit_price": "47950",
    "client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479",
    "trigger_price_type": "mark_price"
  },
  "agent_wallet": "69trU9A5...",
  "expiry_window": 30000,
  "builder_code": "MYCODE"
}

Response

  • Status 200: Take profit and stop loss set successfully
  {
    "success": true
  }
  • Status 400: Bad request
  {
    "error": "Position not found",
    "code": 400
  }
  • Status 500: Internal server error

Code Example (Python)

import requests

payload = {
    "account": "42trU9A5...",
    "signature": "5j1Vy9Uq...",
    "timestamp": 1716200000000,
    "symbol": "BTC",
    "side": "bid",
    "take_profit": {
        "stop_price": "55000",
        "limit_price": "54950"
    },
    "stop_loss": {
        "stop_price": "48000",
        "limit_price": "47950"
    }
}

response = requests.post(
    "/api/v1/positions/tpsl",
    json=payload,
    headers={"Content-Type": "application/json"}
)

data = response.json()