Skip to main content

Order Operations

TL;DR/v1/stream is the sole bidirectional WebSocket. Authenticate in-band, stream framed order.place / order.cancel / order.modify requests and receive one reply per frame, dispatched to the same intake and verification the REST endpoints use. The same session carries orders, fills, and tree subscriptions, short-lived-token refresh, and cancel-on-disconnect for market makers.

Connect

The socket upgrades without credentials in the URL. Its first authenticated operation is a login frame. Set cancel_on_disconnect in that frame: Create it with the verified WebSocket factory returned by the same Node transport that handles REST. A stock WebSocket does not authenticate the engine’s self-signed, boot-scoped certificate.
The order signature is still requiredAuthenticating the socket establishes who is connected, not who owns an order. Every order.place / order.cancel / order.modify frame still carries the per-order trading-key signature (the same one the REST endpoints require). An authenticated socket cannot move another key’s orders.

Message format

Every frame is JSON, tagged by op. Requests may carry a request_id, which the reply echoes so a client can correlate responses on the multiplexed socket.

Request frames

Reply frames

Every reply carries a per-connection monotonic seq (starting at 1) so a client can detect a dropped frame.

Cancel-on-disconnect

When you login with cancel_on_disconnect: true, the engine tracks the orders placed on this socket and, when the socket closes, cancels the ones still resting. This protects a market maker that loses connectivity from leaving stale quotes crossing. You can also set an account-wide default so every socket gets the behavior without setting it in each login: PUT /account/settings with { "cancel_on_disconnect_default": true }. An explicit login value overrides the account default for that connection. The teardown is a server-initiated cancel using each order’s own booked key. It needs no client signature, because the order was placed on this authenticated session and a cancel only un-rests an order (it never settles or moves funds).
Orders that have already filled, expired, or been cancelled are left as-is; only still-resting orders from this session are swept.

Heartbeat

Send a ping frame periodically to keep the connection live and detect a half-open socket; the server replies pong. Transport-level WebSocket pings are also answered.

Example

REST vs. WebSocket

For live order state and fill memos, subscribe to the Orders Channel and Fills Channel on this same socket.