TermlessDocs

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

GET/api/v1/diagnostics

One 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.

Scope admin

Headers

  • X-Request-Id string

    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 Diagnostics.

A Diagnostics object.

  • version string required

    Server version.

  • target string required

    The platform the binary was built for, for example x86_64-unknown-linux-gnu.

  • pid integer required

    Process id.

  • started_at integer required

    When the server started, unix seconds (UTC).

  • uptime_s integer required

    Seconds since the server started.

  • process object required

    Read from /proc; every field is null off Linux.

    Fields
    • rss_kb integer or null required

      Resident memory in KB.

    • rss_peak_kb integer or null required

      The most resident memory since the start, in KB (VmHWM).

    • threads integer or null required

      Threads.

    • open_files integer or null required

      Open file descriptors.

  • data_dir string required

    The data folder.

  • log_file string or null required

    The current log file, null before the first one is written.

  • db_bytes integer required

    Size of the database (with its write-ahead log) in bytes.

  • dashboard_sessions integer required

    Dashboard sign-ins that have not expired.

  • streams object required

    Open price streams and their caps.

    Fields
    • sse integer required

      Open SSE streams.

    • ws integer required

      Open WebSockets.

    • max integer

      Cap on open streams in total.

    • max_per_key integer

      Cap on open streams per key or dashboard session.

  • accounts array of DiagnosticsAccount required

    Every account, with its connection status.

    DiagnosticsAccount fields
    • id string required

      Account id.

    • enabled boolean required

      False for an account that is turned off.

    • connected boolean required

      Whether the session to the broker is up right now.

    • since integer or null required

      Unix seconds (UTC) when the current connection came up. null while disconnected.

    • reconnects integer required

      Automatic reconnects since the server started.

    • ping_ms number or null required

      Last heartbeat round trip in milliseconds. null before the first one.

    • server_build integer or null required

      MT5 build the broker's server reported. null before the first login.

    • last_error string or null required

      Why the last connection attempt failed or the connection dropped. null while connected.

    • subscribed integer required

      Number of symbols with a live price subscription.

    • login_rejected boolean required

      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.

    • retry_at integer or null required

      Unix seconds (UTC) of the next connection attempt while disconnected, else null.

    • session_running boolean required

      Whether the account's connection loop is running.

    • ticks_seen integer required

      Price ticks received since the session started.

    • last_tick_at_ms integer or null required

      When the last tick arrived, unix milliseconds (UTC). null before the first.

    • last_frame_at_ms integer or null required

      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.

    • streams integer required

      Open streams (SSE and WebSocket) on this account.

    • ticks_coalesced integer required

      Ticks dropped for slow stream readers (they got the latest tick per symbol instead).

    • undecoded integer required

      Frames from this account the client could not decode.

  • undecoded object required

    Frames the client could not decode.

    Fields
    • total integer required

      Frames the client could not decode since the server started.

    • file string required

      Where kept frames are appended: <data>/captures/undecoded.jsonl.

    • by_command array of UndecodedCount required

      One counter per (account, command, kind), most recent first.

      UndecodedCount fields
      • account string required

        Account id.

      • command integer required

        Protocol command id.

      • kind string required

        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.

        framebodyunknown_pushextra
      • context string required

        Where it happened.

      • count integer required

        How many such frames arrived (kept or only counted).

      • first_at integer required

        First one, unix seconds (UTC).

      • last_at integer required

        Latest one, unix seconds (UTC).

      • last_error string required

        What the decoder said about the latest one.

    • recent array of object required

      The 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
      • id integer required

        Frame number since the server started.

      • time integer required

        When it arrived, unix seconds (UTC).

      • account string required

        Account id.

      • kind string required

        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.

        framebodyunknown_pushextra
      • command integer required

        Protocol command id.

      • code integer required

        The frame's result code.

      • context string required

        Where it happened, for example tick push or account reply.

      • error string required

        What the decoder said.

      • server_build integer required

        The broker's MT5 build at the time.

      • len integer required

        Body length in bytes.

  • problems array of LogLine required

    The last 100 warnings and errors from the log, newest first.

    LogLine fields
    • time integer required

      Unix seconds (UTC).

    • level string required

      Log level.

      warnerror
    • target string required

      The module that logged it.

    • message string required

      The log message.

  • crashes array of CrashReport required

    Crash reports in <data>/crashes, newest first.

    CrashReport fields
    • name string required

      File name in <data>/crashes; fetch the text with GET /api/v1/diagnostics/crashes/{name}.

    • time integer required

      When it was written, unix seconds (UTC).

    • size integer required

      Size in bytes.

    • summary string required

      The panic message, or the first line of an unclean-exit report.

  • unclean_exit_report string or null required

    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.

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
curl -s "$TERMLESS_URL/api/v1/diagnostics" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
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())
Python, stdlib
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))
JavaScript
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());
Response 200
{
  "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

GET/api/v1/diagnostics/undecoded

Frames 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.

Scope admin

Query parameters

  • account string

    Only this account's frames.

  • limit integer default 50 min 1, max 200

    Most frames to return, at most 200.

  • bodies boolean default false

    1 (or true) returns each frame's whole body_hex, up to 64 KB a frame.

Headers

  • X-Request-Id string

    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 Frames.

A JSON array of UndecodedFrame objects.

  • id integer required

    Frame number since the server started.

  • time integer required

    When it arrived, unix seconds (UTC).

  • account string required

    Account id.

  • login integer required

    MT5 login of the account.

  • kind string required

    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.

    framebodyunknown_pushextra
  • command integer required

    Protocol command id.

  • code integer required

    The frame's result code.

  • context string required

    Where it happened, for example tick push or account reply.

  • error string required

    What the decoder said.

  • server_build integer required

    The broker's MT5 build at the time.

  • len integer required

    Body length in bytes.

  • body_hex string required

    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.

  • truncated boolean required

    True when the kept body itself holds only the first 64 KB.

  • body_preview boolean

    Present and true when body_hex was cut to its first 128 bytes; ask with bodies=1 for the whole body.

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
curl -s "$TERMLESS_URL/api/v1/diagnostics/undecoded?account=pepperstone-12345678&limit=50" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
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())
Python, stdlib
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))
JavaScript
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());
Response 200
[
  {
    "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

GET/api/v1/diagnostics/doctor

The 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.

Scope admin

Headers

  • X-Request-Id string

    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 report.

A DoctorReport object.

  • verdict string required

    ok when every check passed, warnings when something should be looked at, problems when something is broken.

    okwarningsproblems
  • version string required

    Server version.

  • data_dir string required

    The data folder that was checked.

  • checks array of DoctorCheck required

    One row per check, in the order they ran.

    DoctorCheck fields
    • name string required

      What was checked: data folder, master.key, setup-token, database, listen, gateway (one per account; gateways when there are none), clock, disk.

    • level string required

      ok, warn or fail.

      okwarnfail
    • detail string required

      What was found, in a sentence.

    • fix string

      What to do. Only on a warn or fail.

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
curl -s "$TERMLESS_URL/api/v1/diagnostics/doctor" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
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())
Python, stdlib
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))
JavaScript
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());
Response 200
{
  "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

GET/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.

Scope admin

Path parameters

  • name string required

    Crash report file name, from the crashes list in GET /api/v1/diagnostics.

Headers

  • X-Request-Id string

    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 report, as text/plain.

Plain text (text/plain).

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
curl -s "$TERMLESS_URL/api/v1/diagnostics/crashes/20261002T231405Z-panic.txt" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
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)
Python, stdlib
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())
JavaScript
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

GET/api/v1/diagnostics/logs

The end of the current log file (<data>/logs/termlessd.<date>.log, one per day). 404 before the first one is written.

Scope admin

Query parameters

  • lines integer default 200 min 1, max 5000

    How many lines from the end, at most 5000.

Headers

  • X-Request-Id string

    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 last lines, as text/plain.

Plain text (text/plain).

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.
  • 500 internal The server hit an internal error. Any route can answer it; a panic also saves a crash report (see Diagnostics).
curl
curl -s "$TERMLESS_URL/api/v1/diagnostics/logs?lines=200" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
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)
Python, stdlib
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())
JavaScript
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());