# Health, setup and session Whether the server is up and how well it has been (GET /status, GET /metrics for Prometheus), first-run setup, and the dashboard's own sign-in. Apps and agents need /health, /me, /status and each account's /ready. ### Check health `GET /api/v1/health` Scope: No key needed. Answers without a key, so it works for uptime monitors. `degraded` means an enabled account is not connected. `version` and `accounts` are filled in only for a signed-in caller or a valid key (`accounts` then only with the accounts it may see); anyone else gets `version: null` and no accounts. **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**: Server state. A Health object. | Field | Type | Description | |---|---|---| | `status` | string | ok when every enabled account is connected, degraded when an enabled account is not, setup before the admin password exists. (required; one of ok, degraded, setup) | | `version` | string or null | Server version, for a signed-in caller or a valid key; null for anyone else (the exact version tells an attacker which fixes are missing). (required) | | `uptime_s` | integer | Seconds since the server started. (required) | | `accounts` | array of object | Empty unless the caller is signed in or sends a valid key; then the accounts it may see. (required; object: id, label, enabled, connected, ping_ms, reconnects) | Example: ```json { "status": "ok", "version": "0.6.2", "uptime_s": 86412, "accounts": [ { "id": "pepperstone-12345678", "label": "Pepperstone demo", "enabled": true, "connected": true, "ping_ms": 14.2, "reconnects": 0 } ] } ``` **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). **curl** ```sh curl -s "$TERMLESS_URL/api/v1/health" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" r = requests.get(f"{base}/health") r.raise_for_status() print(r.json()) ``` ### Check whether setup is needed `GET /api/v1/setup` Scope: No key needed. True on a new install until the admin password is set. **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**: Setup state. A SetupState object. | Field | Type | Description | |---|---|---| | `needs_setup` | boolean | True until the admin password has been set. (required) | Example: ```json { "needs_setup": false } ``` **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). **curl** ```sh curl -s "$TERMLESS_URL/api/v1/setup" ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" r = requests.get(f"{base}/setup") r.raise_for_status() print(r.json()) ``` ### Finish first-run setup `POST /api/v1/setup` Scope: No key needed. Sets the admin password using the one-time setup token the server printed to its log (also in `/setup-token`), and signs you in with a session cookie. The token stops anyone who reaches the port first from claiming the install. Setting `TERMLESS_ADMIN_PASSWORD` in the environment skips this step; `termlessd passwd` resets the password. Wrong tokens count toward the 5-try lockout. **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** (SetupRequest) | Field | Type | Description | |---|---|---| | `token` | string | The one-time setup token from the server log or /setup-token. (required) | | `password` | string | The new admin password: 15 to 200 characters with a lowercase letter, a capital, a digit and a symbol (anything but a letter or a digit counts as a symbol). (required) | Example: ```json { "token": "4f1c9e0b7a2d5e8c3b6a9d0e", "password": "A long passphrase, 2 commas" } ``` **Response 200**: Done, and signed in (Set-Cookie). A Ok object. | Field | Type | Description | |---|---|---| | `ok` | boolean | Always true. (required) | Example: ```json { "ok": true } ``` **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. - `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/setup" \ -c cookies.txt \ -H "Content-Type: application/json" \ -d '{"token": "4f1c9e0b7a2d5e8c3b6a9d0e", "password": "A long passphrase, 2 commas"}' ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" r = requests.post(f"{base}/setup", json={ "token": "4f1c9e0b7a2d5e8c3b6a9d0e", "password": "A long passphrase, 2 commas" }) r.raise_for_status() print(r.json()) ``` ### Sign in to the dashboard `POST /api/v1/session` Scope: No key needed. Checks the admin password and sets the HttpOnly, SameSite=Strict cookie `termless_session` (30 days) that acts like an admin key. A cookie-authenticated write or WebSocket whose `Origin` is another site is refused (403). Five wrong tries from one IP lock that IP out for 15 minutes. **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** (SessionRequest) | Field | Type | Description | |---|---|---| | `password` | string | The admin password. (required) | Example: ```json { "password": "a long passphrase" } ``` **Response 200**: Signed in (Set-Cookie). A Ok object. | Field | Type | Description | |---|---|---| | `ok` | boolean | Always true. (required) | Example: ```json { "ok": true } ``` **Errors** - `401 unauthorized`: No valid API key or session. - `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/session" \ -c cookies.txt \ -H "Content-Type: application/json" \ -d '{"password": "a long passphrase"}' ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" r = requests.post(f"{base}/session", json={ "password": "a long passphrase" }) r.raise_for_status() print(r.json()) ``` ### Sign out `DELETE /api/v1/session` Scope: No key needed. Clears the session cookie. **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**: Signed out. A Ok object. | Field | Type | Description | |---|---|---| | `ok` | boolean | Always true. (required) | Example: ```json { "ok": true } ``` **curl** ```sh curl -s -X DELETE "$TERMLESS_URL/api/v1/session" \ -b cookies.txt ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" s = requests.Session() # signed in earlier with POST /api/v1/session r = s.delete(f"{base}/session") r.raise_for_status() print(r.json()) ``` ### Who am I `GET /api/v1/me` Scope: Any key. Tells you what the key (or session) you sent may do. A good first call for an agent: it shows the scope and the accounts in reach. **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 caller. A Me object. | Field | Type | Description | |---|---|---| | `kind` | string | admin for the dashboard session, key for an API key. (required; one of admin, key) | | `name` | string | admin, or the key's name. (required) | | `scopes` | array of string | What this caller may do. (required; one of read, trade, admin) | | `accounts` | array or null | Account ids this caller may use. null means every account. (required) | Example: ```json { "kind": "key", "name": "EA bridge (gold)", "scopes": [ "trade" ], "accounts": [ "pepperstone-12345678" ] } ``` **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. - `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/me" \ -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}/me", headers=auth) r.raise_for_status() print(r.json()) ``` ### Change the admin password `PUT /api/v1/admin/password` Scope: admin (dashboard cookie only). Dashboard session only; an API key gets 403. Signs out every other dashboard session. A wrong `current` is 400 (not 401, so the dashboard stays signed in) and counts toward the 5-try lockout. **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** (PasswordChange) | Field | Type | Description | |---|---|---| | `current` | string | The admin password in use now. A wrong one is 400, not 401, so the dashboard stays signed in. (required) | | `new` | string | The new admin password: 15 to 200 characters with a lowercase letter, a capital, a digit and a symbol (anything but a letter or a digit counts as a symbol). (required) | Example: ```json { "current": "A long passphrase, 2 commas", "new": "An even longer passphrase, 3 commas" } ``` **Response 200**: Changed. A Ok object. | Field | Type | Description | |---|---|---| | `ok` | boolean | Always true. (required) | Example: ```json { "ok": true } ``` **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 -X PUT "$TERMLESS_URL/api/v1/admin/password" \ -b cookies.txt \ -H "Content-Type: application/json" \ -d '{"current": "A long passphrase, 2 commas", "new": "An even longer passphrase, 3 commas"}' ``` **Python (requests)** ```python import os import requests base = os.environ["TERMLESS_URL"] + "/api/v1" s = requests.Session() # signed in earlier with POST /api/v1/session r = s.put(f"{base}/admin/password", json={ "current": "A long passphrase, 2 commas", "new": "An even longer passphrase, 3 commas" }) r.raise_for_status() print(r.json()) ``` ### Get the status report `GET /api/v1/status` Scope: read. Whether Termless and each broker link are working, and how well over time: a verdict and one plain sentence at the top; the process (version, uptime, memory, restarts and unclean exits in 30 days); and per account its verdict, uptime over 1 hour, 24 hours, 7 days and 30 days (time before the account was added and time it was turned off are left out; Termless's own downtime counts as down), reconnects, the longest outage, a 30-day strip of UTC days, the outages with a cause (broker maintenance, broker unreachable, broker unresponsive, Termless restart, network, login refused), the tick rate and each watched symbol's last tick, order round-trip latency and counts over 24 hours, and protocol drift (the build, whether it is verified, undecoded frames). A key limited to some accounts sees only those; an admin key, a key without an account list and the dashboard see all. Read from the connection history and the audit trail. **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 report. A StatusReport object. | Field | Type | Description | |---|---|---| | `verdict` | string | down when every enabled account is down (and at least one is enabled), degraded when any account is down or degraded or Termless wrote a crash report in the last 24 hours, healthy otherwise (also with no accounts). (required; one of healthy, degraded, down) | | `summary` | string | One plain sentence for people. (required) | | `checked_at` | integer | When this was worked out, unix milliseconds (UTC). (required) | | `termless` | object | (required; object: version, started_at, uptime_s, rss_kb, rss_peak_kb, restarts_30d, unclean_exits_30d, last_start_at, crash_reports_24h, errors_1h, trail_rows_dropped) | | `accounts` | array of AccountHealth | The accounts the caller may use. (required; see AccountHealth) | Example: ```json { "verdict": "healthy", "summary": "All good: 1 account connected, 99.86% up over the last 24 hours.", "checked_at": 1792300000123, "termless": { "version": "0.6.2", "started_at": 1792200000, "uptime_s": 100000, "rss_kb": 16384, "rss_peak_kb": 20480, "restarts_30d": 3, "unclean_exits_30d": 0, "last_start_at": 1792200000000, "crash_reports_24h": 0, "errors_1h": 0, "trail_rows_dropped": 0 }, "accounts": [ { "id": "pepperstone-12345678", "label": "Pepperstone demo", "server": "Pepperstone-Demo", "broker": "Pepperstone", "enabled": true, "verdict": "healthy", "summary": "Connected for 2 h 46 min, ping 12 ms.", "connected": true, "since": 1792290000, "ping_ms": 12.4, "tracked_since": 1790000000000, "uptime": { "1h": { "percent": 100.0, "up_ms": 3600000, "down_ms": 0, "measured_ms": 3600000, "reconnects": 0, "outages": 0, "longest_outage_ms": 0 }, "24h": { "percent": 99.86, "up_ms": 86280000, "down_ms": 120000, "measured_ms": 86400000, "reconnects": 1, "outages": 1, "longest_outage_ms": 120000 }, "7d": { "percent": 99.97, "up_ms": 604620000, "down_ms": 180000, "measured_ms": 604800000, "reconnects": 3, "outages": 2, "longest_outage_ms": 120000 }, "30d": { "percent": 99.95, "up_ms": 2590710000, "down_ms": 1290000, "measured_ms": 2592000000, "reconnects": 9, "outages": 6, "longest_outage_ms": 600000 } }, "days": [ { "date": "2026-09-19", "from": 1789776000000, "percent": null, "up_ms": 0, "down_ms": 0, "measured_ms": 0, "outages": 0 }, { "date": "2026-10-18", "from": 1792281600000, "percent": 99.35, "up_ms": 18280000, "down_ms": 120000, "measured_ms": 18400000, "outages": 1 } ], "outages": [ { "from": 1792291200000, "to": 1792291320000, "duration_ms": 120000, "ongoing": false, "start_estimated": false, "detected_at": null, "cause": "broker_maintenance", "message": "Pepperstone restarted its servers; back after 2 min.", "detail": "login refused (code 2) for 1 min after the link dropped" }, { "from": 1792199996000, "to": 1792200001200, "duration_ms": 5200, "ongoing": false, "start_estimated": false, "detected_at": null, "cause": "termless_restart", "message": "Termless restarted; back after 5 s.", "detail": "termlessd stopped (upgrade or restart)" } ], "ticks": { "per_min": 384.0, "seen": 1234567, "last_tick_age_ms": 400, "feed_quiet": false, "symbols": [ { "symbol": "EURUSD", "last_tick_age_ms": 400, "market_open": true, "fresh": true }, { "symbol": "XAUUSD", "last_tick_age_ms": 812, "market_open": true, "fresh": true } ] }, "orders": { "window_h": 24, "count": 12, "done": 11, "rejected": 1, "timeout": 0, "failed": 0, "latency_ms": { "p50": 41, "p95": 120, "max": 133 } }, "protocol": { "build": 6090, "build_verified": true, "undecoded_1h": 0, "undecoded_24h": 0, "undecoded_by_command": [] }, "pings_missed": 2, "trades_unconfirmed": 0, "trades_late": 0, "command_waits": 1840, "command_wait_ms": 3120 } ] } ``` **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. - `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/status" \ -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}/status", headers=auth) r.raise_for_status() print(r.json()) ``` ### Get Prometheus metrics `GET /api/v1/metrics` Scope: read. The same numbers in the Prometheus text format 0.0.4 (`text/plain; version=0.0.4`), for a scraper: termless_up, termless_build_info{version}, termless_uptime_seconds, termless_process_resident_memory_bytes (Linux), and per account (label `account`): enabled, connected, ready{kind=read|trade}, ping_seconds, reconnects_total, ticks_total, last_tick_age_seconds, uptime_ratio{window=1h|24h|7d|30d}, undecoded_frames_total, server_build, build_verified, orders_total{result=done|rejected|timeout|failed} and order_latency_seconds_sum/_count (since this start). The accounts follow the same rule as GET /status. Send the key as `Authorization: Bearer` (Prometheus: `authorization: {credentials: ...}`). **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 metrics, text/plain; version=0.0.4. Example: ```text # HELP termless_up Always 1 while termlessd answers. # TYPE termless_up gauge termless_up 1 # HELP termless_build_info The termlessd version. # TYPE termless_build_info gauge termless_build_info{version="0.6.2"} 1 # HELP termless_uptime_seconds Seconds since termlessd started. # TYPE termless_uptime_seconds gauge termless_uptime_seconds 100000 # HELP termless_crash_reports_24h Crash reports (panics termlessd survived, unclean exits) written in the last 24 hours. # TYPE termless_crash_reports_24h gauge termless_crash_reports_24h 0 # HELP termless_errors_logged_1h Error lines in termlessd's log in the last hour. # TYPE termless_errors_logged_1h gauge termless_errors_logged_1h 0 # HELP termless_account_connected 1 while the account's link to the broker is up. # TYPE termless_account_connected gauge termless_account_connected{account="pepperstone-12345678"} 1 # HELP termless_account_ready The ready check without asked symbols, 1 or 0. # TYPE termless_account_ready gauge termless_account_ready{account="pepperstone-12345678",kind="read"} 1 termless_account_ready{account="pepperstone-12345678",kind="trade"} 1 # HELP termless_account_uptime_ratio Share of the window the account was connected (as /status). # TYPE termless_account_uptime_ratio gauge termless_account_uptime_ratio{account="pepperstone-12345678",window="24h"} 0.9986 # HELP termless_account_orders_total Trade requests since this start, by result. # TYPE termless_account_orders_total counter termless_account_orders_total{account="pepperstone-12345678",result="done"} 11 ``` **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. - `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/metrics" \ -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}/metrics", headers=auth) r.raise_for_status() print(r.text) ```