Skip to content
LogoLogo

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.

ActionPayload and result
orderorder
cancelcancel
cancelByCloidcancelByCloid
updateLeverageupdateLeverage

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

FieldTypeRequiredMeaning
methodStringYes"post".
idIntegerYesClient-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.
requestObjectYesRequest type and signed trading payload.
request.typeStringYes"action".
request.payloadObjectYesComplete signed trading envelope.
request.payload.actionObjectYesOne of the four supported actions above.
request.payload.nonceUnsigned integerYesTrading nonce.
request.payload.signatureObjectYesSignature fields r, s and v.
request.payload.expiresAfterUnsigned integer or nullNoExpiry in Unix milliseconds, included in signing when non-null.
request.payload.vaultAddressNullNoOmit 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

FieldTypeMeaning
channelString"post".
dataObjectCorrelated response.
data.idIntegerEcho of the request's id.
data.responseObjectResult type and payload.
data.response.typeString"action" for an action result, or "error" for a request/transport error.
data.response.payloadObject or stringThe /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 channel and data.id; updates and responses can interleave or arrive out of order.
  • id only 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.