Guides
Activity and trails
The audit trail of every write and security event, each account's connection history, the equity curve, who is connected and what they receive right now, and the request id that ties a bot's log, the server log and the trail together.
Termless keeps a record of what happened so that nobody has to reconstruct it from memory: every trade call with the broker's answer, every change to accounts and keys, every sign-in and wrong password, every time an account connected or lost its link, and the account's money once a minute. Rows are written off the request path (a batch writer), so recording never slows a trade, and pruned hourly so the database stays small.
| Route | Scope | Kept | |
|---|---|---|---|
| Audit trail | GET /api/v1/audit | admin | 90 days or 200,000 rows |
| Connection history | GET /api/v1/accounts/{id}/events | read | 90 days or 50,000 rows |
| Equity curve | GET /api/v1/accounts/{id}/equity | read | 7 days |
| Who is connected | GET /api/v1/connections, GET /api/v1/keys/{id}/traffic | admin | in memory, since the server started |
Request ids tie it together#
Every response carries an X-Request-Id header. Send your own (1 to 64 characters of A-Z a-z 0-9 - _ . :) and it is kept; otherwise the server makes one of 16 hex characters. The same id is on every log line the request wrote (req{id=...}) and on every audit row it caused. So when a bot says "I placed order 42 at 09:14 and got a timeout", its request id finds the audit row (what the broker actually answered, in how many milliseconds) and the server log lines (what the session was doing) in one search.
The audit trail#
GET /api/v1/audit (admin) returns rows newest first. Filter with account, kind and actor; page with before = the id of the last row you have and limit (default 100, at most 1,000). Every filter given must match; an empty one is ignored.
curl -s "$TERMLESS_URL/api/v1/audit?kind=trade&account=pepperstone-12345678&limit=20" \
-H "Authorization: Bearer $TERMLESS_ADMIN_KEY"Two more filters find a row without paging through the trail:
request_id=bot-20261003-0042: the rows one request caused, an exact match (indexed, so instant at any size).q=xauusd: a case-insensitive piece of text anywhere in the row'srequest_id,actor,account,route,summaryorresult(up to 200 characters;%and_are plain characters). It reads from the newest row down and stops atlimitmatches, so a common word answers at once and a rare one reads the whole trail: 40 to 60 ms at the 200,000-row cap on a laptop.beforepages a search like any other list.
curl -s "$TERMLESS_URL/api/v1/audit?q=not%20enough%20money&limit=50" -H "Authorization: Bearer $TERMLESS_ADMIN_KEY"
curl -s "$TERMLESS_URL/api/v1/audit?request_id=bot-20261003-0042" -H "Authorization: Bearer $TERMLESS_ADMIN_KEY"[{"id": 4821, "at": 1790981179473, "kind": "trade", "actor": "key_3f9a1c07", "actor_kind": "key",
"account": "pepperstone-12345678", "route": "market order", "summary": "market buy 0.10 XAUUSD",
"request": "{\"symbol\":\"XAUUSD\",\"volume\":0.1,\"type\":0,\"price\":0.0,\"sl\":2380.0,\"tp\":2420.0,\"order\":0,\"position\":0,\"comment\":\"breakout\"}",
"status": 200, "retcode": 10009, "result": "Request completed order 51830031 deal 81200131",
"latency_ms": 212, "request_id": "bot-20261003-0042", "ip": null}]| Field | Meaning |
|---|---|
at | When, unix milliseconds UTC. |
kind | trade, account, key, signin, auth_failed, lockout, password, setup, server_check, server_trust, start. |
actor, actor_kind | Who: a key id (key), admin (the dashboard), the client IP before sign-in (anonymous), or termlessd itself (system). |
account | The account concerned, when one was. |
route | What was done. For a trade: market order, pending order, order change, order cancel, SL/TP change, close, partial close, order_send. For an account: add, update, delete. For a key: create, delete. |
summary | One line a person can read. |
request | For a trade: the request sent to the broker, in short JSON (cut to 400 characters). |
status | The HTTP status the caller got. |
retcode, result, latency_ms | For a trade: the broker's return code, its answer in words with the order and deal tickets (or the error when it did not answer), and the broker round trip. |
request_id | The X-Request-Id of the request that caused the row. |
ip | The client IP, on sign-ins, wrong passwords and lockouts. |
A trade is one row per broker call, with status 200, 422 or 502 to 504 (a 503 whose result says it "was not sent" waited its whole turn and never reached the broker). An idempotent replay writes no row: the broker was not asked, so there is nothing new to record. Wrong passwords and setup tokens are auth_failed with the IP; the fifth in 15 minutes adds a lockout. server_check records every POST /servers/check, including the failures the route itself only reports as one generic 502; server_trust every certificate key an admin pinned or unpinned. A trade's summary names the side (market buy 0.10 XAUUSD, buy limit 0.10 EURUSD at 1.07800, close 0.10 of buy #51830031 XAUUSD), so a search for buy or sell finds it. start marks each server start with the version and the account count.
def my_trades_since(ts_ms):
"""Every trade call on the account since ts_ms, oldest first, by paging the trail."""
rows, before = [], None
while True:
page = requests.get(f"{base}/audit", headers=admin,
params={"kind": "trade", "account": acc, "limit": 1000, **({"before": before} if before else {})}).json()
rows += [r for r in page if r["at"] >= ts_ms]
if not page or page[-1]["at"] < ts_ms:
return rows[::-1]
before = page[-1]["id"]The trail wants an admin key. A bot with a trade key does not read it; the person running the bot does, and the bot's own X-Request-Ids are the join.
Connection history#
GET /api/v1/accounts/{id}/events (read) is the account's link to the broker over time, newest first, paged like the audit trail (before = an id, limit at most 1,000).
[{"id": 310, "at": 1790968298412, "account": "pepperstone-12345678", "kind": "connected", "reason": "build 6090", "duration_ms": 1840},
{"id": 309, "at": 1790968296572, "account": "pepperstone-12345678", "kind": "lost", "reason": "connection lost: 2 pings unanswered in a row (the broker keeps the socket open but has stopped answering)", "duration_ms": 73284110}]kind | reason | duration_ms |
|---|---|---|
started | ||
connected (the first login), reconnected (every later one) | build N, the broker's build | how long the account had been disconnected |
lost | why the link was lost: connection lost: ... with the cause (2 pings unanswered in a row ..., command 5 was never answered ..., the broker closed the connection) | how long it had been connected |
connect_failed | the error | |
login_rejected | the broker's refusal; the account retries after 10, 20, 30 and 60 s when the login worked within the last hour, then every minute for the restart code (2) until an hour after the loss, else every 5 minutes | |
stopped | how long it had been connected |
Read it when a stream went quiet, when reconnects in the account's status climbed, or when a trade answered 503 and you want to know how long the gap was. GET /api/v1/status turns the same history into uptime over 1 hour to 30 days and a list of outages with their causes (health checks).
Equity curve#
GET /api/v1/accounts/{id}/equity?hours=24 (read; 1 to 168 hours) returns balance, equity, margin and profit about once a minute while the account was connected, oldest first, the first sample right after each connect, and gaps: the periods inside the window when the account was not connected, as {from, to} in unix milliseconds UTC, oldest first, with to: null while it still is not. They come from the connection history above, so nothing extra is stored.
{"account": "pepperstone-12345678", "hours": 24, "every_s": 60,
"samples": [{"at": 1790977560000, "balance": 10412.58, "equity": 10641.2, "margin": 878.93, "profit": 228.62},
{"at": 1790977620000, "balance": 10412.58, "equity": 10650.69, "margin": 878.93, "profit": 238.11}],
"gaps": [{"from": 1790968296572, "to": 1790968298412}]}Draw a break over each gap instead of a straight line from the last sample before it to the first after: the account's money was not being watched then, and a trade may have happened in between. A gap opens at a lost or stopped event and closes at the next connected or reconnected; a server that was killed rather than stopped leaves no stopped, so that gap opens at the account's last sample before the restart. The route reads only the database, so an account that is turned off or disconnected still shows its stored curve, with an open gap at the end.
It is a week of context for a chart or a drawdown check, not a tick record: for the account's money as it changes, ask a stream for events=account.
Who is connected#
The trails above say what happened. GET /api/v1/connections (admin) says what is going out right now and to whom: when you hand an app a key (a trade journal, a bot, an agent), this is where you see what it receives, how often and how live.
curl -s "$TERMLESS_URL/api/v1/connections" -H "Authorization: Bearer $TERMLESS_ADMIN_KEY"{"time_ms": 1790981179473, "since_ms": 1790968290000,
"streams": [{"id": 12, "kind": "sse", "who": {"kind": "key", "key_id": "key_3f9a1c07", "name": "Price board"},
"ip": "203.0.113.7", "user_agent": "python-requests/2.32", "account": "pepperstone-12345678",
"symbols": ["XAUUSD", "EURUSD"], "events": ["ticks", "trades", "account"], "batch_ms": 0,
"opened_at": 1790977520000, "sent": {"messages": 52811, "bytes": 6203417, "ticks": 52102, "events": 708},
"last_sent_at": 1790981179401, "rate_per_s": 14.6, "coalesced": 0}],
"keys": [{"key_id": "key_3f9a1c07", "name": "Price board", "scope": "read", "accounts": ["pepperstone-12345678"],
"streams_open": 1, "stream_bytes": 6203417, "requests_1h": 120, "requests_24h": 2211, "errors_1h": 0,
"bytes_out_1h": 48210, "last_request_at": 1790981175002, "last_ip": "203.0.113.7",
"top_routes_1h": [{"route": "GET /api/v1/accounts/{id}/deals", "count": 60}, {"route": "GET /api/v1/accounts/{id}/positions", "count": 60}]}],
"dashboard": {"sessions_active": 1, "streams_open": 0, "stream_bytes": 0, "requests_1h": 340, "requests_24h": 1902,
"errors_1h": 0, "bytes_out_1h": 912044, "last_request_at": 1790981179470}}- Streams: every open stream, the key (or the dashboard) that opened it, from which address and program, for which account, symbols and events, and what it has sent so far: messages (ticks, events, the rest), bytes, the last one's time, and the rate over the last 10 seconds. A stream leaves the list when it closes.
- Keys: every key, with zeros until it is used: streams open, requests in the last hour and day, errors, bytes, its last request and address, and its busiest routes.
- Dashboard: the dashboard's own sessions, streams and requests, counted apart from the keys.
GET /api/v1/keys/{id}/traffic?limit=100 is one key's last requests (up to 500 are kept), newest first, each with its time, route, path (with the query; key= is removed), status, time taken, bytes and address, plus its open streams. It is the place to see what an app actually asks for, and when.
All of this is in memory: it starts empty when termlessd starts (since_ms), and nothing of it is written to disk. A key's secret never appears in it.
From the box#
The trails live in termless.db beside the accounts and keys; sqlite3 reads them directly, and the request id in a row finds the matching log lines:
sqlite3 /var/lib/termless/termless.db \
'select at, kind, actor, route, summary, status, retcode, latency_ms, request_id from audit order by id desc limit 50'
grep 'id=bot-20261003-0042' /var/lib/termless/logs/termlessd.2026-10-03.logTERMLESS_ADMIN_KEY in the examples above is a key with the admin scope; the trail is for the person running the server, not for the bot.