Pacifica
  • Getting Started
    • Closed Alpha Guide
      • Link To Guide PDF
    • Closed Alpha Trading Competition
  • Trading on Pacifica
    • Overview
    • Contract Specifications
      • Oracle Price & Mark Price
      • Settlement Mechanism
    • Order Types
      • Market Order
      • Limit Order
      • Order Rules & Constraints
    • Margin & Leverage
    • Funding Rates
    • Liquidations
  • API Documentation
    • API
      • REST API
        • Markets
          • Get market info
          • Get prices
          • Get kline (candle) data
          • Get recent trades
        • Account
          • Get account info
          • Get account settings
          • Update leverage
          • Update margin mode
          • Get positions
          • Get trade history
          • Get funding history
          • Get account equity history
          • Create subaccount
          • Request withdrawal
        • Orders
          • Get open orders
          • Get order history
          • Get order history by ID
          • Create order
          • Create stop order
          • Create position TP/SL
          • Cancel order
          • Cancel all orders
          • Cancel stop order
          • Batch orders
      • Websocket
        • Subscriptions
          • Prices
          • Orderbook
          • Trades
          • Candle
          • Order updates
          • Account balance
          • Account margin
          • Account leverage
          • Account positions
          • Account orders
          • Account order updates
          • Account trades
        • Trading operations
          • Create order
          • Cancel order
          • Cancel all orders
      • Signing
      • Rate limits
    • Specification
  • Other
    • Audits
    • Brand Assets
    • Contact Us
    • Glossary of Terms
Powered by GitBook
On this page
  1. API Documentation
  2. API
  3. REST API
  4. Orders

Create position TP/SL

This endpoint allows users to set take profit and stop loss levels for an existing position.

POST /api/v1/positions/tpsl

Request Body

Field
Type
Need
Description
Example

"account"

string

required

User's wallet address

42trU9A5...

"signature"

string

required

Cryptographic signature

5j1Vy9Uq...

"timestamp"

integer

required

Current timestamp in milliseconds

1716200000000

"symbol"

string

required

Trading pair symbol

BTC

"side"

string

required

Order side (bid/ask)

bid

"take_profit"

object

optional (if there is SL)

Take profit stop order configuration

See next three rows

"stop_price"

string

required

Stop trigger price

55000

"limit_price"

string

optional

Limit price for the triggered order

54950

"client_order_id"

string

optional

Client-defined order ID for the stop order

e36ac10b-58cc-4372-a567-0e02b2c3d479

"stop_loss"

object

optional (if there is TP)

Stop loss order configuration

See next three rows

"stop_price"

string

required

Stop trigger price

48000

"limit_price"

string

optional

Limit price for the triggered order

47950

"client_order_id"

string

optional

Client-defined order ID for the stop order

d25ac10b-58cc-4372-a567-0e02b2c3d479

"agent_wallet"

string

optional

Agent wallet address

69trU9A5...

"expiry_window"

integer

optional

Signature expiry in milliseconds

30000

{
  "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"
  },
  "stop_loss": {
    "stop_price": "48000",
    "limit_price": "47950",
    "client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479"
  },
  "agent_wallet": "69trU9A5...",
  "expiry_window": 30000
}

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()
PreviousCreate stop orderNextCancel order

Last updated 37 minutes ago