# CrossEx WebSocket Documentation

    CrossEx provides a simple and powerful Websocket API to integrate trading status into your business or application.

    # Server URL

    • Production: wss://api.gateio.ws/ws/crossex
    • Heartbeat: Clients must send a Ping frame to the WebSocket server every 30 seconds to maintain the connection. If the server does not receive this frame for more than 30 seconds, it will automatically disconnect.

    # Changelog

    Dec 04 2025

    1. Added channel for complete position closing

    Nov 20 2025

    1. Added margin position subscription/unsubscription
    2. Added margin interest subscription/unsubscription
    3. Added modify spot margin leverage

    # Authentication

    WebSocket authentication uses the same signature calculation method as Gate APIv4 API, i.e.: HexEncode(HMAC_SHA512(secret, signature_string)), but with the following difference: Signature string concatenation method: channel=&event={event}&time={time}, where {event} and {time} correspond to the request information Authentication information is sent in the auth field of the request body.

    » event: login

    » method: api_key

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event login
    » payload body object Yes none
    »» method body string Yes Authentication method
    »» api_key body string Yes api key
    »» sign body string Yes Signature

    Request example

    {
    	"time": 1754272114,
    	"event": "login",
    	"payload": {
    		"method": "api_key",
    		"api_key": "0d5245a5d8be8ac0e96ed8aaa47386cf",
    		"sign": "568e694ebf998fc0e9a26ab26c8cb962d8649fd61fbfc61f068251ae8169f00066b3205bb2491c1625e111f18c4bf1e6bcf8d3fd519eaea8b7335edea960eee2"
    	}
    }
    

    # Response Data Structure

    Name Type Required Constraint Description
    » event string true none Event
    api
    » payload object true none none
    »» conn_id string true none Connection ID
    » result object true none Login result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "event": "login",
      "payload": {
        "conn_id": "644ff57f-add4-407a-97aa-b654c4ede839"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168928
    }
    

    # Order Subscription/Unsubscription

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body [string] Yes Subscribe/Unsubscribe trading pairs !all means all

    # Detailed Description

    » event: subscribe、unsubscribe

    » channel: order

    Request example

    {
      "time": 1754272114,
      "event": "subscribe",
      "channel": "order",
      "payload": [
        "GATE_FUTURE_ETH_USDT"
      ]
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    order
    » event string true none Event
    subscribe
    unsubscribe
    » payload [string] true none Subscribed trading pairs
    » result object true none Subscription/Unsubscription result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "order",
      "event": "subscribe",
      "payload": [
        "OKX_FUTURE_ADA_USDT"
      ],
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168928
    }
    

    # Push Message Response

    Name Type Required Constraint Description
    » channel string true none Channel name
    » event string true none Event
    » payload object true none Data set
    »» user_id string true none User ID
    »» order_id string true none Order ID
    »» text string true none Customer order ID
    »» state string true none Order state
    »» symbol string true none Trading pair
    »» side string true none Direction
    »» type string true none Type
    »» attribute string true none Attribute
    »» exchange_type string true none Exchange
    »» business_type string true none Business type
    »» qty string true none Base currency quantity
    »» quote_qty string true none Quote currency quantity
    »» price string true none Price
    »» time_in_force string true none Time in force strategy
    »» executed_qty string true none Executed quantity
    »» executed_amount string true none Executed amount
    »» executed_avg_price string true none Executed average price
    »» fee_coin string true none Fee coin
    »» fee string true none Fee
    »» reduce_only string true none Reduce only
    »» leverage string true none Leverage
    »» reason string true none Reason
    »» last_executed_qty string true none Last executed quantity
    »» last_executed_price string true none Last executed price
    »» last_executed_amount string true none Last executed amount
    »» position_side string true none Position side
    »» create_time string true none Create time
    »» update_time string true none Update time
    » result object true none Update time
    »» code string true none Return code
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Push message response example

    {
    	"channel": "order",
    	"event": "subscribe",
    	"payload": {
    		"attribute": "COMMON",
    		"business_type": "FUTURE",
    		"create_time": "1756434169096",
    		"exchange_type": "OKX",
    		"executed_amount": "0",
    		"executed_avg_price": "0",
    		"executed_qty": "0",
    		"fee": "0",
    		"fee_coin": "",
    		"last_executed_amount": "0",
    		"last_executed_price": "0",
    		"last_executed_qty": "0",
    		"leverage": "3",
    		"order_id": "2072652940337152",
    		"position_side": "NONE",
    		"price": "0.8499",
    		"qty": "10",
    		"quote_qty": "0",
    		"reason": "{\"label\":\"TRADE_INSUFFICIENT_AVAILABLE_MARGIN_ERROR\",\"message\":\"Insufficient availableMargin\"}",
    		"reduce_only": "false",
    		"side": "BUY",
    		"state": "FAIL",
    		"symbol": "OKX_FUTURE_ADA_USDT",
    		"text": "2072652940337152",
    		"time_in_force": "GTC",
    		"type": "MARKET",
    		"update_time": "1756434169098",
    		"user_id": "2124485957"
    	},
    	"result": {
    		"code": "100000",
    		"message": "success"
    	},
    	"time": 1756434168,
    	"time_ms": 1756434168968
    }
    

    # Asset Subscription/Unsubscription

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body [string] Yes Subscribe/Unsubscribe coin set !all means all

    # Detailed Description

    » event: subscribe、unsubscribe

    » channel: asset

    Request example

    {
      "time": 1754272114,
      "event": "subscribe",
      "channel": "asset",
      "payload": [
        "USDT"
      ]
    }
    

    Response example

    {
      "channel": "asset",
      "event": "subscribe",
      "payload": [
        "USDT"
      ],
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168928
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    asset
    » event string true none Event
    subscribe
    unsubscribe
    » payload [string] true none Subscribe/Unsubscribe coin set
    » result object true none Subscription/Unsubscription result
    »» code string true none Return code
    »» message string true none Return message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    # Push Message Response

    Name Type Required Constraint Description
    » channel string true none Channel name
    » event string true none Event
    » payload object true none Data set
    »» user_id string false none User ID
    »» coin string false none Coin
    »» exchange_type string false none Exchange
    »» balance string false none Balance
    »» upnl string false none Unrealized PNL
    »» equity string false none Equity
    »» futures_initial_margin string false none Futures initial margin
    »» futures_maintenance_margin string false none Futures maintenance margin
    »» borrowing_initial_margin string false none Borrowing initial margin
    »» borrowing_maintenance_margin string false none Borrowing maintenance margin
    »» available_balance string false none Available balance
    » result object true none Update time
    »» code string true none Return code
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Push message response example

    {
    	"channel": "asset",
    	"event": "subscribe",
    	"payload": {
    		"available_balance": "9940.013209",
    		"balance": "9967.013209",
    		"coin": "USDT",
    		"equity": "9967.013209",
    		"exchange_type": "CROSSEX",
    		"futures_initial_margin": "1.236",
    		"futures_maintenance_margin": "0",
                    "borrowing_initial_margin": "0",
                    "borrowing_maintenance_margin": "0",
    		"price": "1",
    		"upnl": "0",
    		"user_id": "2124492766"
    	},
    	"result": {
    		"code": "100000",
    		"message": "success"
    	},
    	"time": 1756465636,
    	"time_ms": 1756465636463
    }
    

    # Trade Subscription/Unsubscription

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body [string] Yes Subscribe/Unsubscribe trading pair set !all means all

    # Detailed Description

    » event: subscribe、unsubscribe

    » channel: usertrades

    Request example

    {
      "time": 1754272114,
      "event": "subscribe",
      "channel": "usertrades",
      "payload": [
        "GATE_FUTURE_ETH_USDT"
      ]
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    usertrades
    » event string true none Event
    subscribe
    unsubscribe
    » payload [string] true none Subscribe/Unsubscribe trading pair set
    » result object true none Subscription/Unsubscription result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "usertrades",
      "event": "subscribe",
      "payload": [
        "OKX_FUTURE_ADA_USDT"
      ],
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168928
    }
    

    # Push Message Response

    Name Type Required Constraint Description
    » channel string true none Channel name
    » event string true none Event
    » payload object true none Data set
    »» user_id string false none User ID
    »» transaction_id string false none Transaction ID
    »» order_id string false none Order ID
    »» text string false none User order ID
    »» symbol string false none Trading pair
    »» exchange_type string false none Exchange
    »» business_type string false none Business type
    »» side string false none Buy/Sell direction
    »» qty string false none Trade quantity
    »» price string false none Trade price
    »» fee string false none Fee
    »» fee_coin string false none Fee coin
    »» fee_rate string false none Fee rate
    »» match_role string false none Match role
    »» rpnl string false none Realized PNL
    »» position_mode string false none Position mode
    »» position_side string false none Position side
    »» create_time string false none Create time
    » result object true none Update time
    »» code string true none Return code
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Push message response example

    {
    	"channel": "usertrades",
    	"event": "subscribe",
    	"payload": {
            "user_id": "2124492766",
            "transaction_id": "2072784922594048",
            "order_id": "2072784922592768",
            "text": "2072784922592768",
            "symbol": "GATE_SPOT_ADA_USDT",
            "exchange_type": "GATE",
            "business_type": "SPOT",
            "side": "BUY",
            "qty": "13.36",
            "price": "0.8228",
            "fee": "0.004008000000000000",
            "fee_coin": "ADA",
            "fee_rate": "0.0003",
            "match_role": "TAKER",
            "rpnl": "0",
            "position_mode": "SINGLE",
            "position_side": "",
            "create_time": "1756465636528"
        },
    	"result": {
    		"code": "100000",
    		"message": "success"
    	},
    	"time": 1756434168,
    	"time_ms": 1756434168984
    }
    

    # Position Subscription/Unsubscription

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body [string] Yes !all means all

    # Detailed Description

    » event: subscribe、unsubscribe

    » channel: position

    Request example

    {
      "time": 1754272114,
      "event": "subscribe",
      "channel": "position",
      "payload": [
        "GATE_FUTURE_ETH_USDT"
      ]
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    position
    » event string true none Event
    subscribe
    unsubscribe
    » payload [string] true none Subscribe/Unsubscribe trading pair set
    » result object true none Subscription/Unsubscription result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "position",
      "event": "subscribe",
      "payload": [
        "OKX_FUTURE_ADA_USDT"
      ],
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168929
    }
    

    # Push Message Response

    Name Type Required Constraint Description
    » channel string true none Channel name
    » event string true none Event
    » payload object true none Data set
    »» user_id string false none User ID
    »» position_id string false none Position ID
    »» symbol string false none Trading pair
    »» position_side string false none Position side
    »» initial_margin string false none Initial margin
    »» maintenance_margin string false none Maintenance margin
    »» position_qty string false none Position quantity
    »» position_value string false none Position value
    »» upnl string false none Unrealized PNL
    »» upnl_rate string false none Unrealized PNL rate
    »» entry_price string false none Entry average price
    »» mark_price string false none Mark price
    »» leverage string false none Position leverage
    »» max_leverage string false none Max leverage
    »» risk_limit string false none Risk limit
    »» fee string false none Position fee
    »» funding_fee string false none Position funding fee
    »» funding_time string false none Funding fee collection time
    »» create_time string false none Position create time
    »» update_time string false none Position update time
    » result object true none Update time
    »» code string true none Return code
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Push message response example

    {
    	"channel": "position",
    	"event": "subscribe",
    	"payload": {
    		"create_time": "1756434169096",
    		"entry_price": "0",
    		"fee": "0",
    		"funding_fee": "0",
    		"funding_time": "0",
    		"initial_margin": "0",
    		"leverage": "3",
    		"maintenance_margin": "0",
    		"mark_price": "0.8499",
    		"max_leverage": "20",
    		"position_id": "20087051449819136",
    		"position_qty": "0",
    		"position_side": "NONE",
    		"position_value": "0",
    		"risk_limit": "1",
    		"symbol": "OKX_FUTURE_ADA_USDT",
    		"update_time": "1756434169098",
    		"upnl": "0",
    		"upnl_rate": "0",
    		"user_id": "2124485957"
    	},
    	"result": {
    		"code": "100000",
    		"message": "success"
    	},
    	"time": 1756434168,
    	"time_ms": 1756434168984
    }
    

    # Margin Position Subscription/Unsubscription

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body [string] Yes !all means all

    # Detailed Description

    » event: subscribe、unsubscribe

    » channel: margin_position

    Request example

    {
      "time": 1754272114,
      "event": "subscribe",
      "channel": "margin_position",
      "payload": [
        "GATE_MARGIN_ETH_USDT"
      ]
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    position
    » event string true none Event
    subscribe
    unsubscribe
    » payload [string] true none Subscribe/Unsubscribe trading pair set
    » result object true none Subscription/Unsubscription result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "margin_position",
      "event": "subscribe",
      "payload": [
        "GATE_MARGIN_ETH_USDT"
      ],
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168929
    }
    

    # Push Message Response

    Name Type Required Constraint Description
    » channel string true none Channel name
    » event string true none Event
    » payload object true none Data set
    »» user_id string false none User ID
    »» position_id string false none Position ID
    »» symbol string false none Trading pair ${EXCHANGE}MARGIN${BASE}_${COUNTER}
    »» position_side string false none Position side
    »» initial_margin string false none Position initial margin
    »» maintenance_margin string false none Position maintenance margin
    »» asset_qty string false none Position asset quantity
    »» asset_coin string false none Position asset coin
    »» position_value string false none Position value
    »» liability string false none Liability quantity
    »» liability_coin string false none Liability coin
    »» interest string false none Deducted interest
    »» max_position_qty string false none Max position quantity
    »» entry_price string false none Entry average price
    »» index_price string false none Index price
    »» upnl string false none Unrealized PNL
    »» upnl_rate string false none Unrealized PNL rate
    »» leverage string false none Entry leverage
    »» max_leverage string false none Max leverage
    »» create_time string false none Create time
    »» update_time string false none Update time
    » result object true none Update time
    »» code string true none Return code
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Push message response example

    {
      "channel": "margin_position",
      "event": "subscribe",
      "payload":{
            "user_id": "20251115",
            "position_id": "20116122196200192",
            "symbol": "OKX_MARGIN_DOGE_USDT",
            "position_side": "LONG",
            "initial_margin": "3.339831063595188875",
            "maintenance_margin": "0.20743774877",
            "asset_qty": "61.72130605",
            "asset_coin": "DOGE",
            "position_value": "9.9969999409185",
            "liability": "10.00003424116",
            "liability_coin": "USDT",
            "interest": "0.0000343",
            "max_position_qty": "61.72130605",
            "entry_price": "0.162018605585874506",
            "index_price": "0.16197",
            "upnl": "-0.0030343002415",
            "upnl_rate": "-0.000909",
            "leverage": "3",
            "max_leverage": "8",
            "create_time": "1763365175843",
            "update_time": "1763365689548"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168984
    }
    

    # Margin Interest Subscription/Unsubscription

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body [string] Yes !all means all

    # Detailed Description

    » event: subscribe、unsubscribe

    » channel: margin_interest

    Request example

    {
      "time": 1754272114,
      "event": "subscribe",
      "channel": "margin_interest",
      "payload": [
        "GATE_MARGIN_ETH_USDT"
      ]
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    position
    » event string true none Event
    subscribe
    unsubscribe
    » payload [string] true none Subscribe/Unsubscribe trading pair set
    » result object true none Subscription/Unsubscription result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "margin_interest",
      "event": "subscribe",
      "payload": [
        "GATE_MARGIN_ETH_USDT"
      ],
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168929
    }
    

    # Push Message Response

    Name Type Required Constraint Description
    » channel string true none Channel name
    » event string true none Event
    » payload object true none Data set
    »» user_id string false none User ID
    »» symbol string false none Trading pair
    »» interest_id string false none Interest deduction ID
    »» liability_id string false none Liability source ID can be order ID/position ID
    »» liability string false none Liability
    »» liability_coin string false none Coin
    »» interest string false none Interest
    »» interest_rate string false none Interest rate
    »» interest_type string false none Interest deduction type
    »» create_time string false none Position create time
    » result object true none Update time
    »» code string true none Return code
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    # Detailed Description

    » interest_type: Interest deduction type PERIODIC_POSITION periodic position interest, PERIODIC_OPEN_ORDER periodic order interest, IMMEDIATE_OPEN_ORDER order opening interest

    Push message response example

    {
      "channel": "margin_interest",
      "event": "subscribe",
      "payload": {
        "user_id": "20251115",
        "symbol": "OKX_MARGIN_DOGE_USDT",
        "interest_id": "2101724189861376",
        "liability_id": "2101724189861120",
        "liability": "10",
        "liability_coin": "USDT",
        "interest": "0.0000343",
        "interest_rate": "0.00000343",
        "interest_type": "IMMEDIATE_OPEN_ORDER",
        "create_time": "1763365295219"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168984
    }
    

    # Place Order

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes none
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body object Yes none
    »» text body string¦null No User-defined ID
    »» symbol body string Yes Unique identifier: Exchange_Business_Base_Counter
    »» side body string Yes Trading direction
    »» qty body string¦null No Base currency quantity
    »» price body string¦null No Price
    »» type body string¦null No Order type (default LIMIT, supported types: LIMIT, MARKET)
    »» time_in_force body string¦null No Time in force
    »» quote_qty body string¦null No Quote currency quantity
    »» reduce_only body boolean¦null No Reduce only
    »» position_side body string¦null No Position side

    # Detailed Description

    » event: api

    » channel: place_order

    »» text: User-defined ID Customer-defined order ID, only supports letters (a-z), numbers (0-9), symbols (-, _)

    »» symbol: Unique identifier: Exchange_Business_Base_Counter Example: If you want to place a SPOT order for ADA/USDT on Binance exchange, you can use this unique identifier: "BINANCE_SPOT_ADA_USDT"; If you want to place a FUTURE order for ADA/USDT on OKX exchange, you can use this unique identifier: "OKX_FUTURE_ADA_USDT";

    »» side: Buy BUY Sell SELL

    »» qty: Base currency quantity Order quantity (mandatory, unless spot market buy)

    »» price: Price Limit order price (required for limit orders)

    »» time_in_force: Time in force Default GTC, supported types: GTC, IOC, FOK, POC

    »» quote_qty: Quote currency quantity Order quote quantity, only used for spot market buy orders

    »» reduce_only: Reduce only true, false

    »» position_side: Position side Not specified for single position. LONG, SHORT Enum values: LONG SHORT NONE

    Request example

    {
      "time": 1754272114,
      "event": "api",
      "channel": "place_order",
      "payload": {
        "text": "test1",
        "symbol": "GATE_FUTURE_ETH_USDT",
        "side": "BUY",
        "qty": "0.01",
        "price": "2800",
        "type": "LIMIT"
      }
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    place_order
    » event string true none Event
    api
    » payload object true none Place order request parameters
    »» order_id string true none Order ID
    »» text string true none Client ID
    » result object true none Place order result
    »» code string true none none
    »» message string true none none
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "place_order",
      "event": "api",
      "payload": {
        "order_id": "2072652940337152",
        "text": "2072652940337152"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168948
    }
    

    # Cancel Order

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body string Yes Order ID

    # Detailed Description

    » event: api

    » channel: cancel_order

    Request example

    {
      "time": 1754272114,
      "event": "api",
      "channel": "cancel_order",
      "payload": "2065058175870464"
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    cancel_order
    » event string true none Event
    api
    » result object true none Cancel order result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "cancel_order",
      "event": "api",
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168948
    }
    

    # Modify Order

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body object Yes none
    »» order_id body string Yes Order ID
    »» qty body string Yes Quantity
    »» price body string Yes
    »» symbol body string No

    # Detailed Description

    » event: api

    » channel: update_order

    Request example

    {
      "time": 1754272114,
      "event": "api",
      "channel": "update_order",
      "payload": {
        "order_id": "2065057827622656",
        "qty": "0.01",
        "symbol": "GATE_SPOT_BTC_USDT",
        "price": "2801"
      }
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    update_order
    » event string true none Event
    api
    » payload object true none none
    »» order_id string true none Order ID
    »» text string true none Client ID
    » result object true none Modify result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "update_order",
      "event": "api",
      "payload": {
        "order_id": "2072652940337152",
        "text": "2072652940337152"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168948
    }
    

    # Modify Leverage

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body object Yes none
    »» symbol body string Yes Trading pair
    »» leverage body string Yes Multiplier

    # Detailed Description

    » event: api

    » channel: set_leverage

    Request example

    {
      "time": 1754272114,
      "event": "api",
      "channel": "set_leverage",
      "payload": {
        "symbol": "GATE_FUTURE_ETH_USDT",
        "leverage": "5"
      }
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    set_leverage
    » event string true none Event
    api
    » payload object true none none
    »» symbol string true none Trading pair
    »» leverage string true none Multiplier
    » result object true none Modify result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "set_leverage",
      "event": "api",
      "payload": {
        "symbol": "GATE_FUTURE_ETH_USDT",
        "leverage": "10"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168948
    }
    

    # Modify Spot Margin Leverage

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body object Yes none
    »» symbol body string Yes Trading pair
    »» leverage body string Yes Multiplier

    # Detailed Description

    » event: api

    » channel: set_margin_leverage

    Request example

    {
      "time": 1754272114,
      "event": "api",
      "channel": "set_margin_leverage",
      "payload": {
        "symbol": "OKX_MARGIN_ADA_USDT",
        "leverage": "5"
      }
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    set_leverage
    » event string true none Event
    api
    » payload object true none none
    »» symbol string true none Trading pair
    »» leverage string true none Multiplier
    » result object true none Modify result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "set_margin_leverage",
      "event": "api",
      "payload": {
        "symbol": "OKX_MARGIN_ADA_USDT",
        "leverage": "10"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168948
    }
    

    # Change Account Contract Position Mode and Account Mode

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body object Yes none
    »» position_mode body string No Position mode
    »» account_mode body string No Account mode
    »» exchange_type body string No Exchange, default is cross-exchange

    # Detailed Description

    » event: api

    » channel: update_accounts

    »» position_mode: SINGLE/DUAL

    »» account_mode: CROSS_EXCHANGE/ISOLATED_EXCHANGE

    »» exchange_type: BINANCE/OKX/GATE/CROSSEX, when account mode is ISOLATED_EXCHANGE, exchange must be specified when modifying contract position mode

    Request example

    {
      "time": 1754272114,
      "event": "api",
      "channel": "update_accounts",
      "payload": {
        "account_mode":"ISOLATED_EXCHANGE",
        "position_mode": "DUAL",
        "exchange_type": "BINANCE"
      }
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    update_accounts
    » event string true none Event
    api
    » payload object true none none
    »» position_mode string false none Position mode
    »» account_mode string false none Account mode
    »» exchange_type string false none Exchange
    » result object true none Modify result
    »» code string true none Response code
    »» message string true none Response message
    » time integer true none Timestamp (seconds)
    » time_ms integer true none Timestamp (milliseconds)

    Response example

    {
      "channel": "update_accounts",
      "event": "api",
      "payload": {
        "account_mode":"ISOLATED_EXCHANGE",
        "position_mode": "DUAL",
        "exchange_type": "BINANCE"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168948
    }
    

    # Close Position Completely

    # Request Parameters

    Name Location Type Required Description
    » time body integer Yes Timestamp (seconds)
    » event body string Yes Event
    » channel body string Yes Channel name
    » payload body object Yes none
    »» symbol body string Yes Trading pair
    »» position_side body string No Position side

    # Detailed Description

    » event: api

    » channel: close_position

    Request example

    {
      "time": 1754272114,
      "event": "api",
      "channel": "close_position",
      "payload": {
        "symbol": "GATE_MARGIN_ETH_USDT",
        "position_side": "LONG"
      }
    }
    

    # Response Result

    Name Type Required Constraint Description
    » channel string true none Channel name
    close_position
    » event string true none Event
    api
    » payload object true none none
    »» order_id string true none Order ID
    »» text string true none Client ID

    Response example

    {
      "channel": "close_position",
      "event": "api",
      "payload": {
        "order_id": "2072652940337152",
        "text": "2072652940337152"
      },
      "result": {
        "code": "100000",
        "message": "success"
      },
      "time": 1756434168,
      "time_ms": 1756434168948
    }
    

    # Return Codes

    Return Code Description
    100000 Success
    100001 Missing or invalid parameters
    100002 Not logged in
    100003 Maximum connections reached
    100004 Timeout
    100005 Operation failed
    100006 Login failed
    100007 Network error, please try again later