Skip to main content
Authenticate the socket to receive updates for the signed-in user. Message shapes are in WebSocket Protocol. No initial state is sent when the socket authenticates. Seed balances, positions, and orders from GET /execution/balances, GET /execution/positions, and GET /execution/orders, then apply socket updates. See Portfolio and Order lifecycle. A fill is the socket event order_event with event filled or partial_fill, and the webhook event trades.filled. See Webhooks.

Refresh-aware reconnect

The socket’s user session lasts as long as the access token. The gateway sends auth_expiring about a minute before expiry, and auth_expired when the session ends. Refresh the token and send authenticate again. When you reconnect, pass the last eventId you processed as resumeFrom, and events sent while you were away are replayed. Seed from REST only when the resumed frame says complete: false.
The SDK does all of this for you: client.createWebSocket() authenticates by message, refreshes on auth_expiring, resumes from the last eventId, de-duplicates, and reports onResumed.

Server-side: every user’s events

A backend can receive all users’ events for the app on one API-key connection instead of one socket per user. See App events.

WebSocket Protocol

Authenticated user-event frames.

Order lifecycle

Statuses to poll when the socket was down.

Portfolio

Activity and the leaderboard.

Webhooks

trades.filled on your server.