Endpoint
current as the {id} to connect to the single running agent:
No authentication is required. The WebSocket endpoint is open on localhost for the single-user setup, consistent with the REST API. If you ever proxy the backend beyond localhost, add authentication at that boundary.
Message format
Every message is a JSON object with anevent field that identifies its type, plus a ts field (ISO 8601 UTC timestamp) present on all events. Parse the event field first and branch on its value to handle each message type.
Events
snapshot
Emitted every ~15–30 minutes when the agent records a new equity snapshot. Use this to drive equity charts and drawdown indicators.
Current portfolio equity in USDT.
The agent’s current execution phase.
Drawdown from the all-time equity peak, expressed as a decimal fraction (e.g.
0.012 = 1.2%).Fraction of the daily drawdown budget consumed so far today (e.g.
0.031 = 3.1%).trade
Emitted immediately after every trade execution — paper or live. The journal_ref field links to the corresponding journal entry.
Trading pair in
BASE/QUOTE format.Direction of the trade.
Trade size in USDT (quote currency).
Executed fill price from the TWAK-verified quote.
Realised PnL in USDT.
null for opening trades where the position is not yet closed.Total fees paid in USDT, including swap fee and gas.
ID of the corresponding journal entry. Use this to correlate trade events with journal detail.
journal_entry
Emitted for every event the agent records in its append-only journal — trade executions, skips, risk decisions, configuration changes, and lifecycle transitions.
High-level event classifier (e.g.
EXECUTED, SKIPPED, RISK_VETO, STATUS_CHANGE).Array of searchable tags for filtering and grouping journal entries in your UI.
Human-readable description of the event, including the agent’s reasoning where applicable.
risk_veto
Emitted when the Risk Engine’s policy layer blocks a trade before it reaches the executor. The trade is not executed; the veto is also recorded in the journal.
The risk rule that fired (e.g.
daily_drawdown, max_drawdown, streak_limit).Plain-language explanation of why the rule blocked this specific trade.
Reference ID of the blocked order.
status_change
Emitted whenever the agent transitions between lifecycle states. Use this to update status indicators and unlock or disable UI actions.
The previous agent status.
The new agent status.
twak_block
Emitted in live mode when the TWAK signing layer (the physics layer) rejects a transaction after the policy layer has already approved it. This is distinct from a risk_veto — the trade passed risk checks but was refused at the signing boundary.
The TWAK policy rule that refused the transaction (e.g.
per_trade_cap, daily_cap, allowlist).Plain-language explanation of the refusal.
Reference ID of the blocked order.
quote_rejected
Emitted when the QuoteVerifier discards a price quote before the trade reaches the risk engine. The skip is journaled automatically — no action is required on your part.
The trading pair for which the quote was rejected.
The category of rejection. Maps to the
QUOTE_DIVERGENCE, QUOTE_STALE, and INSUFFICIENT_LIQUIDITY error codes respectively.Quantified explanation of the rejection — useful for tuning quote thresholds.
promotion / demotion
Emitted in live mode when the agent is promoted to LIVE or demoted back to PAPER. Both events are also echoed as a status_change event on the same connection.
(
promotion only) The on-chain transaction hash of the agent’s first live trade.(
demotion only) The risk rule that triggered the demotion.(
demotion only) Whether the breach was against the daily drawdown limit or the maximum drawdown limit.(
demotion only) ISO 8601 timestamp until which promotion is locked, or null if no time-lock applies.Connection example
Connect to the stream and handle each event type in aswitch statement. Unrecognised event types should be silently ignored to stay forward-compatible as new events are added.
If WebSocket is unavailable in your environment — for example, in a server-side polling script — you can poll the REST endpoints on a 30-second interval as a fallback. Use
GET /agents/{id}/equity, /trades, /journal, and /risk/blocks to approximate the same data. Event ordering and latency will differ from the push stream.Event reference summary
| Event | Tier | When emitted |
|---|---|---|
snapshot | Core | Every ~15–30 min on a new equity snapshot |
trade | Core | On every trade execution (paper or live) |
journal_entry | Core | On every journal write |
risk_veto | Core | When the policy layer blocks a trade |
status_change | Core | On every agent status transition |
quote_rejected | Core | When a price quote is discarded |
twak_block | Live only | When the TWAK signing layer rejects a transaction |
promotion | Live only | When the agent transitions to LIVE |
demotion | Live only | When the agent is demoted from LIVE |