# Objects Every JSON shape the API sends or takes. ## Account The password is write-only: never returned, stored encrypted with a per-install key. | Field | Type | Description | |---|---|---| | `id` | string | Your id for the account, used in every URL. a-z, 0-9 and -, up to 48 characters. (required) | | `label` | string | Display name. (required) | | `login` | integer | MT5 login number. (required) | | `server` | string | Trade server name, for example Pepperstone-Demo. (required) | | `host` | string | Web terminal host the session connects to. (required) | | `port` | integer | Port, usually 443. (required) | | `symbols` | array of string | Symbols kept subscribed for live prices (the watchlist). (required) | | `enabled` | boolean | When false the server keeps the account but does not connect it. (required) | | `created_at` | integer | When the account was added, unix seconds (UTC). (required) | | `tls_name` | string or null | For an IP access point: the name on the gateway's certificate. null for a named host. (required) | | `trade_real` | boolean | Whether trading is allowed when the broker reports this account as real money (account type real or preliminary). Off by default: every route that needs the trade scope then answers 403 real_account. Demo and contest accounts trade either way, and reading is never affected. (required) | | `new_trades_paused` | boolean | New trades are paused (0.6.0): an order that would open something answers 403 trading_paused and is not sent; closing, changing stops and cancelling still work. (required) | | `pinned` | boolean | The gateway's certificate key was pinned by an admin (see the server directory). (required) | | `status` | object | (required; see AccountStatus) | | `clock` | string or null | How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds _utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock. (required; one of ny7, utc, None) | ```json { "id": "pepperstone-12345678", "label": "Pepperstone demo", "login": 12345678, "server": "Pepperstone-Demo", "host": "mt5-demo01.pepperstone.com", "port": 443, "symbols": [ "XAUUSD", "EURUSD" ], "enabled": true, "created_at": 1790881742, "tls_name": null, "trade_real": false, "new_trades_paused": false, "clock": null, "pinned": false, "status": { "connected": true, "since": 1790968298, "reconnects": 0, "ping_ms": 14.2, "server_build": 6090, "last_error": null, "subscribed": 2, "login_rejected": false, "retry_at": null } } ``` ## AccountStatus | Field | Type | Description | |---|---|---| | `connected` | boolean | Whether the session to the broker is up right now. (required) | | `since` | integer or null | Unix seconds (UTC) when the current connection came up. null while disconnected. (required) | | `reconnects` | integer | Automatic reconnects since the server started. (required) | | `ping_ms` | number or null | Last heartbeat round trip in milliseconds. null before the first one. (required) | | `server_build` | integer or null | MT5 build the broker's server reported. null before the first login. (required) | | `last_error` | string or null | Why the last connection attempt failed or the connection dropped. null while connected. (required) | | `subscribed` | integer | Number of symbols with a live price subscription. (required) | | `login_rejected` | boolean | True after the broker refused the login. A refusal within an hour of losing a working connection (a broker restarting refuses logins with code 2 for seconds to minutes) is tried again after 10, 20, 30 and 60 s, then every minute for code 2 until an hour after the loss (0.6.3), then every 5 minutes; any other refusal only every 5 minutes, so a wrong password cannot get the account locked. (required) | | `retry_at` | integer or null | Unix seconds (UTC) of the next connection attempt while disconnected, else null. (required) | ```json { "connected": true, "since": 1790968298, "reconnects": 0, "ping_ms": 14.2, "server_build": 6090, "last_error": null, "subscribed": 2, "login_rejected": false, "retry_at": null } ``` ## AccountCreate | Field | Type | Description | |---|---|---| | `id` | string | Your id for the account: a-z, 0-9 and -, up to 48 characters. Defaults to the server's first word and the login, for example pepperstone-12345678. | | `label` | string | Display name. Defaults to the server and login. | | `login` | integer | MT5 login number (a numeric string also works). (required) | | `password` | string | MT5 password (master or investor). Write-only. (required) | | `server` | string | Trade server name exactly as the broker spells it. (required) | | `host` | string | Web terminal host. Looked up from server (this install's directory, then the built-in list) when omitted; 400 if it cannot be found. | | `port` | integer | Port. Defaults to the directory's port, else 443. | | `tls_name` | string | For an IP access point: the name on its certificate. Defaults to the directory's for that host. | | `symbols` | array of string | Symbols to keep subscribed (the watchlist). | | `enabled` | boolean | false saves the account without connecting it. (default true) | | `trade_real` | boolean | Allow trading when the broker reports the account as real money. Off by default; demo and contest accounts trade either way. (default false) | | `clock` | string or null | How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds _utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock. (one of ny7, utc, None) | ```json { "label": "Pepperstone demo", "login": 12345678, "password": "your MT5 password", "server": "Pepperstone-Demo", "symbols": [ "XAUUSD", "EURUSD" ] } ``` ## AccountPatch Send only the fields you want to change. | Field | Type | Description | |---|---|---| | `label` | string | Display name. | | `password` | string | New MT5 password. Write-only. Logs in again. | | `server` | string | Trade server name. Logs in again; the host is looked up when host is not sent. | | `host` | string | Web terminal host. Logs in again. | | `port` | integer | Port. Logs in again. | | `tls_name` | string | The name on the gateway's certificate, for an IP access point; an empty string clears it. Logs in again. | | `symbols` | array of string | Replaces the whole watchlist and starts streaming new symbols without logging in again. | | `enabled` | boolean | false logs out and parks the account, true connects it again. | | `trade_real` | boolean | true allows trading when the broker reports the account as real money; false turns it off again. Takes effect at once, without logging in again. | | `new_trades_paused` | boolean | true refuses orders that would open something (403 trading_paused, not sent) while closing, changing stops and cancelling still work; false lets them through again (0.6.0). At once, no new login. | | `clock` | string or null | How the trade server's clock relates to UTC, for the *_utc fields (0.7.0): ny7 (New York plus 7 hours on the US calendar: IC Markets, Pepperstone), utc (Exness), or null for none. With a rule, answers and streams carry time_utc beside time, time_utc_msc beside time_msc (and the same for time_setup, time_done, time_update, and expiration_utc beside a pending order's expiration), each worked out by itself from the time-zone database; a time in New York's repeated autumn hour uses the earlier offset and adds _utc_ambiguous: true. Without one, no UTC fields: Termless never guesses a broker's clock. null takes it away; at once, open streams too. (one of ny7, utc, None) | ```json { "symbols": [ "XAUUSD", "EURUSD", "GBPUSD" ] } ``` ## Summary | Field | Type | Description | |---|---|---| | `login` | integer | MT5 login number. (required) | | `name` | string | Account holder name at the broker. (required) | | `server` | string | Trade server name. (required) | | `company` | string | Broker company name. (required) | | `currency` | string | Deposit currency. (required) | | `leverage` | integer | Leverage, for example 200 for 1:200. (required) | | `balance` | number | Balance without open positions. (required) | | `credit` | number | Credit from the broker. (required) | | `profit` | number | Floating profit of open positions, live. (required) | | `equity` | number | balance + credit + profit, live. (required) | | `margin` | number | Margin in use, live. (required) | | `margin_free` | number | equity - margin. (required) | | `margin_level` | number | equity / margin x 100, in percent. 0 with no margin in use. (required) | | `margin_so_call` | number | Margin call level. (required) | | `margin_so_so` | number | Stop out level. (required) | | `trade_allowed` | boolean | Whether the broker allows trading on this account. (required) | | `demo` | boolean | True for a demo account. (required) | | `hedging` | boolean | True for a hedging account, false for netting. (required) | | `server_offset` | integer | Trade server clock, in seconds east of UTC. Subtract it from any market or trade time to get UTC. From the account record, read again at least hourly, and checked against live ticks (a tick's server time minus its arrival, to the quarter hour): when they disagree the ticks win while a tick agreed in the last 10 minutes, then the record. It is the offset now; times from before the broker's last summer-time switch were stamped with the old one. (required) | | `positions` | integer | Open positions. (required) | | `orders` | integer | Pending orders. (required) | ```json { "login": 12345678, "name": "Demo Trader", "server": "Pepperstone-Demo", "company": "Pepperstone Group Limited", "currency": "USD", "leverage": 200, "balance": 10412.58, "credit": 0.0, "profit": 238.11, "equity": 10650.69, "margin": 878.93, "margin_free": 9771.76, "margin_level": 1211.78, "margin_so_call": 100.0, "margin_so_so": 50.0, "trade_allowed": true, "demo": true, "hedging": true, "server_offset": 10800, "positions": 3, "orders": 2 } ``` ## SymbolBrief | Field | Type | Description | |---|---|---| | `name` | string | Symbol name, for example XAUUSD. (required) | | `description` | string | Broker's description. (required) | | `path` | string | Folder in the broker's symbol tree. (required) | | `digits` | integer | Price decimals. (required) | ```json { "name": "XAUUSD", "description": "Gold vs US Dollar", "path": "Metals\\XAUUSD", "digits": 2 } ``` ## SymbolSpec With the broker's group overrides applied. | Field | Type | Description | |---|---|---| | `name` | string | Symbol name. (required) | | `description` | string | Broker's description. (required) | | `path` | string | Folder in the broker's symbol tree. (required) | | `digits` | integer | Price decimals. (required) | | `point` | number | Smallest price step, 10^-digits. (required) | | `contract_size` | number | Units per 1.00 lot. (required) | | `tick_size` | number | Smallest price change. The point when the broker does not send one. (required) | | `tick_value` | number or null | Value of one tick_size move for 1.00 lot, in the account currency. The broker's own figure, else worked out as the terminal does: tick_size x contract_size, converted from currency_profit to the account currency, for forex, CFD, leveraged CFD and exchange stock symbols. null when the broker sends none and it cannot be worked out (futures and index CFDs, or no conversion symbol). Pepperstone sends neither tick value nor tick size. (required) | | `currency_base` | string | Base currency. (required) | | `currency_profit` | string | Profit currency. (required) | | `currency_margin` | string | Margin currency. (required) | | `volume_min` | number | Smallest order, in lots. (required) | | `volume_max` | number | Largest order, in lots. (required) | | `volume_step` | number | Lot step. (required) | | `volume_limit` | number | Largest total of open positions and pending orders in one direction, in lots. 0 = no limit. (required) | | `trade_mode` | string | Whether trading is allowed. unknown only for a value MetaTrader does not define. (required; one of full, long_only, short_only, close_only, disabled, unknown) | | `execution` | string | Execution mode. unknown only for a value MetaTrader does not define. (required; one of market, instant, request, exchange, unknown) | | `filling` | array of string | Filling modes the symbol allows. (required; one of fok, ioc, return) | | `stops_level` | integer | Minimum distance of SL and TP from the price, in points. (required) | | `freeze_level` | integer | Distance in points inside which orders cannot be changed. (required) | | `swap_long` | number | Swap for long positions, in the unit swap_mode names. (required) | | `swap_short` | number | Swap for short positions, in the unit swap_mode names. (required) | | `swap_mode` | string | The unit of swap_long and swap_short. unknown only for a value MetaTrader does not define. (required; one of disabled, points, symbol_currency, margin_currency, deposit_currency, interest_current, interest_open, reopen_current, reopen_bid, profit_currency, unknown) | | `swap_3day` | string or null | The day the swap is charged three times: sunday, monday, tuesday, wednesday, thursday, friday or saturday. null for none (crypto CFDs send none). (required) | | `margin_initial` | number | Initial margin setting of the symbol, as the broker sends it. (required) | | `margin_maintenance` | number | Maintenance margin setting, as the broker sends it. (required) | | `margin_hedged` | number | Margin for a hedged pair of positions (one lot each way), as the broker sends it. (required) | | `margin_rate_buy` | number | Initial margin rate for a buy (the same as margin_rates.buy). (required) | | `margin_rate_sell` | number | Initial margin rate for a sell (the same as margin_rates.sell). (required) | | `margin_rates` | object | Every order type's initial margin rate, as the broker sends it. A pending type's rate is what the broker holds while such an order waits: the brokers seen send 0 there (nothing is held), and once the order fills the position needs its side's market rate. A market rate of 0 counts as 1. (required; object: buy, sell, buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit, sell_stop_limit) | | `expiration` | array of string | The expiry modes a pending order on this symbol may use. (required; one of gtc, day, specified, specified_day) | | `order_types` | array of string | The order types the symbol takes. (required; one of market, limit, stop, stop_limit, sl, tp, close_by) | | `sessions` | object | (required; object: quote, trade) | | `tradeable` | boolean or null | Whether a trade can be opened now, as on /quotes: the trade_mode is full, long_only or short_only, and one of today's trade sessions is open by the server's clock. null when the broker sent no trade sessions. (required) | | `book_depth` | integer | The levels a side of the symbol's order book may hold (0 when the broker sends none); a book past it is renewed (0.7.0). | ```json { "name": "XAUUSD", "description": "Gold vs US Dollar", "path": "Metals\\XAUUSD", "digits": 2, "point": 0.01, "contract_size": 100, "tick_size": 0.01, "tick_value": 1.0, "currency_base": "XAU", "currency_profit": "USD", "currency_margin": "XAU", "volume_min": 0.01, "volume_max": 100, "volume_step": 0.01, "volume_limit": 0, "trade_mode": "full", "execution": "market", "filling": [ "fok", "ioc" ], "stops_level": 0, "freeze_level": 0, "swap_long": -6.2, "swap_short": 1.4, "swap_mode": "points", "swap_3day": "wednesday", "margin_initial": 0.0, "margin_maintenance": 0.0, "margin_hedged": 50.0, "margin_rate_buy": 1.0, "margin_rate_sell": 1.0, "margin_rates": { "buy": 1.0, "sell": 1.0, "buy_limit": 0.0, "sell_limit": 0.0, "buy_stop": 0.0, "sell_stop": 0.0, "buy_stop_limit": 0.0, "sell_stop_limit": 0.0 }, "expiration": [ "gtc", "day", "specified", "specified_day" ], "order_types": [ "market", "limit", "stop", "stop_limit", "sl", "tp", "close_by" ], "sessions": { "quote": [ [], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [] ], "trade": [ [], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [ [ 0, 1440 ] ], [] ] }, "tradeable": true } ``` ## Quote | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name. (required) | | `bid` | number or null | Bid price. null when the symbol has no price yet. (required) | | `ask` | number or null | Ask price. null when the symbol has no price yet. (required) | | `last` | number or null | Last deal price. 0 for most forex and CFD symbols; null when the symbol has no price yet. (required) | | `time` | integer or null | Unix seconds, trade server clock. (required) | | `time_msc` | integer or null | Unix milliseconds, trade server clock. (required) | | `tradeable` | boolean or null | Whether a trade can be opened now: the symbol's trade_mode is full, long_only or short_only, and one of today's trade sessions is open by the server's clock. null when the broker sent no trade sessions. (required) | ```json { "symbol": "XAUUSD", "bid": 2391.42, "ask": 2391.6, "last": 0, "time": 1790981179, "time_msc": 1790981179473, "tradeable": true } ``` ## Candles | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name, as the broker spells it. (required) | | `timeframe` | string | Timeframe. (required; one of M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1) | | `candles` | array of Candle | Bars, oldest first. Each says whether it is complete. (required; see Candle) | ```json { "symbol": "XAUUSD", "timeframe": "M5", "candles": [ { "time": 1790980500, "open": 2394.31, "high": 2395.1, "low": 2390.58, "close": 2392.41, "tick_volume": 2330, "real_volume": 0, "spread": 0, "complete": true }, { "time": 1790980800, "open": 2392.41, "high": 2394.19, "low": 2392.29, "close": 2393.97, "tick_volume": 834, "real_volume": 0, "spread": 0, "complete": false } ] } ``` ## Candle | Field | Type | Description | |---|---|---| | `time` | integer | Bar open time, unix seconds, trade server clock. (required) | | `open` | number | Open. (required) | | `high` | number | High. (required) | | `low` | number | Low. (required) | | `close` | number | Close. (required) | | `tick_volume` | integer | Tick count in the bar. (required) | | `real_volume` | integer | Exchange volume. 0 for most CFD symbols. (required) | | `spread` | integer | Always 0: the web protocol's bars carry no spread (MetaTrader builds bars from the bid). (required) | | `complete` | boolean | The bar has closed, by the server's clock (a month bar closes at the next month's start). The newest bar is usually still forming, but at a weekend or a daily break it may be closed too: read this rather than dropping the last bar. (required) | | `time_utc` | integer | Bar open time in UTC, unix seconds; only with the account's clock rule (0.7.0). | | `time_utc_ambiguous` | boolean | true when the time falls in New York's repeated autumn hour (0.7.0). | ## Tick A price change: the data of `event: tick` on the SSE stream. With the account's clock rule (0.7.0), UTC fields come beside it (see the account's clock). (time_utc_msc) | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name. (required) | | `bid` | number | Bid price. (required) | | `ask` | number | Ask price. (required) | | `last` | number | Last deal price. 0 for most forex and CFD symbols. (required) | | `time_msc` | integer | Unix milliseconds, trade server clock. (required) | ```json { "symbol": "XAUUSD", "bid": 2391.42, "ask": 2391.6, "last": 0, "time_msc": 1790981179473 } ``` ## StreamStatus The data of `event: status` on the SSE stream: sent first, then whenever connected changes, and once more (connected false, with a reason) when the stream ends. | Field | Type | Description | |---|---|---| | `connected` | boolean | Whether the account is connected to the broker. (required) | | `ping_ms` | number or null | Last heartbeat round trip in milliseconds. (required) | | `id` | string | Only on the first status, and only when the stream follows trades or orders: where the stream starts in the account's trade event numbering. The client's own cursor when it resumed (after= or Last-Event-ID), else the newest event id (:0 before the first event), so a client holds a cursor before any trade happens. On SSE the same value is the event's id: line. | | `reason` | string | Only on the last status before the stream ends. account changed: the account was deleted or logs in with new details; server stopping: the server is shutting down; key revoked, key changed, signed out (0.6.0): the key that opened it was deleted or may no longer read this account, or the dashboard session ended. Reconnect to follow the account (EventSource does this by itself). (one of account changed, server stopping, key revoked, key changed, signed out) | ```json { "connected": true, "ping_ms": 14.2, "id": "1790968290117:40" } ``` ## TradeEvent The data of a `trade` event (`events=trades`): one per broker trade push, as it is applied, numbered per account. An order push carries `order`, `state` and `pending`; a deal push carries `deal`, `balance`, `credit` and usually `position`; a position update carries `position` only; a deal caught up after a gap carries `deal` and `caught_up: true`. For a market order show the deal; for a pending order show its order events (`pending: true`) and, when it fills, the deal; a position update needs no line of its own. | Field | Type | Description | |---|---|---| | `seq` | integer | 1, 2, 3, ... per account. The newest 1,024 events are kept in the database, so the numbering carries on across a restart or an upgrade; it starts again only when the account is added again or logs in to another broker account (login or server). (required) | | `id` | string | :, epoch being the unix ms when this numbering began. On SSE also the event's id: line, which EventSource sends back as Last-Event-ID; any client can resume with after=, from before a restart too. (required) | | `what` | string | What happened. For a pending order (kind order): placed, modified or removed while it is live; filled, cancelled, expired, rejected (or done) when it moves to history. For a deal (kind deal): opened, partial, closed, reversed, or balance for a balance, credit or commission deal. For kind position: updated. (required; one of placed, modified, removed, filled, cancelled, expired, rejected, done, opened, partial, closed, reversed, balance, deal, updated) | | `kind` | string | order for an order push, deal for a deal push, position for a position the broker changed without a deal (its SL or TP moved, or the step just before a close; the broker sends it as a deal record with ticket 0 and balance 0, which before 0.2.2 came out as a phantom deal opened). (required; one of order, deal, position) | | `pending` | boolean | With kind order: true for a limit, stop or stop-limit order, false for a market buy or sell (or a close-by). A market order is placed, taken off the book and filed as filled (or cancelled) in the same moment, each step an order event with pending false and, once done, volume 0 (volume_initial is what was asked); a UI shows the deal event for it and skips these. | | `order` | object | (see Order) | | `state` | string | With kind order: the order's MetaTrader state. (one of started, placed, cancelled, partial, filled, rejected, expired, request, unknown) | | `deal` | object | (see Deal) | | `position` | object | With kind deal: the position the deal touched; with kind position: the position that changed. With an extra `open`. A closed one (open false) carries its last known values (open price, SL, TP, time, comment, magic) with volume 0, where the broker sends zeros. Absent for a balance deal. (object: ticket, symbol, side, volume, price_open, price_current, sl, tp, profit, swap, commission, comment, magic, reason, identifier, time, time_msc, time_update, open) | | `positions` | array of Position | Other positions the same push updated (a netting account). (see Position) | | `balance` | number | With kind deal: the account's balance after the deal. Never on kind position, nor on a caught_up deal. | | `credit` | number | With kind deal: the account's credit after the deal. Never on kind position, nor on a caught_up deal. | | `caught_up` | boolean | Present and true on a deal the broker made during a gap (the broker link was down, the server was stopped, or the account's session started again) and that was read back from the account's history after it: kind deal with `what` and `deal` only (a close is partial while its position is still open), oldest first, before the gap's resync. A deal already sent is never sent again, and nothing older than the oldest event the server keeps for the account (or the start of its numbering) is sent. Up to 7 days back and 500 deals; more than that sends only the resync. | ```json { "seq": 42, "id": "1790968290117:42", "what": "opened", "kind": "deal", "deal": { "ticket": 81200118, "order": 51830012, "position_id": 51830012, "symbol": "XAUUSD", "type": "buy", "entry": "in", "volume": 0.2, "price": 2385.0, "profit": 0.0, "commission": -0.7, "swap": 0.0, "fee": 0.0, "magic": 0, "comment": "breakout", "reason": "web", "time": 1790975498, "time_msc": 1790975498123 }, "balance": 10412.58, "credit": 0.0, "position": { "ticket": 51830012, "symbol": "XAUUSD", "side": "buy", "volume": 0.2, "price_open": 2385.0, "price_current": 2385.0, "sl": 2380.0, "tp": 2420.0, "profit": 0.0, "swap": 0.0, "commission": -0.7, "comment": "breakout", "magic": 0, "reason": "web", "identifier": 51830012, "time": 1790975498, "time_msc": 1790975498123, "time_update": 1790975498, "open": true } } ``` ## Resync The data of a `resync` event (with events=trades; WebSocket: type resync): trade events were or may have been missed and cannot be replayed. Read positions, orders and deals again, then go on from `id`. After a gap the deals the broker made meanwhile come first as trade events marked `caught_up`; pending orders placed or removed and stops moved during the gap have no history, so the resync still follows them. | Field | Type | Description | |---|---|---| | `seq` | integer | Its place in the account's numbering: its own seq for a resync the server recorded (after a gap: the broker link came back, the server restarted, the account's session started again; or when the server fell behind the broker), else the newest seq when it was sent. (required) | | `id` | string | :. Carry on from this id. (required) | | `reason` | string | Why. Recorded in the numbering (and replayed like trade events): "the broker link came back; ...", "the server restarted; ...", "the account's session started again; ..." (each after the deals made during the gap, sent first as trade events marked caught_up), "the server fell behind the broker's trade pushes". Sent to one client only: "that id is from another numbering (the account now logs in to another broker account, or its kept events were lost)" (an id from another epoch: the account was added again, or logs in to another broker account), "that id is newer than anything this account has sent", "more happened since that id than the server keeps", "this stream fell behind; read the account again". (required) | ```json { "seq": 49, "id": "1790968290117:49", "reason": "the broker link came back; its trade pushes sent while it was down are not replayed (the deals made meanwhile came first, marked caught_up)" } ``` ## TradesSince The answer of GET /trades: the account's numbered trade events for a client that polls instead of streaming. | Field | Type | Description | |---|---|---| | `id` | string | The newest event's id (:0 before the first). Ask again with after=. (required) | | `events` | array of object | The events after `after`, oldest first: each a TradeEvent or a Resync with `event` beside its fields. Without after: every event kept (up to 1,024). Empty when resync is set. (required; object: event) | | `resync` | string or null | null, or why the events since after cannot be given (another epoch: the account was added again or logs in to another broker account; an id newer than anything sent; more happened than the server keeps). Then read positions, orders and deals again and carry on from id. A restart of the server does not change the epoch: an id from before it still resumes. (required) | ```json { "id": "1790968290117:43", "events": [ { "event": "trade", "seq": 42, "id": "1790968290117:42", "what": "opened", "kind": "deal", "deal": { "ticket": 81200118, "order": 51830012, "position_id": 51830012, "symbol": "XAUUSD", "type": "buy", "entry": "in", "volume": 0.2, "price": 2385.0, "profit": 0.0, "commission": -0.7, "swap": 0.0, "fee": 0.0, "magic": 0, "comment": "breakout", "reason": "web", "time": 1790975498, "time_msc": 1790975498123 }, "balance": 10412.58, "credit": 0.0, "position": { "ticket": 51830012, "symbol": "XAUUSD", "side": "buy", "volume": 0.2, "price_open": 2385.0, "price_current": 2385.0, "sl": 2380.0, "tp": 2420.0, "profit": 0.0, "swap": 0.0, "commission": -0.7, "comment": "breakout", "magic": 0, "reason": "web", "identifier": 51830012, "time": 1790975498, "time_msc": 1790975498123, "time_update": 1790975498, "open": true } }, { "event": "trade", "seq": 43, "id": "1790968290117:43", "what": "updated", "kind": "position", "position": { "ticket": 51830012, "symbol": "XAUUSD", "side": "buy", "volume": 0.2, "price_open": 2385.0, "price_current": 2391.42, "sl": 2386.0, "tp": 2420.0, "profit": 128.4, "swap": -1.12, "commission": -1.4, "comment": "breakout", "magic": 0, "reason": "web", "identifier": 51830012, "time": 1790975498, "time_msc": 1790975498123, "time_update": 1790981102, "open": true } } ], "resync": null } ``` ## AccountSnapshot The data of an `account` event (`events=account`): the account summary with live profit, equity and margin, right after the stream opens and then whenever a value changed, checked every 500 ms at most. | Field | Type | Description | |---|---|---| | `login` | integer | MT5 login number. (required) | | `name` | string | Account holder name at the broker. (required) | | `server` | string | Trade server name. (required) | | `company` | string | Broker company name. (required) | | `currency` | string | Deposit currency. (required) | | `leverage` | integer | Leverage, for example 200 for 1:200. (required) | | `balance` | number | Balance without open positions. (required) | | `credit` | number | Credit from the broker. (required) | | `profit` | number | Floating profit of open positions, live. (required) | | `equity` | number | balance + credit + profit, live. (required) | | `margin` | number | Margin in use, live. (required) | | `margin_free` | number | equity - margin. (required) | | `margin_level` | number | equity / margin x 100, in percent. 0 with no margin in use. (required) | | `margin_so_call` | number | Margin call level. (required) | | `margin_so_so` | number | Stop out level. (required) | | `trade_allowed` | boolean | Whether the broker allows trading on this account. (required) | | `demo` | boolean | True for a demo account. (required) | | `hedging` | boolean | True for a hedging account, false for netting. (required) | | `server_offset` | integer | Trade server clock, in seconds east of UTC. Subtract it from any market or trade time to get UTC. From the account record, read again at least hourly, and checked against live ticks (a tick's server time minus its arrival, to the quarter hour): when they disagree the ticks win while a tick agreed in the last 10 minutes, then the record. It is the offset now; times from before the broker's last summer-time switch were stamped with the old one. (required) | | `positions` | integer | Open positions. (required) | | `orders` | integer | Pending orders. (required) | | `time_ms` | integer | When it was computed, unix milliseconds (UTC). (required) | ```json { "login": 12345678, "name": "Demo Trader", "server": "Pepperstone-Demo", "company": "Pepperstone Group Limited", "currency": "USD", "leverage": 200, "balance": 10412.58, "credit": 0.0, "profit": 238.11, "equity": 10650.69, "margin": 878.93, "margin_free": 9771.76, "margin_level": 1211.78, "margin_so_call": 100.0, "margin_so_so": 50.0, "trade_allowed": true, "demo": true, "hedging": true, "server_offset": 10800, "positions": 3, "orders": 2, "time_ms": 1790981179473 } ``` ## PositionsSnapshot The data of a `positions` event (`events=positions`): every open position with live P/L, on the same 500 ms rhythm as `account`, only when something changed. A UI never computes P/L itself. | Field | Type | Description | |---|---|---| | `positions` | array of Position | Every open position with live profit and price_current. (required; see Position) | | `time_ms` | integer | When it was computed, unix milliseconds (UTC). (required) | ```json { "positions": [ { "ticket": 51830012, "symbol": "XAUUSD", "side": "buy", "volume": 0.2, "price_open": 2385.0, "price_current": 2391.42, "sl": 2380.0, "tp": 2420.0, "profit": 128.4, "swap": -1.12, "commission": -1.4, "comment": "breakout", "magic": 0, "reason": "web", "identifier": 51830012, "time": 1790975498, "time_msc": 1790975498123, "time_update": 1790975498 } ], "time_ms": 1790981179473 } ``` ## WsMessage What the server sends on the WebSocket, one JSON object per message, told apart by type. First a status, then subscribed, then any trade events replayed for `after=` (or a resync), then ticks (and the trade, account, positions and orders events asked for with `events=`; orders right after subscribed and the replay); status again whenever connected changes. *status* | Field | Type | Description | |---|---|---| | `type` | string | Connection state. (required) | | `connected` | boolean | Whether the account is connected to the broker. (required) | | `ping_ms` | number or null | Last heartbeat round trip in milliseconds. (required) | | `id` | string | Only on the first status, when the socket follows trades or orders: where it starts in the account's trade event numbering (as on SSE). | | `reason` | string | Only on the last status before the socket closes: account changed (deleted, or logs in with new details), server stopping, or (0.6.0) key revoked, key changed, signed out. (one of account changed, server stopping, key revoked, key changed, signed out) | *subscribed* | Field | Type | Description | |---|---|---| | `type` | string | The symbols now streaming, after the open or a subscribe/unsubscribe. (required) | | `symbols` | array of string | Every symbol on this socket. (required) | *tick* | Field | Type | Description | |---|---|---| | `type` | string | A price change. (required) | | `symbol` | string | Symbol name. (required) | | `bid` | number | Bid price. (required) | | `ask` | number | Ask price. (required) | | `last` | number | Last deal price. 0 for most forex and CFD symbols. (required) | | `time_msc` | integer | Unix milliseconds, trade server clock. (required) | *gap* | Field | Type | Description | |---|---|---| | `type` | string | Ticks this socket missed. (required) | | `reason` | string | behind: this stream fell behind and kept only the newest tick per symbol; reconnect: the broker link was down; fanout: the account's fan-out fell behind the session. (required; one of behind, reconnect, fanout) | | `symbols` | array of string | behind: the symbols that lost ticks; otherwise every symbol of the stream. (required) | | `dropped` | integer or null | behind: how many ticks this stream lost; null when nobody can count them. (required) | | `from_msc` | integer | behind: the first dropped tick's time; otherwise the last tick this stream got before. Ticks' own clock. (required) | | `to_msc` | integer | behind: the last dropped tick's time; otherwise the first tick after, which follows this event. (required) | | `from_utc_msc` | integer | from_msc in UTC; only with the account's clock rule (0.7.1). | | `to_utc_msc` | integer | to_msc in UTC; only with the account's clock rule (0.7.1). | | `from_utc_ambiguous` | boolean | true when from_msc falls in New York's repeated autumn hour (0.7.1). | | `to_utc_ambiguous` | boolean | true when to_msc falls in New York's repeated autumn hour (0.7.1). | *bar* | Field | Type | Description | |---|---|---| | `type` | string | A bar of a series (with events=bars). (required) | | `symbol` | string | Symbol name. (required) | | `timeframe` | string | Timeframe. (required; one of M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1) | | `time` | integer | Bar open time, unix seconds, trade server clock. (required) | | `open` | number | Open. (required) | | `high` | number | High. (required) | | `low` | number | Low. (required) | | `close` | number | Close. (required) | | `tick_volume` | integer | Tick count in the bar. (required) | | `real_volume` | integer | Exchange volume. (required) | | `state` | string | forming: built from the bids, at most four a second per series; closed: the broker's bar once its period ended (plus 2 s), sent once per period, or later for a period whose tick came late (0.7.1: bars can arrive out of time order, place each by time); corrected: the broker's bar differs from the one sent (read again a minute later, or after the server clock went back). (required; one of forming, closed, corrected) | *bars_gap* | Field | Type | Description | |---|---|---| | `type` | string | Bars a series cannot send. (required) | | `symbol` | string | Symbol name. (required) | | `timeframe` | string | Timeframe. (required; one of M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1) | | `from` | integer | The first missed bar's open time. (required) | | `to` | integer | The last missed bar's open time. (required) | | `from_utc` | integer | from in UTC; only with the account's clock rule (0.7.1). | | `to_utc` | integer | to in UTC; only with the account's clock rule (0.7.1). | | `from_utc_ambiguous` | boolean | true when from falls in New York's repeated autumn hour (0.7.1). | | `to_utc_ambiguous` | boolean | true when to falls in New York's repeated autumn hour (0.7.1). | *bars* | Field | Type | Description | |---|---|---| | `type` | string | The bar series now on the socket, after a bars or unbars message (0.7.0). (required) | | `series` | array of string | Every series, SYMBOL:TF. (required) | *trade* | Field | Type | Description | |---|---|---| | `type` | string | A broker trade push (with events=trades). (required) | | `seq` | integer | 1, 2, 3, ... per account. The newest 1,024 events are kept in the database, so the numbering carries on across a restart or an upgrade; it starts again only when the account is added again or logs in to another broker account (login or server). (required) | | `id` | string | :, epoch being the unix ms when this numbering began. On SSE also the event's id: line, which EventSource sends back as Last-Event-ID; any client can resume with after=, from before a restart too. (required) | | `what` | string | What happened. For a pending order (kind order): placed, modified or removed while it is live; filled, cancelled, expired, rejected (or done) when it moves to history. For a deal (kind deal): opened, partial, closed, reversed, or balance for a balance, credit or commission deal. For kind position: updated. (required; one of placed, modified, removed, filled, cancelled, expired, rejected, done, opened, partial, closed, reversed, balance, deal, updated) | | `kind` | string | order for an order push, deal for a deal push, position for a position the broker changed without a deal (its SL or TP moved, or the step just before a close; the broker sends it as a deal record with ticket 0 and balance 0, which before 0.2.2 came out as a phantom deal opened). (required; one of order, deal, position) | | `pending` | boolean | With kind order: true for a limit, stop or stop-limit order, false for a market buy or sell (or a close-by). A market order is placed, taken off the book and filed as filled (or cancelled) in the same moment, each step an order event with pending false and, once done, volume 0 (volume_initial is what was asked); a UI shows the deal event for it and skips these. | | `order` | object | (see Order) | | `state` | string | With kind order: the order's MetaTrader state. (one of started, placed, cancelled, partial, filled, rejected, expired, request, unknown) | | `deal` | object | (see Deal) | | `position` | object | With kind deal: the position the deal touched; with kind position: the position that changed. With an extra `open`. A closed one (open false) carries its last known values (open price, SL, TP, time, comment, magic) with volume 0, where the broker sends zeros. Absent for a balance deal. (object: ticket, symbol, side, volume, price_open, price_current, sl, tp, profit, swap, commission, comment, magic, reason, identifier, time, time_msc, time_update, open) | | `positions` | array of Position | Other positions the same push updated (a netting account). (see Position) | | `balance` | number | With kind deal: the account's balance after the deal. Never on kind position, nor on a caught_up deal. | | `credit` | number | With kind deal: the account's credit after the deal. Never on kind position, nor on a caught_up deal. | | `caught_up` | boolean | Present and true on a deal the broker made during a gap (the broker link was down, the server was stopped, or the account's session started again) and that was read back from the account's history after it: kind deal with `what` and `deal` only (a close is partial while its position is still open), oldest first, before the gap's resync. A deal already sent is never sent again, and nothing older than the oldest event the server keeps for the account (or the start of its numbering) is sent. Up to 7 days back and 500 deals; more than that sends only the resync. | *resync* | Field | Type | Description | |---|---|---| | `type` | string | Missed trade events cannot be replayed (with events=trades). (required) | | `seq` | integer | Its place in the account's numbering: its own seq for a resync the server recorded (after a gap: the broker link came back, the server restarted, the account's session started again; or when the server fell behind the broker), else the newest seq when it was sent. (required) | | `id` | string | :. Carry on from this id. (required) | | `reason` | string | Why. Recorded in the numbering (and replayed like trade events): "the broker link came back; ...", "the server restarted; ...", "the account's session started again; ..." (each after the deals made during the gap, sent first as trade events marked caught_up), "the server fell behind the broker's trade pushes". Sent to one client only: "that id is from another numbering (the account now logs in to another broker account, or its kept events were lost)" (an id from another epoch: the account was added again, or logs in to another broker account), "that id is newer than anything this account has sent", "more happened since that id than the server keeps", "this stream fell behind; read the account again". (required) | *account* | Field | Type | Description | |---|---|---| | `type` | string | The account summary, live (with events=account). (required) | | `login` | integer | MT5 login number. (required) | | `name` | string | Account holder name at the broker. (required) | | `server` | string | Trade server name. (required) | | `company` | string | Broker company name. (required) | | `currency` | string | Deposit currency. (required) | | `leverage` | integer | Leverage, for example 200 for 1:200. (required) | | `balance` | number | Balance without open positions. (required) | | `credit` | number | Credit from the broker. (required) | | `profit` | number | Floating profit of open positions, live. (required) | | `equity` | number | balance + credit + profit, live. (required) | | `margin` | number | Margin in use, live. (required) | | `margin_free` | number | equity - margin. (required) | | `margin_level` | number | equity / margin x 100, in percent. 0 with no margin in use. (required) | | `margin_so_call` | number | Margin call level. (required) | | `margin_so_so` | number | Stop out level. (required) | | `trade_allowed` | boolean | Whether the broker allows trading on this account. (required) | | `demo` | boolean | True for a demo account. (required) | | `hedging` | boolean | True for a hedging account, false for netting. (required) | | `server_offset` | integer | Trade server clock, in seconds east of UTC. Subtract it from any market or trade time to get UTC. From the account record, read again at least hourly, and checked against live ticks (a tick's server time minus its arrival, to the quarter hour): when they disagree the ticks win while a tick agreed in the last 10 minutes, then the record. It is the offset now; times from before the broker's last summer-time switch were stamped with the old one. (required) | | `positions` | integer | Open positions. (required) | | `orders` | integer | Pending orders. (required) | | `time_ms` | integer | When it was computed, unix milliseconds (UTC). (required) | *positions* | Field | Type | Description | |---|---|---| | `type` | string | Every open position, live (with events=positions). (required) | | `positions` | array of Position | Every open position with live profit and price_current. (required; see Position) | | `time_ms` | integer | When it was computed, unix milliseconds (UTC). (required) | *orders* | Field | Type | Description | |---|---|---| | `type` | string | Every pending order (with events=orders). (required) | | `orders` | array of Order | Every pending order (limit, stop, stop limit), as `GET /orders` lists them. (required; see Order) | | `time_ms` | integer | When it was read, unix milliseconds (UTC). (required) | *error* | Field | Type | Description | |---|---|---| | `type` | string | A message the server could not act on. (required) | | `message` | string | What went wrong. (required) | ```json { "type": "status", "connected": true, "ping_ms": 14.2, "id": "1790968290117:40" } ``` ## WsCommand What a client may send on the WebSocket. The answer is subscribed with the whole list, or an error. | Field | Type | Description | |---|---|---| | `subscribe` | array of string | Symbols to add (at most 200 on one socket). | | `unsubscribe` | array of string | Symbols to drop. Applied before subscribe when both are sent. | | `bars` | array of string | Bar series to add, SYMBOL:TF (0.7.0; the socket must be opened with events=bars). At most 100 a socket. | | `unbars` | array of string | Bar series to drop (0.7.0). | ```json { "subscribe": [ "GBPUSD" ] } ``` ## Position | Field | Type | Description | |---|---|---| | `ticket` | integer | Position ticket. (required) | | `symbol` | string | Symbol name. (required) | | `side` | string | Direction. (required; one of buy, sell) | | `volume` | number | Lots. (required) | | `price_open` | number | Open price. (required) | | `price_current` | number | Current close price (bid for a buy, ask for a sell). (required) | | `sl` | number | Stop loss price, 0 when none. (required) | | `tp` | number | Take profit price, 0 when none. (required) | | `profit` | number | Floating profit in the deposit currency, live. (required) | | `swap` | number | Swap so far. (required) | | `commission` | number | Commission so far. (required) | | `comment` | string | Comment. The broker keeps 31 characters; for an order sent through Termless with a longer comment, Termless keeps the full text and puts it back here when the broker's is its start. (required) | | `magic` | integer | Magic number. The web protocol cannot send one, so the broker stores 0; for an order sent through Termless with a magic number, Termless keeps it and puts it back here (the broker's own wins when it is not 0). (required) | | `reason` | string | Why it came about: client (a desktop terminal), mobile, web (anything sent through Termless), expert, sl and tp (closed at the stop loss or take profit), stop_out, and rarer ones. The wire carries the trade server's own numbers (web 17, SL 3, TP 4), not the official DEAL_REASON_* values, so read the word. (required; one of client, mobile, web, expert, sl, tp, stop_out, rollover, vmargin, split, corporate_action, dealer, gateway, signal, settlement, transfer, sync, external_client, external_service, migration, unknown) | | `identifier` | integer | Position id; the deals of this position carry it as position_id. (required) | | `time` | integer | Open time, unix seconds, trade server clock. (required) | | `time_msc` | integer | Open time, unix milliseconds, trade server clock. (required) | | `time_update` | integer | Last change, unix seconds, trade server clock. (required) | ```json { "ticket": 51830012, "symbol": "XAUUSD", "side": "buy", "volume": 0.2, "price_open": 2385.0, "price_current": 2391.42, "sl": 2380.0, "tp": 2420.0, "profit": 128.4, "swap": -1.12, "commission": -1.4, "comment": "breakout", "magic": 0, "reason": "web", "identifier": 51830012, "time": 1790975498, "time_msc": 1790975498123, "time_update": 1790975498 } ``` ## Order | Field | Type | Description | |---|---|---| | `ticket` | integer | Order ticket. (required) | | `symbol` | string | Symbol name. (required) | | `type` | string | Order type. `GET /orders` and `orders` events list pending orders only (limit, stop, stop limit); in a `trade` event a market order is `buy` or `sell` (with `pending: false`). (required; one of buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit, sell_stop_limit, buy, sell, close_by) | | `side` | string | Direction. (required; one of buy, sell) | | `volume` | number | Lots still to fill. (required) | | `volume_initial` | number | Lots when placed. (required) | | `price` | number | Trigger price. (required) | | `stop_limit` | number | Limit price for stop limit orders, 0 otherwise. (required) | | `sl` | number | Stop loss price, 0 when none. (required) | | `tp` | number | Take profit price, 0 when none. (required) | | `expiration` | integer | Expiry, unix seconds, trade server clock. 0 = good till cancelled. (required) | | `comment` | string | Comment. The broker keeps 31 characters; for an order sent through Termless with a longer comment, Termless keeps the full text and puts it back here when the broker's is its start. (required) | | `magic` | integer | Magic number. The web protocol cannot send one, so the broker stores 0; for an order sent through Termless with a magic number, Termless keeps it and puts it back here (the broker's own wins when it is not 0). An order that closed a tagged position (its stop, its target) gets the magic but keeps its own comment. (required) | | `reason` | string | Why it came about: client (a desktop terminal), mobile, web (anything sent through Termless), expert, sl and tp (closed at the stop loss or take profit), stop_out, and rarer ones. The wire carries the trade server's own numbers (web 17, SL 3, TP 4), not the official DEAL_REASON_* values, so read the word. (required; one of client, mobile, web, expert, sl, tp, stop_out, rollover, vmargin, split, corporate_action, dealer, gateway, signal, settlement, transfer, sync, external_client, external_service, migration, unknown) | | `time_setup` | integer | When the order was placed, unix seconds, trade server clock. (required) | | `time_setup_msc` | integer | When the order was placed, unix milliseconds, trade server clock. (required) | ```json { "ticket": 51830020, "symbol": "XAUUSD", "type": "buy_limit", "side": "buy", "volume": 0.1, "volume_initial": 0.1, "price": 2365.0, "stop_limit": 0, "sl": 2350.0, "tp": 2410.0, "expiration": 0, "comment": "dip buy", "magic": 0, "reason": "web", "time_setup": 1790977698, "time_setup_msc": 1790977698412 } ``` ## HistoryOrder An order that left the book (GET /orders/history): the order shape plus how and when it ended and its position. | Field | Type | Description | |---|---|---| | `ticket` | integer | Order ticket. (required) | | `symbol` | string | Symbol name. (required) | | `type` | string | Order type. Market orders are filed here too: buy, sell or close_by. (required; one of buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit, sell_stop_limit, buy, sell, close_by) | | `side` | string | Direction. (required; one of buy, sell) | | `volume` | number | Lots left unfilled when it left the book (0 for a filled order). (required) | | `volume_initial` | number | Lots when placed. (required) | | `price` | number | Trigger price. (required) | | `stop_limit` | number | Limit price for stop limit orders, 0 otherwise. (required) | | `sl` | number | Stop loss price, 0 when none. (required) | | `tp` | number | Take profit price, 0 when none. (required) | | `expiration` | integer | Expiry, unix seconds, trade server clock. 0 = good till cancelled. (required) | | `comment` | string | Comment. The broker keeps 31 characters; for an order sent through Termless with a longer comment, Termless keeps the full text and puts it back here when the broker's is its start. (required) | | `magic` | integer | Magic number. The web protocol cannot send one, so the broker stores 0; for an order sent through Termless with a magic number, Termless keeps it and puts it back here (the broker's own wins when it is not 0). An order that closed a tagged position (its stop, its target) gets the magic but keeps its own comment. (required) | | `reason` | string | Why it came about: client (a desktop terminal), mobile, web (anything sent through Termless), expert, sl and tp (closed at the stop loss or take profit), stop_out, and rarer ones. The wire carries the trade server's own numbers (web 17, SL 3, TP 4), not the official DEAL_REASON_* values, so read the word. (required; one of client, mobile, web, expert, sl, tp, stop_out, rollover, vmargin, split, corporate_action, dealer, gateway, signal, settlement, transfer, sync, external_client, external_service, migration, unknown) | | `time_setup` | integer | When the order was placed, unix seconds, trade server clock. (required) | | `time_setup_msc` | integer | When the order was placed, unix milliseconds, trade server clock. (required) | | `state` | string | The order's MetaTrader state when it left the book: filled, cancelled, expired, rejected or partial (partly filled); started, placed and request are states an order passes through on its way; unknown only for a value MetaTrader does not define. (required; one of started, placed, cancelled, partial, filled, rejected, expired, request, unknown) | | `time_done` | integer | When it left the book, unix seconds, trade server clock. (required) | | `time_done_msc` | integer | When it left the book, unix milliseconds, trade server clock. (required) | | `position_id` | integer | The position it opened or closed; 0 for an order that never filled. (required) | ```json { "ticket": 51830012, "symbol": "XAUUSD", "type": "buy", "side": "buy", "volume": 0.0, "volume_initial": 0.2, "price": 2385.0, "stop_limit": 0, "sl": 2380.0, "tp": 2420.0, "expiration": 0, "comment": "breakout", "magic": 0, "reason": "web", "time_setup": 1790975498, "time_setup_msc": 1790975497981, "state": "filled", "time_done": 1790975498, "time_done_msc": 1790975498123, "position_id": 51830012 } ``` ## Deal | Field | Type | Description | |---|---|---| | `ticket` | integer | Deal ticket. (required) | | `order` | integer | Order that made the deal. (required) | | `position_id` | integer | Position the deal belongs to (its identifier). (required) | | `symbol` | string | Symbol name. Empty for balance operations. (required) | | `type` | string | The MetaTrader deal type, lowercase. unknown only for a value MetaTrader does not define. (required; one of buy, sell, balance, credit, charge, correction, bonus, commission, commission_daily, commission_monthly, commission_agent_daily, commission_agent_monthly, interest, buy_canceled, sell_canceled, dividend, dividend_franked, tax, unknown) | | `entry` | string | in opens, out closes, inout reverses, out_by closes by an opposite position. unknown only for a value MetaTrader does not define. (required; one of in, out, inout, out_by, unknown) | | `volume` | number | Lots. (required) | | `price` | number | Deal price. (required) | | `profit` | number | Realised profit in the deposit currency. (required) | | `commission` | number | Commission. (required) | | `swap` | number | Swap. (required) | | `fee` | number | Fee. (required) | | `magic` | integer | Magic number. The web protocol cannot send one, so the broker stores 0; for an order sent through Termless with a magic number, Termless keeps it and puts it back here (the broker's own wins when it is not 0). A closing deal (a close at the stop loss or take profit included) gets the magic of the position it closed. (required) | | `comment` | string | Comment. The opening deal of an order sent through Termless with a comment past 31 characters gets the full text back; a closing deal keeps its own (IC Markets and Pepperstone write [sl 4129.45] or [tp ...] there on a close by stop, but read reason). (required) | | `reason` | string | Why it came about: client (a desktop terminal), mobile, web (anything sent through Termless), expert, sl and tp (closed at the stop loss or take profit), stop_out, and rarer ones. The wire carries the trade server's own numbers (web 17, SL 3, TP 4), not the official DEAL_REASON_* values, so read the word. (required; one of client, mobile, web, expert, sl, tp, stop_out, rollover, vmargin, split, corporate_action, dealer, gateway, signal, settlement, transfer, sync, external_client, external_service, migration, unknown) | | `time` | integer | Unix seconds, trade server clock. (required) | | `time_msc` | integer | Unix milliseconds, trade server clock. (required) | ```json { "ticket": 81200118, "order": 51830012, "position_id": 51830012, "symbol": "XAUUSD", "type": "buy", "entry": "in", "volume": 0.2, "price": 2385.0, "profit": 0.0, "commission": -0.7, "swap": 0.0, "fee": 0.0, "magic": 0, "comment": "breakout", "reason": "web", "time": 1790975498, "time_msc": 1790975498123 } ``` ## TradeResult | Field | Type | Description | |---|---|---| | `ok` | boolean | True when the broker placed (10008), did (10009) or partly did (10010) the request. Test this, not one code: brokers answer a placed pending order with 10008 or 10009. (required) | | `retcode` | integer | MetaTrader return code. 10009 = done, 10008 = placed. See x-retcodes for the rest. (required) | | `retcode_text` | string | The return code in words. (required) | | `deal` | integer | Deal ticket, 0 when no deal was made. (required) | | `order` | integer | Order ticket. (required) | | `volume` | number | Lots done. (required) | | `price` | number | Price done. (required) | | `bid` | number | Bid when the broker handled the request. (required) | | `ask` | number | Ask when the broker handled the request. (required) | | `comment` | string | Broker's comment. (required) | | `request_id` | integer | The broker's id for the request. (required) | | `warnings` | array of string | Present only when something in the request was changed or cannot be kept, on a 200 and a 422 alike: a comment over 31 characters ("comment is N characters; the broker keeps the first 31, termlessd keeps the full text for this order", without the second half for an order that neither opens nor closes anything); a magic number on a market or pending order ("magic is not sent to the broker (MetaTrader's web protocol has no field for it); termlessd keeps it for this order"); a type_filling the symbol does not allow, when order_send named one ("ORDER_FILLING_FOK is not allowed for EURUSD; sent ORDER_FILLING_IOC"); an expiry with seconds ("the broker keeps expiry times to the whole minute: "). | ```json { "ok": true, "retcode": 10009, "retcode_text": "Request completed", "deal": 81200131, "order": 51830031, "volume": 0.1, "price": 2391.6, "bid": 2391.42, "ask": 2391.6, "comment": "Request completed", "request_id": 31 } ``` ## TradeRejected The answer to a trade the broker refused (422): the trade result, with ok false, plus an error whose code is rejected. | Field | Type | Description | |---|---|---| | `ok` | boolean | True when the broker placed (10008), did (10009) or partly did (10010) the request. Test this, not one code: brokers answer a placed pending order with 10008 or 10009. (required) | | `retcode` | integer | MetaTrader return code. 10009 = done, 10008 = placed. See x-retcodes for the rest. (required) | | `retcode_text` | string | The return code in words. (required) | | `deal` | integer | Deal ticket, 0 when no deal was made. (required) | | `order` | integer | Order ticket. (required) | | `volume` | number | Lots done. (required) | | `price` | number | Price done. (required) | | `bid` | number | Bid when the broker handled the request. (required) | | `ask` | number | Ask when the broker handled the request. (required) | | `comment` | string | Broker's comment. (required) | | `request_id` | integer | The broker's id for the request. (required) | | `warnings` | array of string | Present only when something in the request was changed or cannot be kept, on a 200 and a 422 alike: a comment over 31 characters ("comment is N characters; the broker keeps the first 31, termlessd keeps the full text for this order", without the second half for an order that neither opens nor closes anything); a magic number on a market or pending order ("magic is not sent to the broker (MetaTrader's web protocol has no field for it); termlessd keeps it for this order"); a type_filling the symbol does not allow, when order_send named one ("ORDER_FILLING_FOK is not allowed for EURUSD; sent ORDER_FILLING_IOC"); an expiry with seconds ("the broker keeps expiry times to the whole minute: "). | | `error` | object | (required; object: code, message) | ```json { "ok": false, "retcode": 10014, "retcode_text": "Invalid volume", "deal": 0, "order": 0, "volume": 0, "price": 0, "bid": 2391.42, "ask": 2391.6, "comment": "Invalid volume", "request_id": 32, "error": { "code": "rejected", "message": "the broker refused the request: Invalid volume (10014)" } } ``` ## MarketOrder Opens a position at market. | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name. (required) | | `side` | string | Direction. (required; one of buy, sell) | | `volume` | number | Lots, for example 0.10. (required) | | `price` | number | Price sent with the request. Leave it out to fill at market. | | `sl` | number | Stop loss price. | | `tp` | number | Take profit price. | | `deviation` | integer | Largest slippage you accept, in points. (default 20) | | `comment` | string | Comment, up to 255 characters (more is 400). The broker keeps the first 31; for a market or pending order Termless keeps the full text and puts it back on the order, its position, its opening deal and the stream events. Longer than 31 adds a warning to the answer. | | `magic` | integer | Magic number. The web protocol's trade request has no field for it, so the broker stores 0; for a market or pending order Termless keeps it and puts it back on the order, its position, its deals and the stream events (MetaTrader's own apps still show 0). Sending one adds a warning to the answer. | ```json { "symbol": "XAUUSD", "side": "buy", "volume": 0.1, "sl": 2380.0, "tp": 2420.0, "comment": "breakout" } ``` ## PendingOrder Places a pending order. | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name. (required) | | `side` | string | Direction. (required; one of buy, sell) | | `volume` | number | Lots. (required) | | `type` | string | limit, stop or stop_limit. Its presence makes the order pending. (required; one of limit, stop, stop_limit) | | `price` | number | Trigger price. (required) | | `stop_limit` | number | Limit price, required for stop_limit only. | | `sl` | number | Stop loss price. | | `tp` | number | Take profit price. | | `expiration` | integer | Expiry, unix seconds, trade server clock. Omit (or 0) for good till cancelled. The broker keeps whole minutes; one with seconds gets a warning naming the minute. | | `comment` | string | Comment, up to 255 characters (more is 400). The broker keeps the first 31; for a market or pending order Termless keeps the full text and puts it back on the order, its position, its opening deal and the stream events. Longer than 31 adds a warning to the answer. | | `magic` | integer | Magic number. The web protocol's trade request has no field for it, so the broker stores 0; for a market or pending order Termless keeps it and puts it back on the order, its position, its deals and the stream events (MetaTrader's own apps still show 0). Sending one adds a warning to the answer. | ```json { "symbol": "XAUUSD", "side": "buy", "volume": 0.1, "type": "limit", "price": 2365.0, "sl": 2350.0, "tp": 2410.0 } ``` ## OrderModify Send only what changes; omitted fields keep their value. | Field | Type | Description | |---|---|---| | `price` | number | New trigger price. | | `stop_limit` | number | New limit price (stop limit orders). | | `sl` | number | New stop loss, 0 removes it. | | `tp` | number | New take profit, 0 removes it. | | `expiration` | integer | New expiry, unix seconds, trade server clock. 0 = good till cancelled. | ```json { "price": 2360.0, "sl": 2345.0 } ``` ## PositionModify Send sl, tp or both; an omitted one keeps its value, 0 removes it. | Field | Type | Description | |---|---|---| | `sl` | number | New stop loss, 0 removes it. | | `tp` | number | New take profit, 0 removes it. | ```json { "sl": 2386.0, "tp": 2425.0 } ``` ## OrderSendRequest The request dict of the official MetaTrader5 Python package's order_send(), with the same field names. Enum fields take the integer constants or their names; numbers may also be sent as strings. | Field | Type | Description | |---|---|---| | `action` | integer or string | TRADE_ACTION_*: 1 deal (market), 5 pending, 6 sltp, 7 modify, 8 remove, 10 close_by. A number or the official name, for example TRADE_ACTION_DEAL. (required) | | `symbol` | string | Symbol name. | | `volume` | number | Lots. | | `type` | integer or string | ORDER_TYPE_*: 0 buy, 1 sell, 2 buy_limit, 3 sell_limit, 4 buy_stop, 5 sell_stop, 6 buy_stop_limit, 7 sell_stop_limit, 8 close_by. A number or the official name, for example ORDER_TYPE_SELL. | | `price` | number | Price. | | `stoplimit` | number | Limit price of a stop limit order. stop_limit also works. | | `sl` | number | Stop loss. | | `tp` | number | Take profit. | | `deviation` | integer | Largest slippage, in points. | | `type_filling` | integer or string | ORDER_FILLING_*: 0 FOK, 1 IOC, 2 return, 3 BOC. A number or the official name, for example ORDER_FILLING_IOC. A mode the symbol does not allow is replaced by one it does (IOC, then FOK, then return), as the web terminal does, and the answer's warnings name the mode sent. A pending order goes out as return unless the symbol is exchange-executed. | | `type_time` | integer or string | ORDER_TIME_*: 0 GTC, 1 day, 2 specified, 3 specified day. A number or the official name, for example ORDER_TIME_GTC. | | `expiration` | integer | Expiry, unix seconds, trade server clock. The broker keeps whole minutes; one with seconds gets a warning. | | `comment` | string | Comment, up to 255 characters (more is 400). The broker keeps the first 31; for a market or pending order Termless keeps the full text and puts it back on the order, its position, its opening deal and the stream events. Longer than 31 adds a warning to the answer. | | `magic` | integer | Magic number. The web protocol's trade request has no field for it, so the broker stores 0; for a market or pending order Termless keeps it and puts it back on the order, its position, its deals and the stream events (MetaTrader's own apps still show 0). Sending one adds a warning to the answer. | | `position` | integer | Position ticket, to close or modify a position. | | `position_by` | integer | Opposite position ticket, for close_by. | | `order` | integer | Order ticket, to modify or remove a pending order. | ```json { "action": "TRADE_ACTION_DEAL", "symbol": "XAUUSD", "volume": 0.1, "type": "ORDER_TYPE_BUY", "price": 2391.6, "sl": 2380.0, "tp": 2420.0, "deviation": 20, "type_filling": "ORDER_FILLING_IOC", "type_time": 0, "comment": "from mt5 script", "magic": 7 } ``` ## AuditRow One row of the audit trail: every write and every security event, with the request id that caused it. Trades get one row per broker call and none for an idempotent replay. | Field | Type | Description | |---|---|---| | `id` | integer | Row id, increasing. Page with `before`. (required) | | `at` | integer | When it happened, unix milliseconds (UTC). (required) | | `kind` | string | What kind of thing happened. (required; one of trade, account, key, signin, auth_failed, lockout, password, setup, server_check, server_trust, start) | | `actor` | string | Who did it: the key id for a key, admin for the dashboard, the client IP before sign-in, termlessd for the server itself. (required) | | `actor_kind` | string | admin for the dashboard session, key for an API key, anonymous before sign-in, system for the server. (required; one of admin, key, anonymous, system) | | `account` | string or null | The account it concerned, when one did. (required) | | `route` | string | What was done. For a trade: market order, pending order, order change, order cancel, SL/TP change, close, partial close or order_send. For an account: add, update or delete. For a key: create or delete. (required) | | `summary` | string | One line a person can read. (required) | | `request` | string or null | For a trade: the request sent to the broker, in short JSON (cut to 400 characters). (required) | | `status` | integer or null | The HTTP status the caller got. (required) | | `retcode` | integer or null | For a trade the broker answered: its return code. (required) | | `result` | string or null | For a trade: the broker's answer in words with the order and deal tickets, or the error when it did not answer. (required) | | `latency_ms` | integer or null | For a trade: the broker round trip in milliseconds. (required) | | `request_id` | string or null | The X-Request-Id of the request that caused the row; the same id is on its log lines. (required) | | `ip` | string or null | The client IP, recorded for sign-ins, wrong passwords and lockouts. (required) | ```json { "id": 4821, "at": 1790981179473, "kind": "trade", "actor": "key_3f9a1c07", "actor_kind": "key", "account": "pepperstone-12345678", "route": "market order", "summary": "market buy 0.10 XAUUSD", "request": "{\"symbol\":\"XAUUSD\",\"volume\":0.1,\"type\":0,\"price\":0.0,\"sl\":2380.0,\"tp\":2420.0,\"order\":0,\"position\":0,\"comment\":\"breakout\"}", "status": 200, "retcode": 10009, "result": "Request completed order 51830031 deal 81200131", "latency_ms": 212, "request_id": "bot-20261003-0042", "ip": null } ``` ## ConnectionEvent One entry of an account's connection history. | Field | Type | Description | |---|---|---| | `id` | integer | Row id, increasing. Page with `before`. (required) | | `at` | integer | When it happened, unix milliseconds (UTC). (required) | | `account` | string | Account id. (required) | | `kind` | string | started when the session began; connected (reason: the broker's build) the first time it logged in and reconnected after that; lost (reason: the session's last error) when the link dropped; connect_failed or login_rejected when an attempt failed; stopped when the account was turned off or removed. (required; one of started, connected, reconnected, lost, connect_failed, login_rejected, stopped) | | `reason` | string or null | The build for connected and reconnected, the error for lost, connect_failed and login_rejected. (required) | | `duration_ms` | integer or null | For connected and reconnected: how long the account had been disconnected. For lost and stopped: how long it had been connected. (required) | | `quiet_since` | integer or null | On a lost event cut for missed pings (0.6.0): when the first unanswered ping was sent, unix milliseconds (UTC), so when the broker went quiet; null otherwise. (required) | ```json { "id": 310, "at": 1790968298412, "account": "pepperstone-12345678", "kind": "connected", "reason": "build 6090", "duration_ms": 1840, "quiet_since": null } ``` ## EquityCurve Balance, equity, margin and profit sampled about once a minute, kept 7 days, and the gaps when the account was not connected. Served from the database, so it works while the account is disconnected or turned off. | Field | Type | Description | |---|---|---| | `account` | string | Account id. (required) | | `hours` | integer | The window asked for, ending now. (required) | | `every_s` | integer | Seconds between samples while connected (60). (required) | | `samples` | array of EquitySample | Oldest first. About one a minute while the account is connected, the first right after it connects; none while it is not (see gaps). (required; see EquitySample) | | `gaps` | array of EquityGap | Oldest first: the periods inside the window when the account was not connected, read from its connection events. Draw a break there instead of a line across the outage. (required; see EquityGap) | ```json { "account": "pepperstone-12345678", "hours": 24, "every_s": 60, "samples": [ { "at": 1790977560000, "balance": 10412.58, "equity": 10641.2, "margin": 878.93, "profit": 228.62 }, { "at": 1790977620000, "balance": 10412.58, "equity": 10650.69, "margin": 878.93, "profit": 238.11 } ], "gaps": [ { "from": 1790968296572, "to": 1790968298412 } ] } ``` ## EquitySample | Field | Type | Description | |---|---|---| | `at` | integer | Unix milliseconds (UTC). (required) | | `balance` | number | Balance. (required) | | `equity` | number | Equity, with live profit. (required) | | `margin` | number | Margin in use. (required) | | `profit` | number | Floating profit of open positions. (required) | ```json { "at": 1790977560000, "balance": 10412.58, "equity": 10641.2, "margin": 878.93, "profit": 228.62 } ``` ## ApiKey | Field | Type | Description | |---|---|---| | `id` | string | Key id, used to revoke it. (required) | | `name` | string | What the key is for. (required) | | `prefix` | string | The key's first 12 characters (tl_ and 9 more), to recognise it. (required) | | `scopes` | array of string | One scope. (required; one of read, trade, admin) | | `accounts` | array or null | Account ids the key may use. null = every account. (required) | | `created_at` | integer | Unix seconds (UTC). (required) | | `last_used_at` | integer or null | Unix seconds (UTC) of the last request, null if never used. (required) | | `max_volume` | number or null | The most lots one order that opens something may have (0.6.0); null: no limit. (required) | | `max_open_per_min` | integer or null | The most orders that open something this key may send in 60 s (0.6.0); null: no limit. (required) | | `max_daily_loss` | number or null | The most the account may lose in a forex day (from 17:00 New York, account currency) before this key opens nothing (0.7.0); null: no limit. (required) | | `max_drawdown_pct` | number or null | The most percent the account's equity may fall below its high since the limit was set before this key opens nothing (0.7.0); null: no limit. (required) | | `limits_since` | integer or null | When the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0). (required) | ```json { "id": "key_3f9a1c07", "name": "EA bridge (gold)", "prefix": "tl_4be1a09c7", "scopes": [ "trade" ], "accounts": [ "pepperstone-12345678" ], "created_at": 1790709498, "last_used_at": 1790974298, "max_volume": 0.5, "max_open_per_min": 10, "max_daily_loss": 500.0, "max_drawdown_pct": null, "limits_since": null } ``` ## ApiKeyCreate | Field | Type | Description | |---|---|---| | `name` | string | What the key is for, for example "EA bridge (gold)". Up to 80 characters. (required) | | `scopes` | one of | Exactly one scope. trade includes read; admin includes everything. Defaults to ["read"]. | | `accounts` | array of string | Limit the key to these account ids. Omit for every account. Not allowed with admin (400); an unknown id is 400 too. | | `max_volume` | number | The most lots one order that opens something may have; above it the order answers 403 key_limit and is not sent. Closing is never limited. Omit for no limit (0.6.0). | | `max_open_per_min` | integer | The most orders that open something this key may send in 60 s, 1 to 600; past it 429 key_limit with Retry-After, not sent. Omit for no limit (0.6.0). | | `max_daily_loss` | one of | A positive amount in the account's currency; past it (from the forex day's start) orders that open something answer 403 key_limit, not sent (0.7.0). null or left out: no limit. | | `max_drawdown_pct` | one of | More than 0, at most 100: past that many percent below the equity's high since it was set, orders that open something answer 403 key_limit, not sent (0.7.0). Setting or changing it starts its high afresh. | ```json { "name": "EA bridge (gold)", "scopes": [ "trade" ], "accounts": [ "pepperstone-12345678" ], "max_volume": 0.5, "max_open_per_min": 10 } ``` ## ApiKeyCreated | Field | Type | Description | |---|---|---| | `id` | string | Key id, used to revoke it. (required) | | `name` | string | What the key is for. (required) | | `prefix` | string | The key's first 12 characters (tl_ and 9 more), to recognise it. (required) | | `scopes` | array of string | One scope. (required; one of read, trade, admin) | | `accounts` | array or null | Account ids the key may use. null = every account. (required) | | `created_at` | integer | Unix seconds (UTC). (required) | | `last_used_at` | integer or null | Unix seconds (UTC) of the last request, null if never used. (required) | | `max_volume` | number or null | The most lots one order that opens something may have (0.6.0); null: no limit. (required) | | `max_open_per_min` | integer or null | The most orders that open something this key may send in 60 s (0.6.0); null: no limit. (required) | | `max_daily_loss` | number or null | The most the account may lose in a forex day (from 17:00 New York, account currency) before this key opens nothing (0.7.0); null: no limit. (required) | | `max_drawdown_pct` | number or null | The most percent the account's equity may fall below its high since the limit was set before this key opens nothing (0.7.0); null: no limit. (required) | | `limits_since` | integer or null | When the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0). (required) | | `key` | string | The full key, tl_ and 48 hex characters. It is shown only in this response, so store it now. (required) | ```json { "id": "key_3f9a1c07", "name": "EA bridge (gold)", "prefix": "tl_4be1a09c7", "scopes": [ "trade" ], "accounts": [ "pepperstone-12345678" ], "created_at": 1790981179, "last_used_at": null, "max_volume": 0.5, "max_open_per_min": 10, "max_daily_loss": 500.0, "max_drawdown_pct": null, "limits_since": null, "key": "tl_4be1a09c7d2e5f8b1a3c6e9d0f2b4a7c8e1d3f5a7b9c0e2d" } ``` ## Me | Field | Type | Description | |---|---|---| | `kind` | string | admin for the dashboard session, key for an API key. (required; one of admin, key) | | `name` | string | admin, or the key's name. (required) | | `scopes` | array of string | What this caller may do. (required; one of read, trade, admin) | | `accounts` | array or null | Account ids this caller may use. null means every account. (required) | ```json { "kind": "key", "name": "EA bridge (gold)", "scopes": [ "trade" ], "accounts": [ "pepperstone-12345678" ] } ``` ## Health | Field | Type | Description | |---|---|---| | `status` | string | ok when every enabled account is connected, degraded when an enabled account is not, setup before the admin password exists. (required; one of ok, degraded, setup) | | `version` | string or null | Server version, for a signed-in caller or a valid key; null for anyone else (the exact version tells an attacker which fixes are missing). (required) | | `uptime_s` | integer | Seconds since the server started. (required) | | `accounts` | array of object | Empty unless the caller is signed in or sends a valid key; then the accounts it may see. (required; object: id, label, enabled, connected, ping_ms, reconnects) | ```json { "status": "ok", "version": "0.6.2", "uptime_s": 86412, "accounts": [ { "id": "pepperstone-12345678", "label": "Pepperstone demo", "enabled": true, "connected": true, "ping_ms": 14.2, "reconnects": 0 } ] } ``` ## Error Every error response has this shape. | Field | Type | Description | |---|---|---| | `error` | object | (required; object: code, message) | ```json { "error": { "code": "not_found", "message": "no account with id pepperstone-live" } } ``` ## Ok | Field | Type | Description | |---|---|---| | `ok` | boolean | Always true. (required) | ```json { "ok": true } ``` ## SetupState | Field | Type | Description | |---|---|---| | `needs_setup` | boolean | True until the admin password has been set. (required) | ```json { "needs_setup": true } ``` ## SetupRequest | Field | Type | Description | |---|---|---| | `token` | string | The one-time setup token from the server log or /setup-token. (required) | | `password` | string | The new admin password: 15 to 200 characters with a lowercase letter, a capital, a digit and a symbol (anything but a letter or a digit counts as a symbol). (required) | ```json { "token": "4f1c9e0b7a2d5e8c3b6a9d0e", "password": "A long passphrase, 2 commas" } ``` ## SessionRequest | Field | Type | Description | |---|---|---| | `password` | string | The admin password. (required) | ```json { "password": "a long passphrase" } ``` ## PasswordChange | Field | Type | Description | |---|---|---| | `current` | string | The admin password in use now. A wrong one is 400, not 401, so the dashboard stays signed in. (required) | | `new` | string | The new admin password: 15 to 200 characters with a lowercase letter, a capital, a digit and a symbol (anything but a letter or a digit counts as a symbol). (required) | ```json { "current": "A long passphrase, 2 commas", "new": "An even longer passphrase, 3 commas" } ``` ## Server | Field | Type | Description | |---|---|---| | `server` | string | Trade server name exactly as the broker spells it, for example Pepperstone-Demo. (required) | | `company` | string | Broker company name. (required) | | `host` | string | Host that serves the broker's MT5 web terminal. (required) | | `port` | integer | Port, usually 443. (required) | | `type` | string | Demo or real money server. (required; one of demo, real) | | `build` | integer or null | MT5 web terminal build seen on the host. null until this install has checked it. (required) | | `verified_at` | integer or null | Unix seconds (UTC) when this install last checked the host. null for a built-in entry it has not checked. (required) | | `tls_name` | string or null | For an IP access point: the name sent (SNI) and checked against the certificate while TCP goes to the IP. null for a named host. (required) | | `pin_sha256` | string or null | SHA-256 of the certificate key an admin pinned for this host (64 hex), or null. (required) | | `prop_firm` | boolean | A prop firm's server (from the built-in directory). (required) | ```json { "server": "Pepperstone-Demo", "company": "Pepperstone Group Limited", "host": "mt5-demo01.pepperstone.com", "port": 443, "type": "demo", "build": 6090, "verified_at": 1790966779, "tls_name": null, "pin_sha256": null, "prop_firm": false } ``` ## ServerCheckRequest | Field | Type | Description | |---|---|---| | `host` | string | Host name to check. A pasted link works: the scheme, path, query, fragment and any user@ are dropped, and host:port works when port is left out. (required) | | `port` | integer | Port. Defaults to 443. (default 443) | | `tls_name` | string | For an IP access point: the name on its certificate (sent as SNI and checked). Defaults to the directory's for that host. | | `fingerprint` | string | Pin this certificate key for the host: the spki_sha256 a refused check reported (64 hex; sha256: and colons allowed). Only for a host you know is the broker's; audited as server_trust. | ```json { "host": "mt5-demo01.pepperstone.com" } ``` ## ServerCheck | Field | Type | Description | |---|---|---| | `ok` | boolean | True when the host serves an MT5 web terminal. (required) | | `host` | string | The host that was checked. (required) | | `port` | integer | The port that was checked. (required) | | `company` | string | Broker company name from the terminal page. (required) | | `build` | integer | Web terminal build. (required) | | `servers` | array of object | Trade servers this host answers for. They are saved to the directory. (required; object: server, type) | | `tls_name` | string or null | The TLS name used, for an IP access point. (required) | | `pin_sha256` | string or null | The pinned key the host was checked with, if any. (required) | ```json { "ok": true, "host": "mt5-demo01.pepperstone.com", "port": 443, "company": "Pepperstone Group Limited", "build": 6090, "servers": [ { "server": "Pepperstone-Demo", "type": "demo" } ], "tls_name": null, "pin_sha256": null } ``` ## Diagnostics What the server itself is doing. | Field | Type | Description | |---|---|---| | `version` | string | Server version. (required) | | `target` | string | The platform the binary was built for, for example x86_64-unknown-linux-gnu. (required) | | `pid` | integer | Process id. (required) | | `started_at` | integer | When the server started, unix seconds (UTC). (required) | | `uptime_s` | integer | Seconds since the server started. (required) | | `process` | object | Read from /proc; every field is null off Linux. (required; object: rss_kb, rss_peak_kb, threads, open_files) | | `data_dir` | string | The data folder. (required) | | `log_file` | string or null | The current log file, null before the first one is written. (required) | | `db_bytes` | integer | Size of the database (with its write-ahead log) in bytes. (required) | | `dashboard_sessions` | integer | Dashboard sign-ins that have not expired. (required) | | `streams` | object | Open price streams and their caps. (required; object: sse, ws, max, max_per_key) | | `accounts` | array of DiagnosticsAccount | Every account, with its connection status. (required; see DiagnosticsAccount) | | `undecoded` | object | Frames the client could not decode. (required; object: total, file, by_command, recent) | | `problems` | array of LogLine | The last 100 warnings and errors from the log, newest first. (required; see LogLine) | | `crashes` | array of CrashReport | Crash reports in /crashes, newest first. (required; see CrashReport) | | `unclean_exit_report` | string or null | null, or the file name (such as unclean-exit-2026-10-03T00-12-07Z.txt) of the report written at this start because the previous run did not shut down cleanly (its pid file was still there). Read it with GET /api/v1/diagnostics/crashes/{name}. It stays set for the whole run. (required) | ```json { "version": "0.1.0", "target": "x86_64-unknown-linux-gnu", "pid": 41822, "started_at": 1790894779, "uptime_s": 75600, "process": { "rss_kb": 23140, "rss_peak_kb": 31200, "threads": 9, "open_files": 21 }, "data_dir": "/var/lib/termless", "log_file": "/var/lib/termless/logs/termlessd.2026-10-03.log", "db_bytes": 135168, "dashboard_sessions": 1, "streams": { "sse": 1, "ws": 0, "max": 1024, "max_per_key": 256 }, "accounts": [ { "connected": true, "since": 1790968298, "reconnects": 0, "ping_ms": 14.2, "server_build": 6090, "last_error": null, "subscribed": 2, "login_rejected": false, "retry_at": null, "id": "pepperstone-12345678", "enabled": true, "session_running": true, "ticks_seen": 1840211, "last_tick_at_ms": 1790970379473, "last_frame_at_ms": 1790970381002, "streams": 1, "ticks_coalesced": 0, "undecoded": 3 } ], "undecoded": { "total": 3, "file": "/var/lib/termless/captures/undecoded.jsonl", "by_command": [ { "account": "pepperstone-12345678", "command": 8, "kind": "body", "context": "tick push", "count": 3, "first_at": 1790964410, "last_at": 1790965012, "last_error": "short read at offset 40" } ], "recent": [ { "id": 3, "time": 1790965012, "account": "pepperstone-12345678", "kind": "body", "command": 8, "code": 0, "context": "tick push", "error": "short read at offset 40", "server_build": 6090, "len": 52 } ] }, "problems": [ { "time": 1790968290, "level": "warn", "target": "termless::session", "message": "[pepperstone-12345678] connection lost, reconnecting" } ], "crashes": [ { "name": "20261002T231405Z-panic.txt", "time": 1790896445, "size": 6120, "summary": "index out of bounds: the len is 3 but the index is 3" } ], "unclean_exit_report": null } ``` ## DiagnosticsAccount An account's status plus the counters diagnostics adds. | Field | Type | Description | |---|---|---| | `id` | string | Account id. (required) | | `enabled` | boolean | False for an account that is turned off. (required) | | `connected` | boolean | Whether the session to the broker is up right now. (required) | | `since` | integer or null | Unix seconds (UTC) when the current connection came up. null while disconnected. (required) | | `reconnects` | integer | Automatic reconnects since the server started. (required) | | `ping_ms` | number or null | Last heartbeat round trip in milliseconds. null before the first one. (required) | | `server_build` | integer or null | MT5 build the broker's server reported. null before the first login. (required) | | `last_error` | string or null | Why the last connection attempt failed or the connection dropped. null while connected. (required) | | `subscribed` | integer | Number of symbols with a live price subscription. (required) | | `login_rejected` | boolean | True after the broker refused the login. A refusal within an hour of losing a working connection (a broker restarting refuses logins with code 2 for seconds to minutes) is tried again after 10, 20, 30 and 60 s, then every minute for code 2 until an hour after the loss (0.6.3), then every 5 minutes; any other refusal only every 5 minutes, so a wrong password cannot get the account locked. (required) | | `retry_at` | integer or null | Unix seconds (UTC) of the next connection attempt while disconnected, else null. (required) | | `session_running` | boolean | Whether the account's connection loop is running. (required) | | `ticks_seen` | integer | Price ticks received since the session started. (required) | | `last_tick_at_ms` | integer or null | When the last tick arrived, unix milliseconds (UTC). null before the first. (required) | | `last_frame_at_ms` | integer or null | When the last frame of any kind (pings included) arrived from the broker, unix milliseconds (UTC). A connected account with an old value is about to be declared dead. (required) | | `streams` | integer | Open streams (SSE and WebSocket) on this account. (required) | | `ticks_coalesced` | integer | Ticks dropped for slow stream readers (they got the latest tick per symbol instead). (required) | | `undecoded` | integer | Frames from this account the client could not decode. (required) | ## UndecodedFrame A frame the client could not decode, kept with its bytes. | Field | Type | Description | |---|---|---| | `id` | integer | Frame number since the server started. (required) | | `time` | integer | When it arrived, unix seconds (UTC). (required) | | `account` | string | Account id. (required) | | `login` | integer | MT5 login of the account. (required) | | `kind` | string | frame: the outer frame or its encryption did not check out. body: a known command whose body did not parse. unknown_push: a push with a command id the client does not handle. extra (0.6.0): a reply read in full with bytes after the records the layout knows; kept for diagnosis, never counted as undecoded. (required; one of frame, body, unknown_push, extra) | | `command` | integer | Protocol command id. (required) | | `code` | integer | The frame's result code. (required) | | `context` | string | Where it happened, for example tick push or account reply. (required) | | `error` | string | What the decoder said. (required) | | `server_build` | integer | The broker's MT5 build at the time. (required) | | `len` | integer | Body length in bytes. (required) | | `body_hex` | string | The body as hex. Without `bodies=1` it is cut to the first 128 bytes and `body_preview` is true; with it, up to 64 KB a frame. (required) | | `truncated` | boolean | True when the kept body itself holds only the first 64 KB. (required) | | `body_preview` | boolean | Present and true when body_hex was cut to its first 128 bytes; ask with `bodies=1` for the whole body. | ```json { "id": 3, "time": 1790965012, "account": "pepperstone-12345678", "login": 12345678, "kind": "body", "command": 8, "code": 0, "context": "tick push", "error": "short read at offset 40", "server_build": 6090, "len": 52, "body_hex": "0a000000b80b0000a4703d0ad7af924000000000000000000000000000000000c8b1e2a4b5010000", "truncated": false } ``` ## UndecodedCount | Field | Type | Description | |---|---|---| | `account` | string | Account id. (required) | | `command` | integer | Protocol command id. (required) | | `kind` | string | frame: the outer frame or its encryption did not check out. body: a known command whose body did not parse. unknown_push: a push with a command id the client does not handle. extra (0.6.0): a reply read in full with bytes after the records the layout knows; kept for diagnosis, never counted as undecoded. (required; one of frame, body, unknown_push, extra) | | `context` | string | Where it happened. (required) | | `count` | integer | How many such frames arrived (kept or only counted). (required) | | `first_at` | integer | First one, unix seconds (UTC). (required) | | `last_at` | integer | Latest one, unix seconds (UTC). (required) | | `last_error` | string | What the decoder said about the latest one. (required) | ```json { "account": "pepperstone-12345678", "command": 8, "kind": "body", "context": "tick push", "count": 3, "first_at": 1790964410, "last_at": 1790965012, "last_error": "short read at offset 40" } ``` ## LogLine | Field | Type | Description | |---|---|---| | `time` | integer | Unix seconds (UTC). (required) | | `level` | string | Log level. (required; one of warn, error) | | `target` | string | The module that logged it. (required) | | `message` | string | The log message. (required) | ```json { "time": 1790968290, "level": "warn", "target": "termless::session", "message": "[pepperstone-12345678] connection lost, reconnecting" } ``` ## CrashReport | Field | Type | Description | |---|---|---| | `name` | string | File name in /crashes; fetch the text with GET /api/v1/diagnostics/crashes/{name}. (required) | | `time` | integer | When it was written, unix seconds (UTC). (required) | | `size` | integer | Size in bytes. (required) | | `summary` | string | The panic message, or the first line of an unclean-exit report. (required) | ```json { "name": "20261002T231405Z-panic.txt", "time": 1790896445, "size": 6120, "summary": "index out of bounds: the len is 3 but the index is 3" } ``` ## DoctorReport The same checks as `termlessd doctor`: data folder, master.key, database integrity and row counts, listen address, each account's gateway (DNS, TLS, the web terminal's build), the clock against the broker (the newest live tick), free disk. | Field | Type | Description | |---|---|---| | `verdict` | string | ok when every check passed, warnings when something should be looked at, problems when something is broken. (required; one of ok, warnings, problems) | | `version` | string | Server version. (required) | | `data_dir` | string | The data folder that was checked. (required) | | `checks` | array of DoctorCheck | One row per check, in the order they ran. (required; see DoctorCheck) | ```json { "verdict": "warnings", "version": "0.1.0", "data_dir": "/var/lib/termless", "checks": [ { "name": "data folder", "level": "ok", "detail": "/var/lib/termless exists and is writable" }, { "name": "master.key", "level": "ok", "detail": "/var/lib/termless/master.key present (owner-only)" }, { "name": "database", "level": "ok", "detail": "/var/lib/termless/termless.db (132 KB) integrity ok; rows: accounts 1, keys 2, audit 4821, account_events 310, equity_samples 1440" }, { "name": "listen", "level": "ok", "detail": "serving on http://127.0.0.1:8780" }, { "name": "gateway", "level": "ok", "detail": "pepperstone-12345678: mt5-demo01.pepperstone.com:443 is Pepperstone Group Limited build 6090 (2 servers); connected, build 6090" }, { "name": "clock", "level": "warn", "detail": "7 s off the broker's clock", "fix": "enable NTP (timedatectl set-ntp true); candle times and expirations depend on it" }, { "name": "disk", "level": "ok", "detail": "18240 MB free; termless uses 3 MB" } ] } ``` ## DoctorCheck | Field | Type | Description | |---|---|---| | `name` | string | What was checked: data folder, master.key, setup-token, database, listen, gateway (one per account; gateways when there are none), clock, disk. (required) | | `level` | string | ok, warn or fail. (required; one of ok, warn, fail) | | `detail` | string | What was found, in a sentence. (required) | | `fix` | string | What to do. Only on a warn or fail. | ```json { "name": "clock", "level": "warn", "detail": "7 s off the broker's clock", "fix": "enable NTP (timedatectl set-ntp true); candle times and expirations depend on it" } ``` ## EquityGap A period the account was not connected. | Field | Type | Description | |---|---|---| | `from` | integer | When the account stopped being connected (a lost or stopped event, the window's start if it was already down, or for a run that ended without a stop the last sample before the restart), unix milliseconds (UTC). (required) | | `to` | integer or null | When it connected again, unix milliseconds (UTC). null while it still is not. (required) | ```json { "from": 1790968296572, "to": 1790968298412 } ``` ## Certificate A gateway certificate that was refused, for a person to judge. Termless never accepts one on its own; an admin may pin its key. | Field | Type | Description | |---|---|---| | `host` | string | The name that was checked (the TLS name, else the host). (required) | | `reason` | string | Why it was refused. (required; one of unknown_issuer, name_mismatch, expired, not_yet_valid, pin_mismatch, invalid) | | `detail` | string | The TLS library's words. (required) | | `names` | array of string | The names the certificate is for (subjectAltName, else its common name). (required) | | `subject` | string | Its subject, most specific first. (required) | | `issuer` | string | Who issued it. (required) | | `not_before` | integer | Valid from, unix seconds (UTC). (required) | | `not_after` | integer | Valid until, unix seconds (UTC). (required) | | `spki_sha256` | string | SHA-256 of its DER SubjectPublicKeyInfo, 64 lower-case hex: the value to pin. (required) | | `pinned` | string or null | For pin_mismatch: the key that was expected. (required) | ```json { "host": "mt5-demo.broker-example.com", "reason": "name_mismatch", "detail": "NotValidForNameContext", "names": [ "*.mobile-demo.example.net", "mobile-demo.example.net" ], "subject": "CN=*.mobile-demo.example.net", "issuer": "CN=Example DV CA, O=Example Trust, C=LU", "not_before": 1759190400, "not_after": 1790726399, "spki_sha256": "94f8fc63b835599dd9a14fbd30445e94040d65b2801597b764aae9bfb779d4e7", "pinned": null } ``` ## CertificateError 502 untrusted_certificate or certificate_changed: the error and the certificate. | Field | Type | Description | |---|---|---| | `error` | object | (required; object: code, message) | | `certificate` | object | A gateway certificate that was refused, for a person to judge. Termless never accepts one on its own; an admin may pin its key. (required; see Certificate) | ```json { "error": { "code": "untrusted_certificate", "message": "the certificate of mt5-demo.broker-example.com is not trusted: it is for another name; ..." }, "certificate": { "host": "mt5-demo.broker-example.com", "reason": "name_mismatch", "detail": "NotValidForNameContext", "names": [ "*.mobile-demo.example.net", "mobile-demo.example.net" ], "subject": "CN=*.mobile-demo.example.net", "issuer": "CN=Example DV CA, O=Example Trust, C=LU", "not_before": 1759190400, "not_after": 1790726399, "spki_sha256": "94f8fc63b835599dd9a14fbd30445e94040d65b2801597b764aae9bfb779d4e7", "pinned": null } } ``` ## TrustRequest | Field | Type | Description | |---|---|---| | `fingerprint` | string | The key to pin: spki_sha256 from a refused check (64 hex; sha256: and colons allowed). (required) | ```json { "fingerprint": "94f8fc63b835599dd9a14fbd30445e94040d65b2801597b764aae9bfb779d4e7" } ``` ## TrustResult | Field | Type | Description | |---|---|---| | `ok` | boolean | True: pinned. (required) | | `server` | string | The server named in the path. (required) | | `host` | string | Its host. (required) | | `port` | integer | Its port. (required) | | `tls_name` | string or null | Its TLS name, if any. (required) | | `pin_sha256` | string | The pinned key. (required) | | `accounts_restarted` | integer | Accounts on that gateway that logged in again with the pin. (required) | | `servers` | array of object | Servers the host's page lists (saved with the pin). (required; object: server, type) | ## HistoryTick One kept tick (GET /ticks), in the shape of copy_ticks_from's rows. | Field | Type | Description | |---|---|---| | `time` | integer | Unix seconds, trade server clock. (required) | | `time_msc` | integer | Unix milliseconds, trade server clock. (required) | | `bid` | number | Bid after the tick (the previous one when the tick did not change it). (required) | | `ask` | number | Ask after the tick (the previous one when the tick did not change it). (required) | | `last` | number | Last deal price after the tick. 0 for most forex and CFD symbols. (required) | | `volume` | integer | The tick's volume; 0 unless the tick changed it (flag 16). (required) | | `flags` | integer | MetaTrader's TICK_FLAG_* for what the tick changed, added together: 2 bid, 4 ask, 8 last, 16 volume. (required) | | `volume_raw` | integer | The broker's volume number (lots times 10^8), as volume (0.7.0). (required) | | `volume_real` | number | The volume in lots (0.7.0). (required) | ```json { "time": 1790981179, "time_msc": 1790981179473, "bid": 2391.42, "ask": 2391.6, "last": 0, "volume": 0, "volume_raw": 0, "volume_real": 0.0, "flags": 6 } ``` ## TickHistory The ticks termlessd kept for one symbol (the web protocol serves no tick history). Since 0.7.0 a symbol's ticks are kept from its first GET /ticks read on and dropped when it stops streaming, so a first read is often empty: the newest 1,000 per symbol by default, 100,000 over all of an account's symbols. A reconnect starts it again. | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name, as the broker spells it. (required) | | `kept_from_msc` | integer or null | time_msc of the oldest tick kept for the symbol, whatever the request asked: how far back GET /ticks can reach right now. null while none is kept (a symbol subscribed just now, or TERMLESS_TICK_HISTORY=0). (required) | | `ticks` | array of HistoryTick | Ticks, oldest first. (required; see HistoryTick) | ```json { "symbol": "XAUUSD", "kept_from_msc": 1790980874102, "ticks": [ { "time": 1790981179, "time_msc": 1790981179473, "bid": 2391.42, "ask": 2391.6, "last": 0, "volume": 0, "volume_raw": 0, "volume_real": 0.0, "flags": 6 }, { "time": 1790981179, "time_msc": 1790981179688, "bid": 2391.45, "ask": 2391.6, "last": 0, "volume": 0, "volume_raw": 0, "volume_real": 0.0, "flags": 2 } ] } ``` ## BookLevel One price level of an order book, as market_book_get's BookInfo. | Field | Type | Description | |---|---|---| | `type` | integer | MetaTrader's BOOK_TYPE_*: 1 sell, 2 buy, 3 sell market, 4 buy market. (required; one of 1, 2, 3, 4) | | `side` | string | sell for types 1 and 3, buy for 2 and 4. (required; one of sell, buy) | | `price` | number | The level's price. (required) | | `volume` | integer | Volume at this price in the broker's units (units of the base, as the web terminal shows them; 0.7.0, it was called lots), whole (the official volume). (required) | | `volume_dbl` | number | The same, exactly. (required) | | `lots` | number | The units over the symbol's contract size (0.7.0). (required) | ```json { "type": 1, "side": "sell", "price": 2391.8, "volume": 250, "volume_dbl": 250.0, "lots": 2.5 } ``` ## Book A symbol's order book (depth of market), GET /book. | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name, as the broker spells it. (required) | | `time` | integer | The trade server's time of this book, unix seconds, server time. 0 when the broker has sent no book for the symbol (it likely has no depth there; it is asked again after 5 minutes); an old time means the broker sent no fresh book within 3 s when asked again (asked again after 30 s). (required) | | `time_msc` | integer | The same to the millisecond (a change the broker pushed carries its milliseconds; a full snapshot 0 of them). 0 when time is 0. (required) | | `levels` | array of BookLevel | Sells from the highest price down, then buys from the highest price down. Empty when the market is closed, or when the broker sent no book (time 0). (required; see BookLevel) | ```json { "symbol": "XAUUSD", "time": 1790981179, "time_msc": 1790981179629, "levels": [ { "type": 1, "side": "sell", "price": 2391.8, "volume": 250, "volume_dbl": 250.0, "lots": 2.5 }, { "type": 1, "side": "sell", "price": 2391.6, "volume": 100, "volume_dbl": 100.0, "lots": 1.0 }, { "type": 2, "side": "buy", "price": 2391.42, "volume": 120, "volume_dbl": 120.0, "lots": 1.2 }, { "type": 2, "side": "buy", "price": 2391.2, "volume": 300, "volume_dbl": 300.0, "lots": 3.0 } ] } ``` ## OrdersSnapshot The data of an `orders` event (`events=orders`): once right after the first status, then whenever a broker trade push added, changed or removed a pending order (and after a reconnect when the book changed meanwhile). Sent only when the list differs from the last one sent; orders carry no live price, so ticks never send one. Redraw from each snapshot. | Field | Type | Description | |---|---|---| | `orders` | array of Order | Every pending order (limit, stop, stop limit), as `GET /orders` lists them. (required; see Order) | | `time_ms` | integer | When it was read, unix milliseconds (UTC). (required) | ```json { "orders": [ { "ticket": 51830020, "symbol": "XAUUSD", "type": "buy_limit", "side": "buy", "volume": 0.1, "volume_initial": 0.1, "price": 2365.0, "stop_limit": 0, "sl": 2350.0, "tp": 2410.0, "expiration": 0, "comment": "dip buy", "magic": 0, "reason": "web", "time_setup": 1790977698, "time_setup_msc": 1790977698412 } ], "time_ms": 1790977698430 } ``` ## StreamConnection An open stream and what it has sent. | Field | Type | Description | |---|---|---| | `id` | integer | A number for the stream, unique until the server restarts. (required) | | `kind` | string | sse for /stream, ws for /ws. (required; one of sse, ws) | | `who` | object | (required; object: kind, key_id, name) | | `ip` | string | The client's address (behind --trust-proxy, the proxy header's). (required) | | `user_agent` | string | The client's User-Agent (cut to 200 characters). (required) | | `account` | string | The account streamed. (required) | | `symbols` | array of string | The symbols it receives ticks for (they change with WebSocket subscribe and unsubscribe). (required) | | `events` | array of string | What it asked for with events=. (required; one of ticks, bars, trades, account, positions, orders) | | `batch_ms` | integer | SSE batch window asked for; 0 writes every frame at once. (required) | | `opened_at` | integer | When it opened, unix milliseconds (UTC). (required) | | `sent` | object | (required; object: messages, bytes, ticks, events) | | `last_sent_at` | integer or null | When the last message went out, unix milliseconds (UTC), to about 0.1 s. null before the first. (required) | | `rate_per_s` | number | Messages a second over the last 10 s (or over the stream's life when it is younger). (required) | | `coalesced` | integer | Ticks this stream never saw because it fell behind (the newest per symbol was kept). (required) | ```json { "id": 12, "kind": "sse", "who": { "kind": "key", "key_id": "key_3f9a1c07", "name": "EA bridge (gold)" }, "ip": "203.0.113.7", "user_agent": "python-requests/2.32", "account": "pepperstone-12345678", "symbols": [ "XAUUSD", "EURUSD" ], "events": [ "ticks", "trades", "account" ], "batch_ms": 0, "opened_at": 1790977520000, "sent": { "messages": 52811, "bytes": 6203417, "ticks": 52102, "events": 708 }, "last_sent_at": 1790981179401, "rate_per_s": 14.6, "coalesced": 0 } ``` ## KeyTraffic One key's traffic since the server started (zeros when unused). | Field | Type | Description | |---|---|---| | `key_id` | string | Key id. (required) | | `name` | string | Key name. (required) | | `scope` | string | read, trade or admin. (required; one of read, trade, admin) | | `accounts` | array or null | Accounts it is limited to; null = every account. (required) | | `streams_open` | integer | Streams it has open now. (required) | | `stream_bytes` | integer | Bytes its open streams have sent. (required) | | `requests_1h` | integer | Requests in the last hour. (required) | | `requests_24h` | integer | Requests in the last 24 hours (since the start, if that is later). (required) | | `errors_1h` | integer | Requests in the last hour answered 400 or above. (required) | | `bytes_out_1h` | integer | Response body bytes in the last hour (streams not included). (required) | | `last_request_at` | integer or null | Its last request, unix milliseconds (UTC). null if none since the start. (required) | | `last_ip` | string or null | The address of its last request. (required) | | `top_routes_1h` | array of object | Its busiest routes in the last hour, at most 5. (required; object: route, count) | ```json { "key_id": "key_3f9a1c07", "name": "EA bridge (gold)", "scope": "trade", "accounts": [ "pepperstone-12345678" ], "streams_open": 1, "stream_bytes": 6203417, "requests_1h": 120, "requests_24h": 2211, "errors_1h": 0, "bytes_out_1h": 48210, "last_request_at": 1790981175002, "last_ip": "203.0.113.7", "top_routes_1h": [ { "route": "GET /api/v1/accounts/{id}/positions", "count": 60 }, { "route": "GET /api/v1/accounts/{id}/deals", "count": 60 } ] } ``` ## Connections Who is connected and what they receive, live and in memory since the server started. Key secrets never appear. | Field | Type | Description | |---|---|---| | `time_ms` | integer | Now, unix milliseconds (UTC). (required) | | `since_ms` | integer | When the server started: every counter here begins then; nothing is kept across a restart. (required) | | `streams` | array of StreamConnection | Open streams, newest first. (required; see StreamConnection) | | `keys` | array of KeyTraffic | Every key in the keys table. (required; see KeyTraffic) | | `dashboard` | object | (required; object: sessions_active, streams_open, stream_bytes, requests_1h, requests_24h, errors_1h, bytes_out_1h, last_request_at) | ```json { "time_ms": 1790981179473, "since_ms": 1790968290000, "streams": [ { "id": 12, "kind": "sse", "who": { "kind": "key", "key_id": "key_3f9a1c07", "name": "EA bridge (gold)" }, "ip": "203.0.113.7", "user_agent": "python-requests/2.32", "account": "pepperstone-12345678", "symbols": [ "XAUUSD", "EURUSD" ], "events": [ "ticks", "trades", "account" ], "batch_ms": 0, "opened_at": 1790977520000, "sent": { "messages": 52811, "bytes": 6203417, "ticks": 52102, "events": 708 }, "last_sent_at": 1790981179401, "rate_per_s": 14.6, "coalesced": 0 } ], "keys": [ { "key_id": "key_3f9a1c07", "name": "EA bridge (gold)", "scope": "trade", "accounts": [ "pepperstone-12345678" ], "streams_open": 1, "stream_bytes": 6203417, "requests_1h": 120, "requests_24h": 2211, "errors_1h": 0, "bytes_out_1h": 48210, "last_request_at": 1790981175002, "last_ip": "203.0.113.7", "top_routes_1h": [ { "route": "GET /api/v1/accounts/{id}/positions", "count": 60 }, { "route": "GET /api/v1/accounts/{id}/deals", "count": 60 } ] } ], "dashboard": { "sessions_active": 1, "streams_open": 0, "stream_bytes": 0, "requests_1h": 340, "requests_24h": 1902, "errors_1h": 0, "bytes_out_1h": 912044, "last_request_at": 1790981179470 } } ``` ## TrafficRequest | Field | Type | Description | |---|---|---| | `at` | integer | When it was answered, unix milliseconds (UTC). (required) | | `method` | string | HTTP method. (required) | | `route` | string | Method and the route template it matched, for example GET /api/v1/accounts/{id}/quotes; (no route) when none matched. (required) | | `path` | string | The path asked for, with its query (key= removed, cut to 300 characters). (required) | | `status` | integer | HTTP status answered. (required) | | `latency_ms` | number | Time to the response's headers, milliseconds. (required) | | `bytes` | integer | Response body bytes (0 for a stream; see its own counters). (required) | | `ip` | string | The client's address. (required) | | `account` | string or null | The account in the path, if any. (required) | ```json { "at": 1790981175002, "method": "GET", "route": "GET /api/v1/accounts/{id}/positions", "path": "/api/v1/accounts/pepperstone-12345678/positions?symbol=XAUUSD", "status": 200, "latency_ms": 0.21, "bytes": 812, "ip": "203.0.113.7", "account": "pepperstone-12345678" } ``` ## KeyTrafficLog | Field | Type | Description | |---|---|---| | `key_id` | string | Key id. (required) | | `name` | string | Key name. (required) | | `time_ms` | integer | Now, unix milliseconds (UTC). (required) | | `since_ms` | integer | When the server started. (required) | | `requests` | array of TrafficRequest | Its last requests, newest first (up to 500 are kept). (required; see TrafficRequest) | | `streams` | array of StreamConnection | Its open streams. (required; see StreamConnection) | ```json { "key_id": "key_3f9a1c07", "name": "EA bridge (gold)", "time_ms": 1790981179473, "since_ms": 1790968290000, "requests": [ { "at": 1790981175002, "method": "GET", "route": "GET /api/v1/accounts/{id}/positions", "path": "/api/v1/accounts/pepperstone-12345678/positions?symbol=XAUUSD", "status": 200, "latency_ms": 0.21, "bytes": 812, "ip": "203.0.113.7", "account": "pepperstone-12345678" } ], "streams": [ { "id": 12, "kind": "sse", "who": { "kind": "key", "key_id": "key_3f9a1c07", "name": "EA bridge (gold)" }, "ip": "203.0.113.7", "user_agent": "python-requests/2.32", "account": "pepperstone-12345678", "symbols": [ "XAUUSD", "EURUSD" ], "events": [ "ticks", "trades", "account" ], "batch_ms": 0, "opened_at": 1790977520000, "sent": { "messages": 52811, "bytes": 6203417, "ticks": 52102, "events": 708 }, "last_sent_at": 1790981179401, "rate_per_s": 14.6, "coalesced": 0 } ] } ``` ## Calc order_calc_margin and order_calc_profit in one answer (GET /calc). | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name, as the broker spells it. (required) | | `side` | string | Direction. (required; one of buy, sell) | | `type` | string | The MetaTrader order type the side and type make. (required; one of buy, sell, buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit, sell_stop_limit) | | `volume` | number | Lots. (required) | | `price` | number | The open price used: the one asked for, else the current ask for a buy and bid for a sell. (required) | | `margin` | number or null | The margin the trade needs once it is open, at price, in the account currency, rounded to its digits (order_calc_margin with the market type of its side): for a pending type, what the position needs when the order fills. null when no symbol converts the margin currency to the account's. (required) | | `margin_pending` | number or null | For a pending type: what the broker holds while the order waits (its type's own rate, margin_rates in the spec; 0 at the brokers seen, so nothing). null for a market order, or when no symbol converts the margin currency. (required) | | `close` | number or null | The closing price asked for; null without one. (required) | | `profit` | number or null | What the order makes from price to close, in the account currency, rounded to its digits (order_calc_profit). null without close, or when no symbol converts the profit currency to the account's. (required) | | `currency` | string | The account currency the numbers are in. (required) | ```json { "symbol": "XAUUSD", "side": "buy", "type": "buy", "volume": 0.1, "price": 2391.6, "margin": 119.58, "margin_pending": null, "close": 2400.0, "profit": 84.0, "currency": "USD" } ``` ## OrderCheck What sending an order_send request would do to the account (POST /order_check), in the account currency. The order is not sent. | Field | Type | Description | |---|---|---| | `ok` | boolean | True when retcode is 0: sent now, the order would pass these checks. (required) | | `retcode` | integer | 0 when every check passes, else the first that failed: 10014 invalid volume, 10017 trading disabled, 10044 close only, 10042 long only, 10043 short only, 10018 market closed, 10015 invalid price (a pending price on the wrong side of the market), 10016 invalid stops (a stop-loss or take-profit on the wrong side of its price or closer than stops_level), 10019 not enough money. (required; one of 0, 10014, 10017, 10042, 10043, 10044, 10018, 10015, 10016, 10019) | | `comment` | string | The result in words. (required; one of Done, Invalid volume, Trade disabled, Only position closing is allowed, Only long positions are allowed, Only short positions are allowed, Market closed, Invalid price, Invalid stops, No money) | | `balance` | number | Balance now. (required) | | `equity` | number | Equity now, live. (required) | | `profit` | number | Floating profit now, live. (required) | | `margin` | number | Margin in use with the order (includes request_margin). (required) | | `margin_free` | number | equity - margin, with the order. Below 0 is 10019 for an order that opens something. (required) | | `margin_level` | number | equity / margin x 100 with the order, in percent. 0 with no margin. (required) | | `request_margin` | number | The margin the order itself needs: for a pending order what the broker holds while it waits (usually 0). 0 for an action that opens nothing, and when an earlier check failed. (required) | ```json { "ok": true, "retcode": 0, "comment": "Done", "balance": 10412.58, "equity": 10650.69, "profit": 238.11, "margin": 998.51, "margin_free": 9652.18, "margin_level": 1066.66, "request_margin": 119.58 } ``` ## ApiKeyUpdate Any of the fields; the ones left out stay as they are (0.6.0). | Field | Type | Description | |---|---|---| | `name` | string | A new name, up to 80 characters. | | `scopes` | one of | Exactly one scope, as on create. | | `accounts` | one of | The account ids it may use; null or [] for every account. Not allowed with admin (400); an unknown id is 400 too. | | `max_volume` | one of | The most lots per order that opens something; null for no limit. | | `max_open_per_min` | one of | The most orders that open something in 60 s, 1 to 600; null for no limit. | | `max_daily_loss` | one of | A positive amount in the account's currency; past it (from the forex day's start) orders that open something answer 403 key_limit, not sent (0.7.0). null or left out: no limit. | | `max_drawdown_pct` | one of | More than 0, at most 100: past that many percent below the equity's high since it was set, orders that open something answer 403 key_limit, not sent (0.7.0). Setting or changing it starts its high afresh. | ```json { "scopes": [ "read" ] } ``` ## Ready A bot's pre-flight check, answered from memory with no broker round trip. | Field | Type | Description | |---|---|---| | `account` | string | Account id. (required) | | `checked_at` | integer | When this was worked out, unix milliseconds (UTC). (required) | | `ready_to_read` | boolean | Reads of this account work now: false when any reason blocks read. (required) | | `ready_to_trade` | boolean | An order sent now can reach the broker and be accepted on the account side: false when any reason blocks read or trade. (required) | | `reasons` | array of ReadyReason | Why not, and warnings. Empty when all is well. (required; see ReadyReason) | | `link` | object | (required; object: connected, since, connected_for_s, ping_ms, reconnects, last_frame_age_ms, ping_pending_ms, pings_missed, last_error, retry_at) | | `login` | object | (required; object: logged_in, rejected) | | `server` | object | (required; object: build, build_verified, verified_builds) | | `trading` | object | (required; object: allowed, account_trade_allowed, investor, demo, real_money, key_can_trade) | | `prices` | array of ReadyPrice | The watched symbols, then the asked ones that are not watched. (required; see ReadyPrice) | | `undecoded_last_hour` | integer | Frames from this account the client could not decode in the last hour. (required) | ```json { "account": "pepperstone-12345678", "checked_at": 1792300000123, "ready_to_read": true, "ready_to_trade": true, "reasons": [], "link": { "connected": true, "since": 1792290000, "connected_for_s": 10000, "ping_ms": 12.4, "reconnects": 2, "last_frame_age_ms": 800, "ping_pending_ms": null, "pings_missed": 0, "last_error": null, "retry_at": null }, "login": { "logged_in": true, "rejected": false }, "server": { "build": 6090, "build_verified": true, "verified_builds": [ 6090, 6182, 6230 ] }, "trading": { "allowed": true, "account_trade_allowed": true, "investor": false, "demo": true, "real_money": "demo", "key_can_trade": true }, "prices": [ { "symbol": "XAUUSD", "watched": true, "asked": true, "last_tick_age_ms": 812, "market_open": true, "market_source": "sessions", "fresh": true }, { "symbol": "EURUSD", "watched": true, "asked": false, "last_tick_age_ms": 240, "market_open": true, "market_source": "sessions", "fresh": true } ], "undecoded_last_hour": 0 } ``` ## ReadyReason | Field | Type | Description | |---|---|---| | `code` | string | What it is. Blocks read: turned_off, disconnected, login_rejected. Blocks trade (an order would certainly fail): trade_disabled, investor_login, real_account_blocked, key_read_only, account_not_loaded, market_closed, unknown_symbol. Notes: price_stale and no_price (an asked symbol's price is old or missing; since 0.5.1 a note, since a market order still fills at the broker's price), build_unverified, undecoded_frames, link_quiet, connected_recently. (required; one of turned_off, disconnected, login_rejected, trade_disabled, investor_login, real_account_blocked, key_read_only, account_not_loaded, market_closed, price_stale, no_price, unknown_symbol, build_unverified, undecoded_frames, link_quiet, ping_overdue, connected_recently, new_trades_paused) | | `blocks` | string | read (reading and trading both fail), trade, or none (a note). (required; one of read, trade, none) | | `message` | string | One plain sentence for people and logs. (required) | | `symbol` | string | The symbol, on the per-symbol reasons only. | ```json { "code": "market_closed", "blocks": "trade", "symbol": "EURUSD", "message": "EURUSD's market is closed now (its trading sessions say so); orders would be refused" } ``` ## ReadyPrice | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name. (required) | | `watched` | boolean | On the account's watchlist (streamed). (required) | | `asked` | boolean | Named in symbols=. (required) | | `last_tick_age_ms` | integer or null | Milliseconds since its last tick; null before the first. (required) | | `market_open` | boolean or null | Whether its market is open now; null when that cannot be told. (required) | | `market_source` | string or null | sessions (the spec's quote sessions, on the broker's clock), heuristic (no spec loaded yet: the forex week, Sunday 17:00 to Friday 17:00 New York time), or null. (required; one of sessions, heuristic, None) | | `fresh` | boolean | A tick came within 120 s, or the market is closed (a closed market is never stale). Information: nothing is blocked on it (since 0.5.1). (required) | ```json { "symbol": "XAUUSD", "watched": true, "asked": true, "last_tick_age_ms": 812, "market_open": true, "market_source": "sessions", "fresh": true } ``` ## StatusReport Termless and each broker link, over time: uptime, outages and their causes, prices, order latency, protocol drift. | Field | Type | Description | |---|---|---| | `verdict` | string | down when every enabled account is down (and at least one is enabled), degraded when any account is down or degraded or Termless wrote a crash report in the last 24 hours, healthy otherwise (also with no accounts). (required; one of healthy, degraded, down) | | `summary` | string | One plain sentence for people. (required) | | `checked_at` | integer | When this was worked out, unix milliseconds (UTC). (required) | | `termless` | object | (required; object: version, started_at, uptime_s, rss_kb, rss_peak_kb, restarts_30d, unclean_exits_30d, last_start_at, crash_reports_24h, errors_1h, trail_rows_dropped) | | `accounts` | array of AccountHealth | The accounts the caller may use. (required; see AccountHealth) | ```json { "verdict": "healthy", "summary": "All good: 1 account connected, 99.86% up over the last 24 hours.", "checked_at": 1792300000123, "termless": { "version": "0.6.2", "started_at": 1792200000, "uptime_s": 100000, "rss_kb": 16384, "rss_peak_kb": 20480, "restarts_30d": 3, "unclean_exits_30d": 0, "last_start_at": 1792200000000, "crash_reports_24h": 0, "errors_1h": 0, "trail_rows_dropped": 0 }, "accounts": [ { "id": "pepperstone-12345678", "label": "Pepperstone demo", "server": "Pepperstone-Demo", "broker": "Pepperstone", "enabled": true, "verdict": "healthy", "summary": "Connected for 2 h 46 min, ping 12 ms.", "connected": true, "since": 1792290000, "ping_ms": 12.4, "tracked_since": 1790000000000, "uptime": { "1h": { "percent": 100.0, "up_ms": 3600000, "down_ms": 0, "measured_ms": 3600000, "reconnects": 0, "outages": 0, "longest_outage_ms": 0 }, "24h": { "percent": 99.86, "up_ms": 86280000, "down_ms": 120000, "measured_ms": 86400000, "reconnects": 1, "outages": 1, "longest_outage_ms": 120000 }, "7d": { "percent": 99.97, "up_ms": 604620000, "down_ms": 180000, "measured_ms": 604800000, "reconnects": 3, "outages": 2, "longest_outage_ms": 120000 }, "30d": { "percent": 99.95, "up_ms": 2590710000, "down_ms": 1290000, "measured_ms": 2592000000, "reconnects": 9, "outages": 6, "longest_outage_ms": 600000 } }, "days": [ { "date": "2026-09-19", "from": 1789776000000, "percent": null, "up_ms": 0, "down_ms": 0, "measured_ms": 0, "outages": 0 }, { "date": "2026-10-18", "from": 1792281600000, "percent": 99.35, "up_ms": 18280000, "down_ms": 120000, "measured_ms": 18400000, "outages": 1 } ], "outages": [ { "from": 1792291200000, "to": 1792291320000, "duration_ms": 120000, "ongoing": false, "start_estimated": false, "detected_at": null, "cause": "broker_maintenance", "message": "Pepperstone restarted its servers; back after 2 min.", "detail": "login refused (code 2) for 1 min after the link dropped" }, { "from": 1792199996000, "to": 1792200001200, "duration_ms": 5200, "ongoing": false, "start_estimated": false, "detected_at": null, "cause": "termless_restart", "message": "Termless restarted; back after 5 s.", "detail": "termlessd stopped (upgrade or restart)" } ], "ticks": { "per_min": 384.0, "seen": 1234567, "last_tick_age_ms": 400, "feed_quiet": false, "symbols": [ { "symbol": "EURUSD", "last_tick_age_ms": 400, "market_open": true, "fresh": true }, { "symbol": "XAUUSD", "last_tick_age_ms": 812, "market_open": true, "fresh": true } ] }, "orders": { "window_h": 24, "count": 12, "done": 11, "rejected": 1, "timeout": 0, "failed": 0, "latency_ms": { "p50": 41, "p95": 120, "max": 133 } }, "protocol": { "build": 6090, "build_verified": true, "undecoded_1h": 0, "undecoded_24h": 0, "undecoded_by_command": [] }, "pings_missed": 2, "trades_unconfirmed": 0, "trades_late": 0, "command_waits": 1840, "command_wait_ms": 3120 } ] } ``` ## AccountHealth One account in GET /status. | Field | Type | Description | |---|---|---| | `id` | string | Account id. (required) | | `label` | string | Display name. (required) | | `server` | string | Trade server name. (required) | | `broker` | string | The server name's first word (Pepperstone-Demo is Pepperstone), used in the sentences. (required) | | `enabled` | boolean | False when an admin turned it off. (required) | | `verdict` | string | down: enabled and not connected. degraded: connected but an unverified build, undecoded frames in the last hour, its price feed stopped (ticks.feed_quiet), ping over 1000 ms, or under 99% up over the last hour. off: turned off. healthy otherwise. (required; one of healthy, degraded, down, off) | | `summary` | string | One plain sentence for people. (required) | | `connected` | boolean | Whether the link is up now. (required) | | `since` | integer or null | When the current connection came up, unix seconds (UTC). (required) | | `ping_ms` | number or null | Last heartbeat round trip. (required) | | `tracked_since` | integer or null | Where the 30-day numbers start: 30 days ago, or later when the account was added or its connection history starts inside that window; unix milliseconds (UTC); null with no history. (required) | | `uptime` | object | Each window ends now. (required; object: 1h, 24h, 7d, 30d) | | `days` | array of UptimeDay | The last 30 UTC days, oldest first; today runs up to now. (required; see UptimeDay) | | `outages` | array of Outage | Newest first: those overlapping the last 30 days, at most 50. (required; see Outage) | | `ticks` | object | (required; object: per_min, seen, last_tick_age_ms, feed_quiet, symbols) | | `orders` | object | (required; object: window_h, count, done, rejected, timeout, failed, latency_ms) | | `pings_missed` | integer | Heartbeat pings the broker did not answer in time since the server started (0.6.0); two in a row cut the link. (required) | | `trades_unconfirmed` | integer | Trades answered 504 unconfirmed since the start (0.6.0). (required) | | `trades_late` | integer | Of them, those whose final result came later (0.6.0). (required) | | `command_waits` | integer | Requests that waited for their command's turn since the start (most wait no time; 0.6.0). (required) | | `command_wait_ms` | integer | The time they waited, in all, in milliseconds (0.6.0). (required) | | `protocol` | object | (required; object: build, build_verified, undecoded_1h, undecoded_24h, undecoded_by_command) | ```json { "id": "pepperstone-12345678", "label": "Pepperstone demo", "server": "Pepperstone-Demo", "broker": "Pepperstone", "enabled": true, "verdict": "healthy", "summary": "Connected for 2 h 46 min, ping 12 ms.", "connected": true, "since": 1792290000, "ping_ms": 12.4, "tracked_since": 1790000000000, "uptime": { "1h": { "percent": 100.0, "up_ms": 3600000, "down_ms": 0, "measured_ms": 3600000, "reconnects": 0, "outages": 0, "longest_outage_ms": 0 }, "24h": { "percent": 99.86, "up_ms": 86280000, "down_ms": 120000, "measured_ms": 86400000, "reconnects": 1, "outages": 1, "longest_outage_ms": 120000 }, "7d": { "percent": 99.97, "up_ms": 604620000, "down_ms": 180000, "measured_ms": 604800000, "reconnects": 3, "outages": 2, "longest_outage_ms": 120000 }, "30d": { "percent": 99.95, "up_ms": 2590710000, "down_ms": 1290000, "measured_ms": 2592000000, "reconnects": 9, "outages": 6, "longest_outage_ms": 600000 } }, "days": [ { "date": "2026-09-19", "from": 1789776000000, "percent": null, "up_ms": 0, "down_ms": 0, "measured_ms": 0, "outages": 0 }, { "date": "2026-10-18", "from": 1792281600000, "percent": 99.35, "up_ms": 18280000, "down_ms": 120000, "measured_ms": 18400000, "outages": 1 } ], "outages": [ { "from": 1792291200000, "to": 1792291320000, "duration_ms": 120000, "ongoing": false, "start_estimated": false, "detected_at": null, "cause": "broker_maintenance", "message": "Pepperstone restarted its servers; back after 2 min.", "detail": "login refused (code 2) for 1 min after the link dropped" }, { "from": 1792199996000, "to": 1792200001200, "duration_ms": 5200, "ongoing": false, "start_estimated": false, "detected_at": null, "cause": "termless_restart", "message": "Termless restarted; back after 5 s.", "detail": "termlessd stopped (upgrade or restart)" } ], "ticks": { "per_min": 384.0, "seen": 1234567, "last_tick_age_ms": 400, "feed_quiet": false, "symbols": [ { "symbol": "EURUSD", "last_tick_age_ms": 400, "market_open": true, "fresh": true }, { "symbol": "XAUUSD", "last_tick_age_ms": 812, "market_open": true, "fresh": true } ] }, "orders": { "window_h": 24, "count": 12, "done": 11, "rejected": 1, "timeout": 0, "failed": 0, "latency_ms": { "p50": 41, "p95": 120, "max": 133 } }, "protocol": { "build": 6090, "build_verified": true, "undecoded_1h": 0, "undecoded_24h": 0, "undecoded_by_command": [] }, "pings_missed": 2, "trades_unconfirmed": 0, "trades_late": 0, "command_waits": 1840, "command_wait_ms": 3120 } ``` ## UptimeWindow | Field | Type | Description | |---|---|---| | `percent` | number or null | up_ms / measured_ms x 100, 2 decimals; null when nothing was measured. (required) | | `up_ms` | integer | Connected. (required) | | `down_ms` | integer | Not connected, Termless's own downtime included. (required) | | `measured_ms` | integer | The window less the time before the account was added (or before its history starts) and the time it was turned off. (required) | | `reconnects` | integer | Links that came back inside the window. (required) | | `outages` | integer | Outages overlapping the window. (required) | | `longest_outage_ms` | integer | The longest of them, clipped to the window. (required) | ```json { "percent": 99.86, "up_ms": 86280000, "down_ms": 120000, "measured_ms": 86400000, "reconnects": 1, "outages": 1, "longest_outage_ms": 120000 } ``` ## UptimeDay | Field | Type | Description | |---|---|---| | `date` | string | The UTC day, YYYY-MM-DD. (required) | | `from` | integer | Its 00:00 UTC, unix milliseconds. (required) | | `percent` | number or null | As in a window; null for a day with nothing measured. (required) | | `up_ms` | integer | Connected. (required) | | `down_ms` | integer | Not connected. (required) | | `measured_ms` | integer | Measured time in the day (today: up to now). (required) | | `outages` | integer | Outages overlapping the day. (required) | ```json { "date": "2026-10-18", "from": 1792281600000, "percent": 99.35, "up_ms": 18280000, "down_ms": 120000, "measured_ms": 18400000, "outages": 1 } ``` ## Outage | Field | Type | Description | |---|---|---| | `from` | integer | When the link was lost (or Termless stopped), unix milliseconds (UTC). (required) | | `to` | integer or null | When it was connected again; null while it lasts. (required) | | `duration_ms` | integer | to - from, or up to now while it lasts. (required) | | `ongoing` | boolean | True while it lasts. (required) | | `start_estimated` | boolean | True when from is an estimate (0.6.0): a link cut for missed pings is down from its first unanswered ping, 12 to 17 s before the cut. (required) | | `detected_at` | integer or null | When the drop was noticed (the cut), unix milliseconds (UTC), if from is an estimate; else null. (required) | | `cause` | string | broker_maintenance (logins refused with code 2 right after the drop, or the forex weekend break), broker_unreachable (TCP, TLS or the WebSocket upgrade failed or timed out), broker_unresponsive (connected but the broker stopped answering), termless_restart (Termless stopped, restarted, upgraded or was killed, or the account's session started again), network (name lookups failing, no route, connections reset), login_refused (the login details refused), unknown. (required; one of broker_maintenance, broker_unreachable, broker_unresponsive, termless_restart, network, login_refused, unknown) | | `message` | string | One plain sentence for people. (required) | | `detail` | string or null | The technical reason seen (the lost event's reason, the connect errors). (required) | ```json { "from": 1792291200000, "to": 1792291320000, "duration_ms": 120000, "ongoing": false, "start_estimated": false, "detected_at": null, "cause": "broker_maintenance", "message": "Pepperstone restarted its servers; back after 2 min.", "detail": "login refused (code 2) for 1 min after the link dropped" } ``` ## Gap Ticks a stream missed (0.7.0): `event: gap` on SSE, `type: gap` on the WebSocket. They are never replayed: the broker keeps no tick history. | Field | Type | Description | |---|---|---| | `reason` | string | behind: this stream fell behind and kept only the newest tick per symbol; reconnect: the broker link was down; fanout: the account's fan-out fell behind the session. (required; one of behind, reconnect, fanout) | | `symbols` | array of string | behind: the symbols that lost ticks; otherwise every symbol of the stream. (required) | | `dropped` | integer or null | behind: how many ticks this stream lost; null when nobody can count them. (required) | | `from_msc` | integer | behind: the first dropped tick's time; otherwise the last tick this stream got before. Ticks' own clock. (required) | | `to_msc` | integer | behind: the last dropped tick's time; otherwise the first tick after, which follows this event. (required) | | `from_utc_msc` | integer | from_msc in UTC; only with the account's clock rule (0.7.1). | | `to_utc_msc` | integer | to_msc in UTC; only with the account's clock rule (0.7.1). | | `from_utc_ambiguous` | boolean | true when from_msc falls in New York's repeated autumn hour (0.7.1). | | `to_utc_ambiguous` | boolean | true when to_msc falls in New York's repeated autumn hour (0.7.1). | ```json { "reason": "reconnect", "symbols": [ "XAUUSD" ], "dropped": null, "from_msc": 1790981170212, "to_msc": 1790981191408 } ``` ## Bar A bar of a bar series (0.7.0, events=bars): `event: bar` on SSE, `type: bar` on the WebSocket. | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name. (required) | | `timeframe` | string | Timeframe. (required; one of M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1) | | `time` | integer | Bar open time, unix seconds, trade server clock. (required) | | `open` | number | Open. (required) | | `high` | number | High. (required) | | `low` | number | Low. (required) | | `close` | number | Close. (required) | | `tick_volume` | integer | Tick count in the bar. (required) | | `real_volume` | integer | Exchange volume. (required) | | `state` | string | forming: built from the bids, at most four a second per series; closed: the broker's bar once its period ended (plus 2 s), sent once per period, or later for a period whose tick came late (0.7.1: bars can arrive out of time order, place each by time); corrected: the broker's bar differs from the one sent (read again a minute later, or after the server clock went back). (required; one of forming, closed, corrected) | ```json { "symbol": "XAUUSD", "timeframe": "M1", "time": 1790981160, "open": 2391.2, "high": 2391.9, "low": 2391.1, "close": 2391.42, "tick_volume": 112, "real_volume": 0, "state": "forming" } ``` ## BarsGap Bars a series cannot send (0.7.0): over 500 missed during an outage, a stream far behind, or (0.7.1) a bar that could not be read again or a minute of failed reads. Read the range by REST. | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name. (required) | | `timeframe` | string | Timeframe. (required; one of M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1) | | `from` | integer | The first missed bar's open time. (required) | | `to` | integer | The last missed bar's open time. (required) | | `from_utc` | integer | from in UTC; only with the account's clock rule (0.7.1). | | `to_utc` | integer | to in UTC; only with the account's clock rule (0.7.1). | | `from_utc_ambiguous` | boolean | true when from falls in New York's repeated autumn hour (0.7.1). | | `to_utc_ambiguous` | boolean | true when to falls in New York's repeated autumn hour (0.7.1). | ```json { "symbol": "XAUUSD", "timeframe": "M1", "from": 1790944800, "to": 1790981100 } ``` ## OverviewAccount One account: its summary, or why there is none (not connected, for example). | Field | Type | Description | |---|---|---| | `id` | string | Account id. (required) | | `summary` | object | (see Summary) | | `error` | object | (object: code, message, status) | ## Overview | Field | Type | Description | |---|---|---| | `accounts` | array of OverviewAccount | Every enabled account the caller may read. (required; see OverviewAccount) | ```json { "accounts": [ { "id": "pepperstone-12345678", "summary": { "login": 12345678, "name": "Demo Trader", "server": "Pepperstone-Demo", "company": "Pepperstone Group Limited", "currency": "USD", "leverage": 200, "balance": 10412.58, "credit": 0.0, "profit": 238.11, "equity": 10650.69, "margin": 878.93, "margin_free": 9771.76, "margin_level": 1211.78, "margin_so_call": 100.0, "margin_so_so": 50.0, "trade_allowed": true, "demo": true, "hedging": true, "server_offset": 10800, "positions": 3, "orders": 2 } } ] } ``` ## StatsDay | Field | Type | Description | |---|---|---| | `day` | string | YYYY-MM-DD: the forex day under a clock rule, else the server's date. (required) | | `profit` | number | What the trades closed that day made. (required) | | `trades` | integer | Trades closed that day. (required) | ## Stats A trade is a position with a closing deal in the range; its result is every deal of it the history read holds (profit, swap, commission, fee; the read starts 7 days early so an opening commission counts), its time its last closing deal's. | Field | Type | Description | |---|---|---| | `trades` | integer | Positions with a closing deal in the range. (required) | | `wins` | integer | Trades that made money. (required) | | `losses` | integer | Trades that lost money. (required) | | `win_rate` | number or null | Percent of trades won; null with no trades. (required) | | `profit_factor` | number or null | What the wins made over what the losses lost; null with no losses. (required) | | `avg_win` | number or null | Per winning trade. (required) | | `avg_loss` | number or null | Per losing trade (negative). (required) | | `gross_profit` | number | What the wins made. (required) | | `gross_loss` | number | What the losses lost (negative). (required) | | `net` | number | The trades' results together. (required) | | `max_drawdown` | number | The largest fall of the closed results from a high, in time order (positive). (required) | | `by_day` | array of StatsDay | Each day with a closed trade, oldest first. (required; see StatsDay) | | `from` | integer | Range start, unix seconds, server time. (required) | | `to` | integer | Range end. (required) | | `from_utc` | integer | Range start in UTC; only with the account's clock rule (0.7.1). | | `to_utc` | integer | Range end in UTC; only with the account's clock rule (0.7.1). | | `from_utc_ambiguous` | boolean | true when from falls in New York's repeated autumn hour (0.7.1). | | `to_utc_ambiguous` | boolean | true when to falls in New York's repeated autumn hour (0.7.1). | | `currency` | string or null | The account's currency. (required) | ```json { "trades": 5, "wins": 3, "losses": 2, "win_rate": 60.0, "profit_factor": 2.02, "avg_win": 29.0, "avg_loss": -21.5, "gross_profit": 87.0, "gross_loss": -43.0, "net": 44.0, "max_drawdown": 32.0, "by_day": [ { "day": "2026-11-30", "profit": 16.0, "trades": 2 }, { "day": "2026-12-01", "profit": 28.0, "trades": 3 } ], "from": 1793780000, "to": 1796372000, "currency": "USD" } ``` ## SpecItem A spec as GET /symbols/{symbol} gives it, plus its name and when it was read; or an error for a name the broker does not know. *spec* | Field | Type | Description | |---|---|---| | `name` | string | Symbol name. (required) | | `description` | string | Broker's description. (required) | | `path` | string | Folder in the broker's symbol tree. (required) | | `digits` | integer | Price decimals. (required) | | `point` | number | Smallest price step, 10^-digits. (required) | | `contract_size` | number | Units per 1.00 lot. (required) | | `tick_size` | number | Smallest price change. The point when the broker does not send one. (required) | | `tick_value` | number or null | Value of one tick_size move for 1.00 lot, in the account currency. The broker's own figure, else worked out as the terminal does: tick_size x contract_size, converted from currency_profit to the account currency, for forex, CFD, leveraged CFD and exchange stock symbols. null when the broker sends none and it cannot be worked out (futures and index CFDs, or no conversion symbol). Pepperstone sends neither tick value nor tick size. (required) | | `currency_base` | string | Base currency. (required) | | `currency_profit` | string | Profit currency. (required) | | `currency_margin` | string | Margin currency. (required) | | `volume_min` | number | Smallest order, in lots. (required) | | `volume_max` | number | Largest order, in lots. (required) | | `volume_step` | number | Lot step. (required) | | `volume_limit` | number | Largest total of open positions and pending orders in one direction, in lots. 0 = no limit. (required) | | `trade_mode` | string | Whether trading is allowed. unknown only for a value MetaTrader does not define. (required; one of full, long_only, short_only, close_only, disabled, unknown) | | `execution` | string | Execution mode. unknown only for a value MetaTrader does not define. (required; one of market, instant, request, exchange, unknown) | | `filling` | array of string | Filling modes the symbol allows. (required; one of fok, ioc, return) | | `stops_level` | integer | Minimum distance of SL and TP from the price, in points. (required) | | `freeze_level` | integer | Distance in points inside which orders cannot be changed. (required) | | `swap_long` | number | Swap for long positions, in the unit swap_mode names. (required) | | `swap_short` | number | Swap for short positions, in the unit swap_mode names. (required) | | `swap_mode` | string | The unit of swap_long and swap_short. unknown only for a value MetaTrader does not define. (required; one of disabled, points, symbol_currency, margin_currency, deposit_currency, interest_current, interest_open, reopen_current, reopen_bid, profit_currency, unknown) | | `swap_3day` | string or null | The day the swap is charged three times: sunday, monday, tuesday, wednesday, thursday, friday or saturday. null for none (crypto CFDs send none). (required) | | `margin_initial` | number | Initial margin setting of the symbol, as the broker sends it. (required) | | `margin_maintenance` | number | Maintenance margin setting, as the broker sends it. (required) | | `margin_hedged` | number | Margin for a hedged pair of positions (one lot each way), as the broker sends it. (required) | | `margin_rate_buy` | number | Initial margin rate for a buy (the same as margin_rates.buy). (required) | | `margin_rate_sell` | number | Initial margin rate for a sell (the same as margin_rates.sell). (required) | | `margin_rates` | object | Every order type's initial margin rate, as the broker sends it. A pending type's rate is what the broker holds while such an order waits: the brokers seen send 0 there (nothing is held), and once the order fills the position needs its side's market rate. A market rate of 0 counts as 1. (required; object: buy, sell, buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit, sell_stop_limit) | | `expiration` | array of string | The expiry modes a pending order on this symbol may use. (required; one of gtc, day, specified, specified_day) | | `order_types` | array of string | The order types the symbol takes. (required; one of market, limit, stop, stop_limit, sl, tp, close_by) | | `sessions` | object | (required; object: quote, trade) | | `tradeable` | boolean or null | Whether a trade can be opened now, as on /quotes: the trade_mode is full, long_only or short_only, and one of today's trade sessions is open by the server's clock. null when the broker sent no trade sessions. (required) | | `book_depth` | integer | The levels a side of the symbol's order book may hold (0 when the broker sends none); a book past it is renewed (0.7.0). | | `fetched_at_ms` | integer or null | When it was read from the broker, unix ms. (required) | *error* | Field | Type | Description | |---|---|---| | `name` | string | The name as asked. (required) | | `error` | object | (required; object: code, message) | ## CandleBatchRequest | Field | Type | Description | |---|---|---| | `items` | array of object | 1 to 20 ranges, at most 200,000 bars in all (each item's whole range counts). (required; object: symbol, timeframe, from, to) | ```json { "items": [ { "symbol": "XAUUSD", "timeframe": "M5", "from": 1790894400, "to": 1790980800 }, { "symbol": "EURUSD", "timeframe": "H1", "from": 1790376000, "to": 1790980800 } ] } ``` ## CandleBatchItem *candles* | Field | Type | Description | |---|---|---| | `symbol` | string | Symbol name, as the broker spells it. (required) | | `timeframe` | string | Timeframe. (required; one of M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1) | | `from` | integer | As asked. (required) | | `to` | integer | As asked. (required) | | `truncated` | boolean | The range held more than 50,000 bars; the newest are kept. (required) | | `candles` | array of Candle | Bars, oldest first. (required; see Candle) | *error* | Field | Type | Description | |---|---|---| | `symbol` | string | The name as asked. (required) | | `timeframe` | string | Timeframe. (required) | | `from` | integer | As asked. (required) | | `to` | integer | As asked. (required) | | `error` | object | (required; object: code, message, status) | ## CandleBatch | Field | Type | Description | |---|---|---| | `items` | array of CandleBatchItem | One per range asked, in order. (required) |