{"templateId":"markdown","sharedDataIds":{},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"WebSocket API Overview","description":"Write your own software to control Collective2","keywords":"documentation,api,automated trading,Collective2 API Documentation","lang":"en-US","siteUrl":"https://c2-api.redocly.app/","meta":[{"name":"charset","content":"utf-8"}],"llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"websocket-api-overview","__idx":0},"children":["WebSocket API Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/ws"]}," to receive strategy signals, completed live fills, strategy position snapshots,"," ","and broker-account orders, positions, balances and settings. Historical queries remain"," ","available through REST."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"authorization","__idx":1},"children":["Authorization"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pass the API key in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization: Bearer YOUR_API_KEY"]}," during the HTTP upgrade."," ","Missing or invalid authentication returns HTTP 401 before the upgrade. Changes to API-key"," ","or account access can end a connection or remove a subscription."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"channels","__idx":2},"children":["Channels"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Channel"},"children":["Channel"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Payload"},"children":["Payload"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Delivery and recovery"},"children":["Delivery and recovery"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["strategy.signal"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One order/signal object"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Ordered stream with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["seq_id"]}," and bounded replay"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["strategy.live_fills"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["StrategyFillDTO"]}," object"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Completed live fills, with a separate cursor and bounded replay"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["strategy.positions"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Array of positions"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Full replacement snapshot initially and when changed. No replay"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-subscribe#account-orders"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account.orders"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Array of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OrderStatusDTO"]}," rows"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Initial working-order snapshot, then changed rows. Default refresh: 1 second"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-subscribe#account-positions"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account.positions"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Array of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PositionDTO"]}," rows"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Initial snapshot, then changed rows and zero-quantity closures. Default refresh: 1 second"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-subscribe#account-balance"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account.balance"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AccountBalanceDTO"]}," object"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Initial object, then the complete selected object on change. Default refresh: 60 seconds"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-subscribe#account-state"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account.state"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AccountStateDTO"]}," object with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["strategies"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Initial object, then the complete selected object on change. Default refresh: 60 seconds"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Refresh intervals are configurable and do not promise a message every interval."," ","Unchanged selected data produces no update. Several changes can collapse into one"," ","observation. An initial snapshot can be empty and is still a successful subscription."," ","Account channels have no ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["seq_id"]}," replay or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resume_from"]}," support; reconnect and resubscribe"," ","for fresh snapshots."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On the same connection and account/broker pair, live subscriptions to both account orders"," ","and positions receive the observed partial or final fill order update before its resulting"," ","position update. Position-only subscriptions do not require an order subscription."," ","Intermediate partial fills may not appear between updates. Initial snapshots are baselines rather than"," ","historical fill events. There is no ordering guarantee across separate sockets."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-subscribe"},"children":["Subscribing"]}," for JSON examples and complete-row client handling,"," ","and ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-gap-fill"},"children":["Recovery"]}," for the different recovery rules."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"limits","__idx":3},"children":["Limits"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Defaults are configurable per deployment. Strategy subscriptions retain their independent"," ","100-per-connection limit. Account subscriptions have a separate default limit of 2,000 per"," ","connection, including pending subscriptions. A channel/account/broker combination counts as"," ","one account subscription. Four channels for one account count as four. The default connection"," ","limit is 10 per API key."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"message-envelope","__idx":4},"children":["Message Envelope"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Envelope names are explicit, and DTO payloads use their WebSocket names: generally camelCase,"," ","with explicit names such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["strategy_id"]}," on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["StrategyFillDTO"]},". Null values are usually omitted."," ","See ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-subscribe#balance-fields"},"children":["Balance Fields"]}," for fields that remain present as"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}," when unavailable. REST schema casing does not determine WebSocket payload casing."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Meaning"},"children":["Meaning"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["msg_type"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Message/channel type"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unique server message ID for logging and deduplication. Ignored in client requests"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["seq_id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Cursor on replayable strategy signal/fill streams. Absent on account messages"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["request_id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Optional client correlation ID, at most 50 characters. Echoed on acknowledgements and correlated errors"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["timestamp"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["UTC ISO 8601 timestamp. Client timestamps must be within one minute of UTC"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Protocol version, currently ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["4"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Exact account name on account data messages"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["broker_id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["integer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Broker routing identifier on account data messages"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["is_snapshot"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["boolean"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," for an initial account baseline, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," for a later account update"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payload"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["object or array"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Message-specific data. Absent for messages such as heartbeats"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["broker_id"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["is_snapshot"]}," are absent from existing strategy/control messages."," ","Subscription account fields are inside ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payload"]},"; account data also carries routing fields"," ","in the envelope. Array payloads are valid, including ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[]"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Clients may send only ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["subscription.request"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["heartbeat.ack"]},". Other message types are"," ","server-only. See ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/guides/websocket-connect"},"children":["Connecting"]}," for a persistent multi-channel client,"," ","heartbeat handling and negotiated compression."]}]},"headings":[{"value":"WebSocket API Overview","id":"websocket-api-overview","depth":1},{"value":"Authorization","id":"authorization","depth":2},{"value":"Channels","id":"channels","depth":2},{"value":"Limits","id":"limits","depth":2},{"value":"Message Envelope","id":"message-envelope","depth":2}],"frontmatter":{"title":"WebSocket API Overview","description":"Strategy streams and account snapshots over one WebSocket connection","seo":{"title":"WebSocket API Overview"}},"lastModified":"2026-10-29T23:04:52.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/websocket-overview","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}