Skip to main content
GET
Upgrade scoped canonical unified WebSocket
Examples use illustrative identities and UTC times; the documentation cannot submit requests.

Authorization and upgrade

Connect to wss://api.liftx.io/v1/stream with a client that supports Authorization: Bearer ... in its WebSocket upgrade. read permission and current Pro/trial entitlement are required. There is no key query parameter or key-bearing WebSocket subprotocol. A library generates the nonce and validates the server’s accept value. This illustrative handshake uses the standard example nonce; a real client generates a fresh one.

HTTP 101

The upgrade does not itself select an account channel. After it succeeds, send the following controls as JSON text frames. State arrives in versioned binary application messages, not plain JSON WebSocket messages.

Subscribe to an authorized account

For a key permitting all instruments on the illustrative link 17:
Field names are exact, case-sensitive and unique. Send only the keys allowed for the operation and channel. Instrument-restricted keys cannot subscribe to link-wide balances, positions pages, private indexes or the history-hint channel; use permitted exact-instrument tickers and authorized exact-position HTTP reads instead. For an instrument-restricted key permitting the catalog’s illustrative BTC-USDT-SWAP:
Use a separate authorized connection for a different link. Do not send a catalog symbol from one link as authority for another account.

Server message example

An account positions-index response is a binary message with a seven-byte header: message type, little-endian payload length, protocol version and channel. For channel 4, version 1, its decoded JSON payload can be:
This is an instrument membership index, not a Position object or an order inventory. Preserve the exact generation string and revisions. Only a complete baseline supports later deltas. A gap, new epoch/generation or snapshot_required control invalidates dependent cached state. The stream guide specifies every channel, the seven-byte frame layout, balance/ticker binary codecs, JSON payload shapes, history correlation and bounded decoder example. Do not feed an entire binary WebSocket message directly to a JSON parser.

Resync and unsubscribe

Request a fresh index after detecting a gap:
Unsubscribe an exact ticker:
Balances, positions pages, tickers and history do not use index resync; rebuild them with the channel’s documented subscription/read flow. Keep bounded receive queues and reconstruct complete state before resuming decisions after reconnect.

Errors and connection end

Without read, the upgrade is refused with HTTP 403 and JSON:
Authentication, entitlement or capacity can also refuse the handshake. Check status and Content-Type before attempting to decode stream data. After HTTP 101, malformed/unauthorized controls or a slow consumer can close the stream generation; there is no new HTTP JSON error response inside the upgraded connection. Credential/entitlement expiry ends authorization at its deadline. Local revocation cancels the registered stream; periodic authority checks detect out-of-process changes. A disconnect is not evidence that trading positions were canceled or closed. Trading mutations still use POST /v1/commands. This stream carries canonical state, not a separate command execution path or a receipt subscription. Read command receipts for command progress and reconcile the affected position for actual effects.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Response

Success