Server message spec
Basic server message structure
Description
Server messages are used to deliver:
Responses to client requests (e.g. account data, authentication result)
Real-time updates (e.g. price or position changes)
Snapshots of full entity lists (e.g. all accounts or trades)
System errors indicating problems with the request or processing
All messages are wrapped in the server_message field inside message_type.
There are two core categories of server messages:
Response messages – contain either a
successorerrorvalue and always includemessage_response_idlinking them to the original client requestEvent messages – broadcast snapshots or updates with
snapshotorupdatekeys; these do not includemessage_response_id
Each payload is grouped by topic (e.g., accounts, orders, positions, etc.).
Json Structure
Event Message
Used for broadcasting real-time updates or snapshots to all or subscribed clients.
Or for updates:
Or for errors
Response Messages
Used for responses to client-initiated requests (e.g., get_positions, auth_request, etc.).
Error Message
Server Message Envelope Fields
message_id
string
Unique UUID of the outgoing server message
message_response_id
string (opt)
UUID of the original client message (for responses)
message_type
object
Contains the server_message, which includes either a response or event payload
YftManagerApiServerMessage
Description
YftManagerApiServerMessage is the main enum used by the server to send any outgoing message.
Each variant wraps a payload using one of the following wrappers:
YftManagerApiServerResponse<T>Used for client request responses, containing either:
Success(T)Error(YftManagerApiErrorType)
YftManagerApiEventType<T, F>Used for event streams, containing either:
Snapshot(F)— full list (e.g. all orders)Update(T)— new or changed item(s)
This design allows the client to clearly understand:
If the message is a reply or an event
Whether to replace or merge data
How to handle errors contextually
Enum: YftManagerApiServerMessage
YftManagerApiServerMessageAuthResponse
Response to AuthRequest, wraps success or error
ServerTimeResponse
Response to GetServerTime
GetAccountsResponse
Response to GetAccounts, contains list of accounts
GetPositionsResponse
Response to GetPositions, contains list of positions
GetLastPriceResponse
Response to GetLastPrices, contains price list
UpdateBalanceResponse
Response to UpdateBalance, returns updated account
GetHistoryPositionsResponse
Response to GetHistoryPositions, contains historical positions
GetOrdersResponse
Response to GetOrders, returns order list
GetTradesResponse
Response to GetTrades, returns trade list
SubscribeResult
Response to Subscribe, indicates subscription success/failure
Accounts
Event: snapshot or update of account data
Positions
Event: snapshot or update of position data
HistoryPositions
Event: snapshot/update of historical positions
LastPrices
Event: snapshot or update of prices
Orders
Event: snapshot or update of orders
Trades
Event: snapshot or update of trades
TradingGroups
Event: snapshot or update of trading groups
TradingInstruments
Event: snapshot or update of instruments
TradingProfiles
Event: snapshot or update of trading profiles
TradingMarkups
Event: snapshot or update of markup profiles
DayOffProfiles
Event: snapshot or update of day-off profiles
Error Codes
When an operation fails, the error field in the response will contain one of the following string values from the YftManagerApiErrorType enum.
unauthorized
The client's request requires authentication.
auth_failed
Authentication failed due to an invalid secret key.
unknown_topic
The topic specified in a subscribe request does not exist.
network_error
An internal network error occurred while processing the request.
unexpected
An unexpected internal server error occurred.
invalid_message_format
The server could not parse the client's JSON message.
account_not_found
The specified account could not be found.
receiver_account_not_found
The destination account for a transfer could not be found.
day_off
The requested operation cannot be performed due to a trading holiday.
trading_group_not_found
The specified trading group does not exist.
asset_pair_trading_settings_not_found
Trading settings for the specified asset pair are missing.
not_enough_balance
The account has insufficient funds for the operation.
invalid_balance_transfer_amount
The amount for a balance transfer is invalid (e.g., zero or negative).
asset_pair_price_not_found
The price for the specified asset pair could not be found.
commission_price_not_found
Price required for commission calculation is missing.
margin_price_not_found
Price required for margin calculation is missing.
asset_pair_not_found
The specified asset pair does not exist.
profit_price_not_found
Price required for profit calculation is missing.
account_trading_disabled
Trading is disabled for the specified account.
no_liquidity
The order could not be executed due to a lack of liquidity.
invalid_sl
The provided Stop Loss value is invalid.
invalid_tp
The provided Take Profit value is invalid.
position_not_found
The specified position could not be found.
invalid_order_partial_execution_quantity
The quantity for a partial order execution is invalid.
trading_instrument_settings_not_found
Settings for the specified trading instrument are missing.
operation_not_support_for_this_order_type
The requested operation is not supported for this order type.
order_not_found
The specified order could not be found.
invalid_collateral
The specified collateral is invalid.
account_duplicate
An attempt was made to create an account that already exists.
invalid_leverage
The provided leverage value is invalid.
collateral_not_found_in_group_settings
The specified collateral is not configured for the trading group.
trading_account_settings_not_found
Settings for the specified trading account are missing.
lots_too_low
The order's lot size is below the allowed minimum.
lots_too_high
The order's lot size is above the allowed maximum.
invalid_desire_price
The desired price for a pending order is invalid.
sender_account_disabled
The sending account in a transfer is disabled.
reciever_account_disabled
The receiving account in a transfer is disabled.
convert_id_error
An error occurred while converting a numeric ID to a UUID.
sqlx_error
An internal database error occurred.
AuthResponse
The AuthResponse message is sent in reply to an AuthRequest.
It indicates whether the authentication was successful and, if so, includes session and user details.
Depending on the result, the response may contain either:
success: with a fullAuthResultJsonMessagepayloaderror: with a standardized error type fromYftManagerApiErrorType(e.g.,unauthorized,auth_failed)
JSON Structure
Field Reference
message_id
string
Unique ID of the outgoing server message
message_response_id
string
UUID of the original AuthRequest
message_type
object
Wraps server_message.auth_response
success.session_id
string
Session ID assigned to the authenticated client
error
string (enum)
Error code: unauthorized, auth_failed, etc.
ServerTime
Returns the current server time. Used by clients to synchronize clocks, measure latency, or test connectivity.
JSON Structure
Field Reference
message_id
string
Unique identifier of this server message.
message_type
string
Always "server_message" for server responses.
message_response_id
string
Corresponds to the original client message this is replying to.
server_time
string
Server time in ISO 8601 / RFC 3339 format, e.g. "2025-06-05T19:38:17.000+03:00".
GetAccountsResponse
Returns a list of trading accounts available to the authenticated user.
This message is a direct response to a GetAccounts request.
JSON Structure (Success)
JSON Structure (Error)
📑 Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original GetAccounts request
success
array
List of account objects available to the user
error
string
Error code if the request failed (unauthorized, etc.)
📌 See the ManagerApiAccount model for details on the account structure.
GetPositionsResponse
Returns a list of currently open trading positions for the authenticated user or account.
This message is a direct response to a GetPositions request.
JSON Structure (Success)
JSON Structure (Error)
📑 Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original GetPositions request
success
array
List of open positions
error
string
Error code if the request failed (unauthorized, etc.)
🔎 See the ManagerApiPosition model for details on the position structure.
ClosePositionResponse
Description
The response to a ClosePosition request.
On success, returns the closed ManagerApiOrder.
On failure, returns a general error code.
Success
Returns
ManagerApiOrder.
Error
Returns
Error.
Possible error values:
network_error– gRPC call failed (details logged).unexpected– No result returned (details logged).unauthorized- Authentication failed or user does not have permission to perform action.
UpdatePositionResponse
Description
The response to an UpdatePosition request.
On success, returns the updated ManagerApiPosition.
On failure, returns a general error code.
Success
Returns
ManagerApiPosition.
Error
Returns
Error.
Possible error values:
network_error– gRPC call failed (details logged).unexpected– No result returned (details logged).unauthorized- Authentication failed or user does not have permission to perform action.
GetHistoryPositionsResponse
Returns a list of historical (closed) trading positions for the authenticated user or account.
This message is a direct response to a GetHistoryPositions request.
JSON Structure (Success)
JSON Structure (Error)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original GetHistoryPositions request
success
array
List of closed (historical) trading positions
error
string
Error code if the request failed (unauthorized, etc.)
See the ManagerApiPosition model for details on the position structure.
GetLastPriceResponse
Returns the latest bid/ask prices for all available trading instruments.
This message is a direct response to a GetLastPrices request.
JSON Structure (Success)
JSON Structure (Error)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original GetLastPrices request
success
array
List of bid/ask price objects
error
string
Error code if the request failed (unauthorized, etc.)
See the ManagerApiBidAsk model for details on the bid/ask structure.
UpdateBalanceResponse
Returns updated account information along with the balance operation that caused the update (if any). This message is a direct response to an
UpdateBalancerequest.
JSON Structure (Success)
JSON Structure (Error)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original UpdateBalance request
success.operation
object | null
Balance operation that triggered the update (see ManagerApiAccountBalanceUpdateOperation).
error
string
Error code if the request failed (network_error, etc.)
See the ManagerApiAccount and ManagerApiAccountBalanceUpdateOperation model for details on the account structure.
GetOrdersResponse
Returns a list of active orders for the authenticated user or account.
This message is a direct response to a GetOrders request.
JSON Structure (Success)
JSON Structure (Error)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original GetOrders request
success
array
List of active order objects
error
string
Error code if the request failed (unauthorized, etc.)
See the ManagerApiOrder model for details on the order structure.
PlaceOrderResponse
Description
The response to a PlaceOrder request.
On success, returns a ManagerApiOrder object.
On failure, returns a general error code: either network_error or unexpected.
Success
Returns ManagerApiOrder.
Error
Returns
Error.
Possible error values:
network_error– gRPC call failed (exact reason is logged).unexpected– No result returned by the trading engine (also logged).unauthorized- Authentication failed or user does not have permission to perform action.
CancelOrderResponse
Description
The response to a CancelOrder request.
On success, returns the cancelled ManagerApiOrder.
On failure, returns a general error code.
Success
Returns
ManagerApiOrder.
Error
Returns
Error.
Possible error values:
network_error– gRPC call failed (details logged internally).unexpected– No result returned (details logged).unauthorized- Authentication failed or user does not have permission to perform action.
UpdateOrderResponse
Description
The response to an UpdateOrder request.
On success, returns the updated ManagerApiOrder.
On failure, returns a general error code.
Success
Returns
ManagerApiOrder.
Error
Returns
Error.
Possible error values:
network_error– gRPC call failed (details logged).unexpected– No result returned (details logged).unauthorized- Authentication failed or user does not have permission to perform action.
GetTradesResponse
Returns a list of trades executed for the authenticated user or account.
This message is a direct response to a GetTrades request.
JSON Structure (Success)
JSON Structure (Error)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original GetTrades request
success
array
List of executed trade objects
error
string
Error code if the request failed (unauthorized, etc.)
See the ManagerApiTrade model for details on the trade structure.
GetCollateralsResponse
This response returns a list of available collaterals in the system. These collaterals can be used for margin, balance calculations, or asset representation. Each item contains the identifier, name, and decimal precision of the asset.
JSON Structure
Field Description
id
string
Unique identifier of the collateral (e.g., "USD", "BTC").
name
string
Human-readable name of the collateral (e.g., "US Dollar").
digits
number
Number of decimal places supported for the collateral (e.g., 2 or 8).
See the ManagerApiCollateral model for details on the collateral structure.
GetBalanceOperationsResponse
This response provides a list of historical balance operations that have modified account balances — including deposits, withdrawals, trading-related updates, internal transfers, and corrections.
Each entry includes details such as the reason for the update, delta amount, and metadata for tracking and auditing.
JSON Structure
Field Description
id
UUID or\and Numeric ID
Unique identifier of the balance operation
trader_id
UUID or\and Numeric ID
ID of the trader who owns the affected account
account_id
UUID or\and Numeric ID
ID of the account impacted by the operation
reason
string
Reason for the operation, one of:
trading, deposit, withdrawal, transfer, balance_correction, commission, withdrawal_cancel
process_id
string
Identifier for the related processing batch or system event
delta
number
Amount added or subtracted (positive or negative)
date
number
Timestamp in milliseconds since the UNIX epoch
comment
string (optional)
Optional comment or metadata
reference_operation_id
UUID or\and Numeric ID (optional)
ID of a related operation, if this is a follow-up
See the ManagerApiAccountBalanceOperation model for details on the collateral structure
SubscribeResult
Indicates whether a client successfully subscribed to a specific data topic.
This message is a direct response to a Subscribe request.
JSON Structure (Success)
JSON Structure (Error)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
string
UUID of the original Subscribe request
success
boolean
true if the subscription was successful
error
string
Error code if the request failed (unknown_topic, unauthorized, etc.)
Calculation updates
Every ~200 milliseconds, the system performs an internal check to detect any changes in calculated values for trading accounts or open positions. These recalculations are typically triggered by price updates, trading activity, or margin shifts.
When differences are found, compact update messages are sent to all subscribed clients via the SubscriptionTopic::CalculateUpdates channel.
These updates do not include full entities — only the fields that were recalculated.
Account Calculation Updates
Delivered via:
YftManagerApiMessage → message_type::server_message::accounts → update::calculate_updates
This message includes a list of account updates, each containing:
account_id– the affected accountmargin– current used marginequity– current equityfree_margin– available free marginmargin_level– margin level (%)
JSON structure:
Position Calculation Updates
Delivered via:
YftManagerApiMessage → message_type::server_message::positions → update::calculate_updates
This message contains a list of position updates, with:
account_id– the account the position belongs toposition_id– the updated positiongross_pl– updated gross profit/loss
JSON structure:
These messages are lightweight, fast, and ideal for syncing just the essential real-time values with UI or monitoring systems.
Accounts
Broadcast message that delivers either the full list of accounts or incremental updates.
This is an event-type message and is not tied to a specific request (i.e., message_response_id is always null).
Subscription behavior
To start receiving account events, the client must subscribe to the
accountstopic.After a successful subscription, the server immediately pushes a snapshot (full list of current accounts).
Further changes are delivered as update events.
The payload may contain:
snapshot: full list of current accounts (Vec<ManagerApiAccount>)update: a single account-related change (ManagerApiAccountEvent)
JSON Structure (Snapshot)
JSON Structure (Update – Added)
JSON Structure (Update – Updated)
Or, when no balance operation is present:
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of accounts (ManagerApiAccount)
update
object
A single change described by ManagerApiAccountEvent
ManagerApiAccountEvent
Describes the nature of an account change:
added
A new account was created. Contains a ManagerApiAccount object
updated
An existing account was modified. Contains a ManagerApiAccount and an optional ManagerApiAccountBalanceUpdateOperation (e.g., deposit, withdrawal, correction)
calculate_updates
Contains updated margin-related values for multiple accounts. Holds a Vec<ManagerApiAccountCalculationUpdate> with recalculated fields like margin, equity, free_margin, and margin_level.
See the ManagerApiAccount, ManagerApiAccountBalanceUpdateOperation, ManagerApiAccountBalanceUpdate, ManagerApiAccountCalculationUpdate models for structure details.
Positions
Broadcast message that delivers either the full list of currently open positions or an incremental position update.
This is an event-type message and does not contain message_response_id.
Subscription behavior
To start receiving account events, the client must subscribe to the
positionstopic.After a successful subscription, the server immediately pushes a snapshot (full list of active positions).
Further changes are delivered as update events.
The payload may contain:
snapshot: list of all currently open positions (Vec<ManagerApiPosition>)update: a single position-related change (ManagerApiPositionEvent)
JSON Structure (Snapshot)
JSON Structure (Update – Created)
JSON Structure (Update – Updated)
JSON Structure (Update – Closed)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of open positions (ManagerApiPosition)
update
object
A single change described by ManagerApiPositionEvent
ManagerApiPositionEvent
Describes the nature of a position change:
created
A new position was opened
updated
An existing position was updated (e.g. SL/TP, volume, etc.)
closed
The position was closed
calculate_updates
Contains updated profit/loss values for multiple positions. Holds a Vec<ManagerApiPositionCalculationUpdate> with recalculated fields like gross_pl.
Each variant contains a full ManagerApiPosition object.
See the ManagerApiPosition model for structure details.
HistoryPositions
Broadcast message that delivers either a full snapshot or an update of closed (historical) trading positions. This is an event-type message and is not tied to a specific client request.
The payload may contain:
snapshot: full list of historical positions (Vec<ManagerApiPosition>)update: partial update (subset of closed positions, typically aVec<ManagerApiPosition>as well)
⚠️ Unlike live positions, there is no separate event enum here — both
snapshotandupdateuse plain array ofManagerApiPosition.
JSON Structure (Snapshot)
JSON Structure (Update)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of historical positions
update
array
Subset of new/updated closed positions
See the ManagerApiPosition model for details on the position structure.
LastPrices
Broadcast message that delivers either a full snapshot or an update of the latest bid/ask prices. This is an event-type message used for real-time price feeds.
The payload may contain:
snapshot: full list of the latest prices for all instrumentsupdate: subset of instruments whose prices have changed
Both snapshot and update contain arrays of ManagerApiBidAsk objects.
JSON Structure (Snapshot)
JSON Structure (Update)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Latest known prices for all trading instruments
update
array
Price changes for one or more instruments
See the ManagerBidAsk model for details on the price structure.
Orders
Broadcast message that delivers either the full list of currently active orders or an incremental order change. This is an event-type message and is not tied to a specific client request.
Subscription behavior
To start receiving account events, the client must subscribe to the
orderstopic.After a successful subscription, the server immediately pushes a snapshot (full list of active orders).
Further changes are delivered as update events.
The payload may contain:
snapshot: full list of currently active ordersupdate: a single order-related event (create, cancel, execute, etc.)
JSON Structure (Snapshot)
JSON Structure (Update – Examples)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of active orders
update
object
A single order-related event (ManagerApiOrderEvent)
ManagerApiOrderEvent
Represents a change to a single order. The event can be one of the following:
created
A new order was placed
updated
An existing order was modified
canceled
An order was canceled
executed
An order was fully or partially filled
failed
The order was rejected or failed to execute
Each variant contains a full ManagerApiOrder object.
See the ManagerApiOrder model for details on the order structure.
TradingGroups
Broadcast message that delivers either the full list of trading groups or an incremental update. This is an event-type message and is not tied to a specific request.
Subscription behavior
To start receiving account events, the client must subscribe to the
trading_settingstopic.After a successful subscription, the server immediately pushes a snapshot (full list of trading group).
Further changes are delivered as update events.
The payload may contain:
snapshot: full list of available trading groupsupdate: subset of added or changed trading groups
Both snapshot and update are arrays of ManagerApiTradingGroup objects.
JSON Structure (Snapshot)
JSON Structure (Update)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of trading groups
update
array
Newly added or changed trading groups
See the ManagerApiTradingGroup model for details on the trading group structure.
TradingInstruments
Broadcast message that delivers either the full list of trading instruments or an incremental update. This is an event-type message and is not tied to a specific request.
Subscription behavior
To start receiving account events, the client must subscribe to the
trading_settingstopic.After a successful subscription, the server immediately pushes a snapshot (full list of trading instruments).
Further changes are delivered as update events.
The payload may contain:
snapshot: full list of available instrumentsupdate: subset of newly added or modified instruments
Both snapshot and update are arrays of ManagerApiTradingInstrument objects.
JSON Structure (Snapshot)
JSON Structure (Update)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of available trading instruments
update
array
Newly added or updated trading instruments
See the ManagerApiTradingInstrument model for details on the instrument structure.
TradingProfiles
Broadcast message that delivers either the full list of trading profiles or an incremental update. This is an event-type message and is not tied to a specific client request.
Subscription behavior
To start receiving account events, the client must subscribe to the
trading_settingstopic.After a successful subscription, the server immediately pushes a snapshot (full list of trading profiles).
Further changes are delivered as update events.
The payload may contain:
snapshot: full list of trading profilesupdate: subset of newly added or modified profiles
Both snapshot and update are arrays of ManagerApiTradingProfile objects.
JSON Structure (Snapshot)
JSON Structure (Update)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of trading profiles
update
array
Newly added or updated trading profiles
See the ManagerApiTradingProfile model for details on the profile structure.
TradingMarkups
Broadcast message that delivers either the full list of trading markup profiles or an incremental update. This is an event-type message and is not tied to any client request.
Subscription behavior
To start receiving account events, the client must subscribe to the
trading_settingstopic.After a successful subscription, the server immediately pushes a snapshot (full list of trading markaps).
Further changes are delivered as update events.
The payload may contain:
snapshot: full list of markup profilesupdate: subset of newly added or modified markup profiles
Both snapshot and update are arrays of ManagerApiMarkupProfile objects.
JSON Structure (Snapshot)
JSON Structure (Update)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of markup profiles
update
array
Newly added or updated markup profiles
See the ManagerApiMarkupProfile model for details on the markup structure.
DayOffProfiles
Broadcast message that delivers either the full list of trading day-off profiles or an incremental update. This is an event-type message and is not tied to any specific request.
Subscription behavior
To start receiving account events, the client must subscribe to the
trading_settingstopic.After a successful subscription, the server immediately pushes a snapshot (full list of day of profiles).
Further changes are delivered as update events.
The payload may contain:
snapshot: full list of day-off profilesupdate: subset of newly added or modified profiles
Both snapshot and update are arrays of ManagerApiDayOffProfile objects.
JSON Structure (Snapshot)
JSON Structure (Update)
Field Reference
message_id
string
Unique identifier of this server message
message_response_id
null
Always null for event messages
snapshot
array
Full list of trading day-off profiles
update
array
Newly added or updated day-off profiles
See the ManagerApiDayOffProfile model for details on the profile structure.
Collateral
This message delivers collateral snapshot or update events from the server to the client. It reflects changes or initial state of available collateral assets used in margin trading, account balances, and valuation.
Subscription behavior
To start receiving account events, the client must subscribe to the
trading_settingstopic.After a successful subscription, the server immediately pushes a snapshot (full list of collateral).
Further changes are delivered as update events.
The event type can be either:
snapshot– full current state of all available collateralsupdate– changes to the existing list (e.g., new collateral added, updated precision or name)
JSON Structure
Or:
Field Description
id
string
Unique identifier of the collateral asset (e.g., "USD", "ETH")
name
string
Human-readable name of the asset (e.g., "US Dollar", "Ethereum")
digits
number
Number of decimal places supported for this asset (e.g., 2, 8)
See the ManagerApiCollateral model for details on the collateral structure.
Last updated