Private WebSockets
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
| Action | Use it for |
|---|---|
| order | Place limit orders. |
| cancel | Cancel by order ID. |
| cancelByCloid | Cancel by client order ID. |
| updateLeverage | Set cross-margin leverage. |
Private subscriptions
| Stream | Use it for |
|---|---|
| clearinghouseState | Positions and margin. |
| openOrders | Current orders. |
| userFills | Fills. |
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
| Field | Type | Required | Meaning |
|---|---|---|---|
method | String | Yes | "post", "subscribe", "unsubscribe" or "ping". |
id | Integer | For post | Distinct request ID for correlation on this connection. |
request | Object | For post | type: "action" and payload containing the complete signed trading envelope; see post. |
auth | Object | For subscribe and unsubscribe | Timestamp, random nonce and request signature; see authorization. |
subscription | Object | For subscribe and unsubscribe | Supported private subscription object; absent from the application ping. |
subscription.type | String | For subscribe and unsubscribe | "clearinghouseState", "openOrders" or "userFills". |
subscription.user | Address | For subscribe and unsubscribe | Customer account authorized by the request signer. |
subscription.dex | String | No | For account-state and open-order subscriptions, omit or use "" for the default DEX. |
subscription.aggregateByTime | Boolean | No | For 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
| Field | Meaning |
|---|---|
channel | "subscriptionResponse" for subscribe and unsubscribe acknowledgements; "pong" for an application ping response; "post" for action-post responses; otherwise the private subscription type. |
data | Present for action-post responses, acknowledgements and private data messages; absent from the application pong. |
data.id | Echoes the post request ID. |
data.response | Typed action or error response for a post. |
data.method | Acknowledged "subscribe" or "unsubscribe" method. |
data.subscription | Subscription 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: trueis 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.