User Synchronization
Use user/syncrequest to maintain real-time synchronization of user and account data. This is essential for accurate user and account updates, position and order tracking, risk management, and auto liquidation/admin alerts.
Signature and Overview
The JSON body for user/syncrequest looks like this:
Parameters
splitResponses(boolean, required) - Mandatory. Should betruefor any B2B vendor.users(number[], optional) - Optional. Do not use if usingshardingExpressionorentityTypes.accounts(number[], optional) - Optional. Do not use if using Socket Sharding.shardingExpression(object, optional) - Controls sharding behavior.divisor(number) - Total number of socket shards desired.remainder(number) - If userId or accountId divided by divisor has a remainder of 1, they will come to the socket with remainder: 1.expressionType(string) - Either"modAccountId"or"modUserId". Determines which entity type’s IDs are used for the modulus operation.
entityTypes(string[], optional) - List of entity types you wish to receive.
Important: You must specify entityTypes now; the default is an empty array! Pass strings such as "user", "account", "fill", "fillPair", and "order"; these are common examples, not a complete list. They control which updates you receive.
You will receive system events for users based on the expressionType in sharding config, but entityTypes will not filter them out. You’ll still receive signature events even if you aren’t telling entityTypes to watch for them.
Filter by Entity Type
To filter WebSocket updates by entity type, pass an entityTypes string array as described above.
This affects both the initial incoming dataset and the types of updates you receive over the socket’s lifetime.
If omitted, the default is an empty array. This means you will not get updates for most entity types, except some special system events.
Entity type values are not validated. A misspelled or unrecognized type (for example, fil instead of fill) is accepted silently and simply delivers no events for that type, so double-check your spelling.
Session Events
The userSessionStats entity updates every time a new authenticated session is created for the user, including plain REST sessions, not just new WebSocket connections. Because it is user-owned, the update fans out to all of that user’s subscribed sockets, so you may receive userSessionStats events without opening a new connection. These events are informational and are not a disconnect signal.
Sharding
What is Socket Sharding?
Sharding splits a workload among multiple instances to reduce load on any single actor. For our sockets, this means that if an actor fails, only a subset of users are affected.
Sharding Behavior
- An entity change occurs.
- The server looks at the entity ID and considers the
expressionTypeconfig option passed tosyncRequest. - The entity ID is divided by
divisor—the remainder controls which socket the event is published to. - Create or Update “props” event is fired.
- The vendor socket application processes the event.
- Only the socket with the correct remainder receives the event.
For example, socket A with divisor = 3, remainder = 1 only receives updates when entityId % divisor == 1.
Sharding Gotchas
remaindermust be less thandivisor. The server checks thatdivisoris greater than 0 andremainderis 0 or more, but it does not check thatremainderis less thandivisor. A shard with, for example,divisor: 3andremainder: 5is accepted and silently receives no events. Make sure your remainders cover0throughdivisor - 1.- User-scoped entities skip
modAccountIdshards. Entities owned by the user rather than an account (such asuserSessionanduserSessionStats) are not delivered tomodAccountIdshards. If you shard by account but also need user-level events, keep one additional unsharded (ormodUserId) connection to receive them.
Implementation Example
Set up sharded socket instances by determining the total number of desired shards and configuring that many sockets with corresponding remainders.

