Reference
Diagnostics
What the server itself is doing: the process, each account's connection, frames the client could not decode, recent warnings, crash reports and the log. Undecodable frames are the first sign of a broker build the client does not understand. Each (account, command, kind) keeps at most 5 bodies an hour; the rest are only counted. Kept ones are also appended to <data>/captures/undecoded.jsonl, and the newest of them are read back at start, so a restart does not empty the list (the counters start again). Admin only.
Get diagnostics
/api/v1/diagnosticsOne snapshot of the server: version and build target, process stats (null off Linux), data folder, log file, database size, dashboard sessions, open streams, every account's status with tick and decode counters, frames the client could not decode, the last 100 warnings and errors, crash reports, and the report from an unclean exit, if any.
Headers
X-Request-IdstringYour 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 Diagnostics.
A Diagnostics object.
versionstring requiredServer version.
targetstring requiredThe platform the binary was built for, for example x86_64-unknown-linux-gnu.
pidinteger requiredProcess id.
started_atinteger requiredWhen the server started, unix seconds (UTC).
uptime_sinteger requiredSeconds since the server started.
processobject requiredRead from /proc; every field is null off Linux.
Fields
rss_kbinteger or null requiredResident memory in KB.
rss_peak_kbinteger or null requiredThe most resident memory since the start, in KB (VmHWM).
threadsinteger or null requiredThreads.
open_filesinteger or null requiredOpen file descriptors.
data_dirstring requiredThe data folder.
log_filestring or null requiredThe current log file, null before the first one is written.
db_bytesinteger requiredSize of the database (with its write-ahead log) in bytes.
dashboard_sessionsinteger requiredDashboard sign-ins that have not expired.
streamsobject requiredOpen price streams and their caps.
Fields
sseinteger requiredOpen SSE streams.
wsinteger requiredOpen WebSockets.
maxintegerCap on open streams in total.
max_per_keyintegerCap on open streams per key or dashboard session.
accountsarray of DiagnosticsAccount requiredEvery account, with its connection status.
DiagnosticsAccount fields
idstring requiredAccount id.
enabledboolean requiredFalse for an account that is turned off.
connectedboolean requiredWhether the session to the broker is up right now.
sinceinteger or null requiredUnix seconds (UTC) when the current connection came up. null while disconnected.
reconnectsinteger requiredAutomatic reconnects since the server started.
ping_msnumber or null requiredLast heartbeat round trip in milliseconds. null before the first one.
server_buildinteger or null requiredMT5 build the broker's server reported. null before the first login.
last_errorstring or null requiredWhy the last connection attempt failed or the connection dropped. null while connected.
subscribedinteger requiredNumber of symbols with a live price subscription.
login_rejectedboolean requiredTrue 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.
retry_atinteger or null requiredUnix seconds (UTC) of the next connection attempt while disconnected, else null.
session_runningboolean requiredWhether the account's connection loop is running.
ticks_seeninteger requiredPrice ticks received since the session started.
last_tick_at_msinteger or null requiredWhen the last tick arrived, unix milliseconds (UTC). null before the first.
last_frame_at_msinteger or null requiredWhen 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.
streamsinteger requiredOpen streams (SSE and WebSocket) on this account.
ticks_coalescedinteger requiredTicks dropped for slow stream readers (they got the latest tick per symbol instead).
undecodedinteger requiredFrames from this account the client could not decode.
undecodedobject requiredFrames the client could not decode.
Fields
totalinteger requiredFrames the client could not decode since the server started.
filestring requiredWhere kept frames are appended: <data>/captures/undecoded.jsonl.
by_commandarray of UndecodedCount requiredOne counter per (account, command, kind), most recent first.
UndecodedCount fields
accountstring requiredAccount id.
commandinteger requiredProtocol command id.
kindstring requiredframe: 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.
framebodyunknown_pushextracontextstring requiredWhere it happened.
countinteger requiredHow many such frames arrived (kept or only counted).
first_atinteger requiredFirst one, unix seconds (UTC).
last_atinteger requiredLatest one, unix seconds (UTC).
last_errorstring requiredWhat the decoder said about the latest one.
recentarray of object requiredThe last 20 kept frames, newest first, without their bytes (GET /api/v1/diagnostics/undecoded has them). Frames kept before a restart are among them: the newest are read back from the file at start.
Fields
idinteger requiredFrame number since the server started.
timeinteger requiredWhen it arrived, unix seconds (UTC).
accountstring requiredAccount id.
kindstring requiredframe: 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.
framebodyunknown_pushextracommandinteger requiredProtocol command id.
codeinteger requiredThe frame's result code.
contextstring requiredWhere it happened, for example tick push or account reply.
errorstring requiredWhat the decoder said.
server_buildinteger requiredThe broker's MT5 build at the time.
leninteger requiredBody length in bytes.
problemsarray of LogLine requiredThe last 100 warnings and errors from the log, newest first.
LogLine fields
timeinteger requiredUnix seconds (UTC).
levelstring requiredLog level.
warnerrortargetstring requiredThe module that logged it.
messagestring requiredThe log message.
crashesarray of CrashReport requiredCrash reports in <data>/crashes, newest first.
CrashReport fields
namestring requiredFile name in <data>/crashes; fetch the text with GET /api/v1/diagnostics/crashes/{name}.
timeinteger requiredWhen it was written, unix seconds (UTC).
sizeinteger requiredSize in bytes.
summarystring requiredThe panic message, or the first line of an unclean-exit report.
unclean_exit_reportstring or null requirednull, 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.
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/diagnostics" \
-H "Authorization: Bearer $TERMLESS_KEY"import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.get(f"{base}/diagnostics", headers=auth)
r.raise_for_status()
print(r.json())import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
req = urllib.request.Request(f"{base}/diagnostics", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
print(json.load(r))const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/diagnostics`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.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
}List undecoded frames
/api/v1/diagnostics/undecodedFrames the client could not decode, newest first, with their bytes as hex. The server keeps the last 200 in memory, and at start reads the newest kept ones back from captures/undecoded.jsonl (its last 4 MB), so a restart does not empty this list. Without bodies=1, body_hex is cut to its first 128 bytes and body_preview: true says so (a page of 200 frames is then under 100 KB); with it, up to 64 KB a frame.
Query parameters
accountstringOnly this account's frames.
limitinteger default50min 1, max 200Most frames to return, at most 200.
bodiesboolean defaultfalse1 (or true) returns each frame's whole body_hex, up to 64 KB a frame.
Headers
X-Request-IdstringYour 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 Frames.
A JSON array of UndecodedFrame objects.
idinteger requiredFrame number since the server started.
timeinteger requiredWhen it arrived, unix seconds (UTC).
accountstring requiredAccount id.
logininteger requiredMT5 login of the account.
kindstring requiredframe: 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.
framebodyunknown_pushextracommandinteger requiredProtocol command id.
codeinteger requiredThe frame's result code.
contextstring requiredWhere it happened, for example tick push or account reply.
errorstring requiredWhat the decoder said.
server_buildinteger requiredThe broker's MT5 build at the time.
leninteger requiredBody length in bytes.
body_hexstring requiredThe body as hex. Without
bodies=1it is cut to the first 128 bytes andbody_previewis true; with it, up to 64 KB a frame.truncatedboolean requiredTrue when the kept body itself holds only the first 64 KB.
body_previewbooleanPresent and true when body_hex was cut to its first 128 bytes; ask with
bodies=1for the whole body.
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/diagnostics/undecoded?account=pepperstone-12345678&limit=50" \
-H "Authorization: Bearer $TERMLESS_KEY"import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.get(f"{base}/diagnostics/undecoded", headers=auth, params={"account": "pepperstone-12345678", "limit": 50})
r.raise_for_status()
print(r.json())import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
req = urllib.request.Request(f"{base}/diagnostics/undecoded?account=pepperstone-12345678&limit=50", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
print(json.load(r))const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/diagnostics/undecoded?account=pepperstone-12345678&limit=50`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.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,
"body_preview": true
}
]Run the doctor
/api/v1/diagnostics/doctorThe same checks as termlessd doctor on the command line, against the running server: the data folder (exists, writable, owner-only), master.key, the database (integrity check and row counts), the listen address, each account's gateway (DNS, TLS, the web terminal's build, and the session's live state), the clock against the first connected broker (warns past 5 s) and free disk. Each warn or fail says what to do.
Headers
X-Request-IdstringYour 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 report.
A DoctorReport object.
verdictstring requiredok when every check passed, warnings when something should be looked at, problems when something is broken.
okwarningsproblemsversionstring requiredServer version.
data_dirstring requiredThe data folder that was checked.
checksarray of DoctorCheck requiredOne row per check, in the order they ran.
DoctorCheck fields
namestring requiredWhat was checked: data folder, master.key, setup-token, database, listen, gateway (one per account; gateways when there are none), clock, disk.
levelstring requiredok, warn or fail.
okwarnfaildetailstring requiredWhat was found, in a sentence.
fixstringWhat to do. Only on a warn or fail.
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/diagnostics/doctor" \
-H "Authorization: Bearer $TERMLESS_KEY"import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.get(f"{base}/diagnostics/doctor", headers=auth)
r.raise_for_status()
print(r.json())import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
req = urllib.request.Request(f"{base}/diagnostics/doctor", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
print(json.load(r))const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/diagnostics/doctor`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.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"
}
]
}Get a crash report
/api/v1/diagnostics/crashes/{name}The text of one crash report: a panic, or an exit without a clean shutdown, with the last log lines before it.
Path parameters
namestring requiredCrash report file name, from the crashes list in GET /api/v1/diagnostics.
Headers
X-Request-IdstringYour 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 report, as text/plain.
Plain text (text/plain).
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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 -s "$TERMLESS_URL/api/v1/diagnostics/crashes/20261002T231405Z-panic.txt" \
-H "Authorization: Bearer $TERMLESS_KEY"import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.get(f"{base}/diagnostics/crashes/20261002T231405Z-panic.txt", headers=auth)
r.raise_for_status()
print(r.text)import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
req = urllib.request.Request(f"{base}/diagnostics/crashes/20261002T231405Z-panic.txt", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
print(r.read().decode())const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/diagnostics/crashes/20261002T231405Z-panic.txt`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.text());Get the log
/api/v1/diagnostics/logsThe end of the current log file (<data>/logs/termlessd.<date>.log, one per day). 404 before the first one is written.
Query parameters
linesinteger default200min 1, max 5000How many lines from the end, at most 5000.
Headers
X-Request-IdstringYour 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 last lines, as text/plain.
Plain text (text/plain).
Errors
- 400
bad_requestA 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
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis 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. - 500
internalThe server hit an internal error. Any route can answer it; a panic also saves a crash report (see Diagnostics).
curl -s "$TERMLESS_URL/api/v1/diagnostics/logs?lines=200" \
-H "Authorization: Bearer $TERMLESS_KEY"import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.get(f"{base}/diagnostics/logs", headers=auth, params={"lines": 200})
r.raise_for_status()
print(r.text)import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
req = urllib.request.Request(f"{base}/diagnostics/logs?lines=200", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
print(r.read().decode())const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/diagnostics/logs?lines=200`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.text());