Skip to content
LogoLogo

WebSocket /ws

Endpoint

WebSocket /ws

Trading selector: request.payload.action.type.

Subscriptions use subscription.type. Message format.

Purpose

Trade and receive private updates on one connection.

Trading actions

ActionUse it for
orderPlace limit orders.
cancelCancel by order ID.
cancelByCloidCancel by client order ID.
updateLeverageSet cross-margin leverage.

Private subscriptions

StreamUse it for
clearinghouseStatePositions and margin.
openOrdersCurrent orders.
userFillsFills.

Connection controls

subscribe · unsubscribe · ping

Authorization

The SDK signs requests. Raw post payloads need an owner or trading-agent signature; subscriptions need owner or reader auth. Browser messages use encrypted transport.

Permissions are checked before delivery. Expiry or revocation stops updates. Sign requests, not server updates. Ping grants no account access.

Request fields

FieldTypeRequiredMeaning
methodStringYes"post", "subscribe", "unsubscribe" or "ping".
idIntegerFor postDistinct request ID for correlation on this connection.
requestObjectFor posttype: "action" and payload containing the complete signed trading envelope; see post.
authObjectFor subscribe and unsubscribeTimestamp, random nonce and request signature; see authorization.
subscriptionObjectFor subscribe and unsubscribeSupported private subscription object; absent from the application ping.
subscription.typeStringFor subscribe and unsubscribe"clearinghouseState", "openOrders" or "userFills".
subscription.userAddressFor subscribe and unsubscribeCustomer account authorized by the request signer.
subscription.dexStringNoFor account-state and open-order subscriptions, omit or use "" for the default DEX.
subscription.aggregateByTimeBooleanNoFor fill subscriptions, omit or use false.

Request example

Example order. Use a fresh nonce and signature.

{
  "method": "post",
  "id": 256,
  "request": {
    "type": "action",
    "payload": {
      "action": {
        "type": "order",
        "orders": [
          {
            "a": 0,
            "b": true,
            "p": "100000",
            "s": "0.001",
            "r": false,
            "t": {
              "limit": {
                "tif": "Gtc"
              }
            },
            "c": "0x11111111111111111111111111111111"
          }
        ],
        "grouping": "na"
      },
      "nonce": 1796250000000,
      "signature": {
        "r": "0x1111111111111111111111111111111111111111111111111111111111111111",
        "s": "0x2222222222222222222222222222222222222222222222222222222222222222",
        "v": 27
      }
    }
  }
}

Response fields

FieldMeaning
channel"subscriptionResponse" for subscribe and unsubscribe acknowledgements; "pong" for an application ping response; "post" for action-post responses; otherwise the private subscription type.
dataPresent for action-post responses, acknowledgements and private data messages; absent from the application pong.
data.idEchoes the post request ID.
data.responseTyped action or error response for a post.
data.methodAcknowledged "subscribe" or "unsubscribe" method.
data.subscriptionSubscription object echoed in an acknowledgement.

Private stream data uses the wrappers documented for account state, open orders and customer fills.

Response example

Order response:

{
  "channel": "post",
  "data": {
    "id": 256,
    "response": {
      "type": "action",
      "payload": {
        "status": "ok",
        "response": {
          "type": "order",
          "data": {
            "statuses": [
              {
                "resting": {
                  "oid": 12345
                }
              }
            ]
          }
        }
      }
    }
  }
}

Constraints

  • Maximum eight active subscriptions. Default DEX only; aggregateByTime: true is unsupported. No public data or unrelated accounts.
  • New subscriptions receive an acknowledgement and initial data. Duplicates receive only an acknowledgement.
  • Accepted methods: post, subscribe, unsubscribe, ping. Posts accept the four supported trading actions only. Info, explorer and public-data posts are rejected; private queries and withdrawals use HTTP.
  • Reconnect with fresh signed subscriptions and refresh through /info. Full replay is not guaranteed.
  • Slow consumers, invalid requests or expired access can close the connection.