WebSocket message format
Endpoint
WebSocket /ws
Selector: method: "post"
Purpose
Submits a signed trading action over the same connection used for private account subscriptions. request.payload is the signed request body accepted by POST /exchange.
| Action | Payload and result |
|---|---|
order | order |
cancel | cancel |
cancelByCloid | cancelByCloid |
updateLeverage | updateLeverage |
Authorization
Owner or permitted trading agent. Sign request.payload before wrapping it; the outer fields are not signed. The SDK handles this. HTTP and WebSocket share trading nonces.
Request fields
| Field | Type | Required | Meaning |
|---|---|---|---|
method | String | Yes | "post". |
id | Integer | Yes | Client-selected nonnegative safe integer (at most 9,007,199,254,740,991) used to correlate this request with its response. Use a distinct value for each outstanding request on the connection. |
request | Object | Yes | Request type and signed trading payload. |
request.type | String | Yes | "action". |
request.payload | Object | Yes | Complete signed trading envelope. |
request.payload.action | Object | Yes | One of the four supported actions above. |
request.payload.nonce | Unsigned integer | Yes | Trading nonce. |
request.payload.signature | Object | Yes | Signature fields r, s and v. |
request.payload.expiresAfter | Unsigned integer or null | No | Expiry in Unix milliseconds, included in signing when non-null. |
request.payload.vaultAddress | Null | No | Omit or use null; customer subaccount/vault routing is unsupported. |
See the action page for fields and limits.
Request example
Example GTC order. Replace the sample 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 | Type | Meaning |
|---|---|---|
channel | String | "post". |
data | Object | Correlated response. |
data.id | Integer | Echo of the request's id. |
data.response | Object | Result type and payload. |
data.response.type | String | "action" for an action result, or "error" for a request/transport error. |
data.response.payload | Object or string | The /exchange result for an action, or an error description string. |
Inspect the inner status and every child result. An "action" response can contain rejections; its payload follows the HTTP action schema.
Response example
Response for id: 256:
{
"channel": "post",
"data": {
"id": 256,
"response": {
"type": "action",
"payload": {
"status": "ok",
"response": {
"type": "order",
"data": {
"statuses": [
{
"resting": {
"oid": 12345
}
}
]
}
}
}
}
}
}Constraints
- Dispatch by
channelanddata.id; updates and responses can interleave or arrive out of order. idonly correlates requests. It is not an order ID, nonce, CLOID or idempotency key.- Assign a CLOID before sending. After timeout or disconnect, restore subscriptions and reconcile orderStatus, openOrders and fills before replacing an uncertain order.
- HTTP and WebSocket share action limits and permissions.
request.type: "info", explorer and public-data requests are rejected. Use HTTP for private /info queries and withdrawals.
Native formats: post and exchange.