Server message spec
Basic server message structure
Description
Server messages are used to deliver results of client requests, real-time updates, or system errors. They are always wrapped in the server_message
envelope inside the message_type
field.
The server may respond with either a success payload or an error type, depending on the operation outcome.
JSON Structure (Success)
JSON Structure (Error)
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
Server message wrapper, with either success
or error
keys
UpdateBalanceErrorCode
This enum defines possible error reasons that can occur when updating an account balance through the update_balance
request.
Enum Variants
account_not_found
The specified account does not exist.
receiver_account_not_found
The target (receiver) account in a transfer was not found.
trading_settings_not_found
Trading configuration (e.g. profile) is missing or invalid.
not_enough_balance
The account does not have sufficient funds to complete the operation.
invalid_balance_transfer_amount
The provided amount is negative, zero, or otherwise invalid.
invalid_collateral
The collateral currency does not match the account or is unsupported.
account_duplicate
A duplicate account record was detected during processing.
sender_account_disabled
The sending account is disabled and cannot initiate a transfer.
reciever_account_disabled
The receiving account is disabled and cannot accept a transfer.
undefinded
An unknown or unspecified error occurred.
Enum: YftManagerApiServerMessageType
YftManagerApiServerMessageType
success
Contains a successful response or snapshot/update message
error
Contains an error code if the server fails to process request
YftServerMessageType
Description
YftServerMessageType<T>
is a generic envelope that defines the semantic context of a server message payload.
It can represent:
a full snapshot of current state (e.g. initial list of positions),
an event update (e.g. an order was created, canceled, updated),
a response to a direct client request.
This design allows clients to understand:
whether data is intended to replace the full state,
append to or modify it,
or simply acknowledge a request.
JSON Structure
Snapshot
Response to a request
General Event JSON Example
Example placeholders:
<payload_type>
:orders
,positions
,accounts
,last_prices
,trades
, etc.<event_type>
:snapshot
,created
,updated
,response
, etc.
Supported Event Types in YftServerMessageType<T>
YftServerMessageType<T>
Event Type
Description
Typical Use Case
snapshot
Represents the full current state of a resource
Initial list of positions or accounts
response
Direct reply to a specific client request (linked via message_response_id
)
Get orders / balances by request
created
A new entity has been created
New order, position placed. Account added.
updated
An existing entity has been modified
Order or position updated
canceled
An entity has been canceled
Order canceled by user or system
closed
A process has completed and the entity was closed
Position closed
executed
The entity has been executed
Order fully or partially executed
failed
The operation related to the entity failed
Order failed due to rejection
Struct: YftServerMessage<T>
data
Vec<T>
List of data items returned
AuthResult
The response to a successful authentication request. It confirms whether a session has been established and may include a session ID used for tracking or authorization purposes.
JSON Structure
Field Reference
message_id
string
Unique identifier of the message from the server.
message_type
string
Type of message, always "server_message"
in server responses.
message_response_id
string
ID of the original client request this message responds to.
session_id
string (optional)
The session ID issued upon successful authentication. May be null
if not used.
ServerTime
Returns the current server time. Used by clients to synchronize clocks, validate 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"
.
UpdateBalance
Used to confirm the result of a balance update operation (e.g., deposit, withdrawal, correction). This response either returns the updated account or an error code explaining why the update failed.
JSON Structure
Field Reference
ok
ManagerApiAccount
Present if the update was successful. Returns the full updated account.
err
UpdateBalanceErrorCode
Present if the update failed.
UpdateBalanceErrorCode
enum
Possible values: account_not_found
, invalid_balance_transfer_amount
, not_enough_balance
, etc.
Accounts
Returns a list of trading accounts associated with the authenticated trader. Each account contains full margin, balance, leverage, and configuration details.
JSON Response Structure
Field Reference
AccountBalabceOperation
The account_balance_operation
server message type communicates a change in a trader’s account balance. It may include both the updated account snapshot and the specific operation that caused the balance change, such as a trade, deposit, or commission.
This message is used for real-time event delivery and wraps data in one of the YftServerMessageType
variants such as created
, updated
, or response
.
JSON Structure
Field Explanation
account
ManagerApiAccount
The updated account state after applying the balance operation.
operation
ManagerApiAccountBalanceUpdateOperation | null
The balance-changing operation. Can be omitted in some cases.
Positions
Returns a list of active trading positions for a trader or account. These records are used to display open positions in the trading interface and to calculate margin, profit, and risk in real time.
JSON Response Structure
HistoryPositions
Returns a list of closed (historical) trading positions for a trader or account. These records are used for reporting, historical performance analysis, and audit trails.
JSON Response Structure
LastPrices
Returns the most recent bid/ask prices for a list of trading instruments. This data is used to display real-time market quotes and to calculate floating profit and margin requirements for open positions.
JSON Response Structure
Orders
Returns a list of active (pending) orders for a trader or account. This data is used to display open orders in the trading interface and to manage order execution, cancellation, or modification.
JSON Response Structure
Trades
Returns a list of executed trades for a trader or account. Trades represent matched executions from submitted orders and are used for reporting, profit calculations, and auditing.
JSON Response Structure
TradingGroups
Returns a list of available trading groups configured in the system. Trading groups define common parameters (e.g. leverage, margin requirements) and are typically assigned to accounts to control trading behavior and risk.
JSON Response Structure
TradingInstruments
Returns a list of trading instruments available in the system. Each instrument represents a tradable asset pair with specific settings used for pricing, trading limits, and UI rendering.
JSON Response Structure
TradingProfiles
Returns a list of trading profiles available in the system. A trading profile defines instrument-specific trading settings for a given trading group, including leverage, margin requirements, and commission rates.
JSON Response Structure
TradingMarkups
Returns a list of trading markup profiles used to adjust bid/ask prices for specific instruments and trading groups. Markups are typically applied to reflect spreads, fees, or risk management policies.
JSON Response Structure
DayOffProfiles
Returns a list of day-off profiles that define time-based trading restrictions. Each profile includes one or more time windows during which trading is disabled for specific instruments (e.g. weekends, holidays, maintenance periods).
JSON Response Structure
SubscribeConfirmed
Sent by the server to confirm a successful subscription to one or more data streams. This message indicates that the client is now registered to receive real-time updates.
JSON Response Structure
Last updated