# Accounts The MT5 accounts this server keeps connected around the clock. Each has an id you choose, used in every account URL. A route that needs the broker answers 503 while the account reconnects (it waits up to 2 s first) or while it is turned off. On an account the broker reports as real money, trading is off until an admin sets `trade_real: true`. ### List accounts `GET /api/v1/accounts` Scope: read. Every account the key may see, with its live connection status. **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Response 200**: Accounts. A JSON array of Account. | 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) | Example: ```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 } } ] ``` **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. **curl** ```sh curl -s "$TERMLESS_URL/api/v1/accounts" \ -H "Authorization: Bearer $TERMLESS_KEY" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.get(f"{base}/accounts", headers=auth) r.raise_for_status() print(r.json()) ``` ### Add an account `POST /api/v1/accounts` Scope: admin. Saves the account and starts connecting it in the background, so `status.connected` is false at first. Poll `GET /api/v1/accounts/{id}` until it connects; a refused login shows in `status.last_error` and `status.login_rejected`. `host` is looked up from `server` (this install's directory, then the built-in list) when omitted; 400 if it cannot be found. 409 if the id, or the same login on the same host, exists. `trade_real: true` allows trading if the broker reports the account as real money (off by default). **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Request body** (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) | Example: ```json { "label": "Pepperstone demo", "login": 12345678, "password": "your MT5 password", "server": "Pepperstone-Demo", "symbols": [ "XAUUSD", "EURUSD" ] } ``` **Response 201**: Saved. Connecting in the background. A Account object. | 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) | Example: ```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": 1790981179, "tls_name": null, "trade_real": false, "new_trades_paused": false, "clock": null, "pinned": false, "status": { "connected": false, "since": null, "reconnects": 0, "ping_ms": null, "server_build": null, "last_error": null, "subscribed": 0, "login_rejected": false, "retry_at": null } } ``` **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `409 conflict`: The thing already exists or the state does not allow it. On a trade route with an Idempotency-Key: the key was already used with a different body or query string, or the first request with it did not finish (cut off, or the server restarted; check positions and orders, then use a new key), or it is still running after 30 s. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. **curl** ```sh curl -s -X POST "$TERMLESS_URL/api/v1/accounts" \ -H "Authorization: Bearer $TERMLESS_KEY" \ -H "Content-Type: application/json" \ -d '{"label": "Pepperstone demo", "login": 12345678, "password": "your MT5 password", "server": "Pepperstone-Demo", "symbols": ["XAUUSD", "EURUSD"]}' ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.post(f"{base}/accounts", headers=auth, json={ "label": "Pepperstone demo", "login": 12345678, "password": "your MT5 password", "server": "Pepperstone-Demo", "symbols": [ "XAUUSD", "EURUSD" ] }) r.raise_for_status() print(r.json()) ``` ### Get an account `GET /api/v1/accounts/{id}` Scope: read. One account with its live connection status. **Path parameters** | Name | Type | Required | Description | |---|---|---|---| | `id` | string | yes | Account id. | **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Response 200**: The account. A Account object. | 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) | Example: ```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 } } ``` **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `404 not_found`: No such account, symbol, ticket, key or route. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. **curl** ```sh curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \ -H "Authorization: Bearer $TERMLESS_KEY" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.get(f"{base}/accounts/pepperstone-12345678", headers=auth) r.raise_for_status() print(r.json()) ``` ### Update an account `PATCH /api/v1/accounts/{id}` Scope: admin. Change the label, watchlist or login details, or turn it off with `enabled: false` (logs out and parks it). Changing password, server, host, port or tls_name logs in again; `symbols` replaces the watchlist and starts streaming new ones without logging in again. `trade_real` allows (true) or stops (false) trading when the broker reports the account as real money; it takes effect at once. **Path parameters** | Name | Type | Required | Description | |---|---|---|---| | `id` | string | yes | Account id. | **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Request body** (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) | Example: ```json { "symbols": [ "XAUUSD", "EURUSD", "GBPUSD" ] } ``` **Response 200**: The updated account. A Account object. | 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) | Example: ```json { "id": "pepperstone-12345678", "label": "Pepperstone demo", "login": 12345678, "server": "Pepperstone-Demo", "host": "mt5-demo01.pepperstone.com", "port": 443, "symbols": [ "XAUUSD", "EURUSD", "GBPUSD" ], "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 } } ``` **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `404 not_found`: No such account, symbol, ticket, key or route. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. **curl** ```sh curl -s -X PATCH "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \ -H "Authorization: Bearer $TERMLESS_KEY" \ -H "Content-Type: application/json" \ -d '{"symbols": ["XAUUSD", "EURUSD", "GBPUSD"]}' ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.patch(f"{base}/accounts/pepperstone-12345678", headers=auth, json={ "symbols": [ "XAUUSD", "EURUSD", "GBPUSD" ] }) r.raise_for_status() print(r.json()) ``` ### Remove an account `DELETE /api/v1/accounts/{id}` Scope: admin. Logs out and forgets the account. Positions at the broker are not touched. **Path parameters** | Name | Type | Required | Description | |---|---|---|---| | `id` | string | yes | Account id. | **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Response 204**: Removed. **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `404 not_found`: No such account, symbol, ticket, key or route. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. **curl** ```sh curl -s -X DELETE "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678" \ -H "Authorization: Bearer $TERMLESS_KEY" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.delete(f"{base}/accounts/pepperstone-12345678", headers=auth) r.raise_for_status() # 204, no body ``` ### Get balance and margin `GET /api/v1/accounts/{id}/summary` Scope: read. Balance, equity, margin and the counts of positions and orders, the same numbers MT5 shows. Profit, equity and margin are live. `server_offset` turns this account's market and trade times into UTC. Never waits on the broker once the account record has been read: a copy older than 5 s is answered at once and read again in the background (balance and credit follow the trade pushes either way). **Path parameters** | Name | Type | Required | Description | |---|---|---|---| | `id` | string | yes | Account id. | **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Response 200**: Account summary. A Summary object. | 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) | Example: ```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 } ``` **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `404 not_found`: No such account, symbol, ticket, key or route. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. - `502 broker_error`: The broker's server failed or answered with something unexpected. - `503 disconnected, busy, stopping`: disconnected: the account is not connected (it reconnects on its own; the route waits up to 2 s first) or is turned off; retry with backoff (on a trade route it was never sent: a trade's Idempotency-Key is let go). busy: requests of one command go to the broker one at a time per account, and this one waited its whole turn (20 s) behind earlier ones and was never sent, so sending it again is safe (a trade's Idempotency-Key is let go, so the retry with the same key is sent). - `504 timeout, unconfirmed`: timeout: the broker did not answer a request that was sent (one broker call is given 20 s), or the whole request ran past 30 s (TERMLESS_REQUEST_TIMEOUT). unconfirmed (trades, since 0.6.0): the broker took the trade but its final result did not come, so it may have been carried out; the body adds request_id, retcode (null or the last in-between state, 10001 to 10003) and retcode_text. Retry with the same Idempotency-Key: the stored answer is replayed (the real result once it came late), so the broker never sees it twice; then check positions and orders. **curl** ```sh curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/summary" \ -H "Authorization: Bearer $TERMLESS_KEY" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.get(f"{base}/accounts/pepperstone-12345678/summary", headers=auth) r.raise_for_status() print(r.json()) ``` ### Get every account's summary `GET /api/v1/overview` Scope: read. The summary of every enabled account the caller may read, read together, in one request (0.7.0): what the dashboard's Overview asks every 4 s. An account with no summary (not connected) carries an error instead. **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Response 200**: Summaries. A Overview object. | Field | Type | Description | |---|---|---| | `accounts` | array of OverviewAccount | Every enabled account the caller may read. (required; see OverviewAccount) | Example: ```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 } } ] } ``` **Errors** - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. **curl** ```sh curl -s "$TERMLESS_URL/api/v1/overview" \ -H "Authorization: Bearer $TERMLESS_KEY" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.get(f"{base}/overview", headers=auth) r.raise_for_status() print(r.json()) ``` ### Check the account is ready `GET /api/v1/accounts/{id}/ready` Scope: read. A bot's pre-flight check before it sends an order: `ready_to_read` and `ready_to_trade`, the `reasons` (a machine `code`, what it `blocks`: read, trade or none, and a plain `message`), and the facts behind them: the link (connected, since, ping, the last frame's age), the login, the server build and whether Termless has been checked against it, the trade side (the broker allows trading, investor login, demo, the real-money switch, whether the caller's key can trade), each watched or asked symbol's last tick age and whether its market is open (from the symbol's quote sessions; a closed market is never stale), and frames that could not be decoded in the last hour. Answered from memory, with no broker round trip, so it is cheap enough to call before every order. A not-ready account is a 200 with the reasons, not an error. **Path parameters** | Name | Type | Required | Description | |---|---|---|---| | `id` | string | yes | Account id. | **Query parameters** | Name | Type | Required | Description | |---|---|---|---| | `symbols` | string | no | The symbols you are about to trade, comma-separated, at most 50 (more is 400). Their market must be open for ready_to_trade (an old or missing price is a note, price_stale or no_price, not a block; each one's age is in prices); an unknown one is the reason unknown_symbol. | **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Response 200**: The check. A Ready object. | 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) | Example: ```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 } ``` **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `404 not_found`: No such account, symbol, ticket, key or route. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. **curl** ```sh curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/ready?symbols=XAUUSD,EURUSD" \ -H "Authorization: Bearer $TERMLESS_KEY" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.get(f"{base}/accounts/pepperstone-12345678/ready", headers=auth, params={"symbols": "XAUUSD,EURUSD"}) r.raise_for_status() print(r.json()) ``` ### Get account statistics `GET /api/v1/accounts/{id}/stats` Scope: read. The trades closed in a range (0.7.0): trades, wins and losses, win rate, profit factor, average win and loss, the largest drawdown of the closed results and the profit of each day (the forex day from 17:00 New York with a clock rule, else the server's date). An answer is kept while the account's trade log has not moved, at most 5 minutes. **Path parameters** | Name | Type | Required | Description | |---|---|---|---| | `id` | string | yes | Account id. | **Query parameters** | Name | Type | Required | Description | |---|---|---|---| | `from` | integer | no | Range start, unix seconds, server time. | | `to` | integer | no | Range end; defaults to now. | | `days` | integer | no | Instead of from: this many days before to (1 to 366; default 30). (1 to 366) | **Headers** | Name | Type | Required | Description | |---|---|---|---| | `X-Request-Id` | string | no | Your own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes. | **Response 200**: Statistics. A Stats object. | 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) | Example: ```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" } ``` **Errors** - `400 bad_request`: A field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes; `key=` is accepted anywhere). - `401 unauthorized`: No valid API key or session. - `403 forbidden`: The key lacks the scope, or may not use this account, or a cookie request came from another site. - `404 not_found`: No such account, symbol, ticket, key or route. - `429 too_many_requests`: This IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait. - `502 broker_error`: The broker's server failed or answered with something unexpected. - `503 disconnected, busy, stopping`: disconnected: the account is not connected (it reconnects on its own; the route waits up to 2 s first) or is turned off; retry with backoff (on a trade route it was never sent: a trade's Idempotency-Key is let go). busy: requests of one command go to the broker one at a time per account, and this one waited its whole turn (20 s) behind earlier ones and was never sent, so sending it again is safe (a trade's Idempotency-Key is let go, so the retry with the same key is sent). - `504 timeout, unconfirmed`: timeout: the broker did not answer a request that was sent (one broker call is given 20 s), or the whole request ran past 30 s (TERMLESS_REQUEST_TIMEOUT). unconfirmed (trades, since 0.6.0): the broker took the trade but its final result did not come, so it may have been carried out; the body adds request_id, retcode (null or the last in-between state, 10001 to 10003) and retcode_text. Retry with the same Idempotency-Key: the stored answer is replayed (the real result once it came late), so the broker never sees it twice; then check positions and orders. **curl** ```sh curl -s "$TERMLESS_URL/api/v1/accounts/pepperstone-12345678/stats?days=30" \ -H "Authorization: Bearer $TERMLESS_KEY" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]} r = requests.get(f"{base}/accounts/pepperstone-12345678/stats", headers=auth, params={"days": 30}) r.raise_for_status() print(r.json()) ```