REST and WebSocket API Reference¶
Status: Normative. This appendix is the single source of truth for the
pm-api-gwyREST contract as exposed under/api/v1. For an operational, tutorial-style guide see API Gateway (REST/WebSocket). The key words MUST, MUST NOT, SHOULD, and MAY are used per RFC 2119.
Scope & conventions¶
This appendix documents the client-visible REST surface of the API gateway.
It covers request shapes, replies, query parameters, auth rules, and the
stable error codes returned by the gateway. WebSocket streams live under
/api/v1/ws/ (private, market-data, admin/monitor, admin/sim) and are
specified normatively in the WebSocket API Reference; they
are not repeated here.
All paths are rooted at /api/v1. Admin paths name their target as a path
segment — /admin/symbols/{symbol}/..., /admin/gateways/{gateway_id}/...,
/admin/market/... — and a body, where one is accepted, carries only
optional parameters.
Endpoint index¶
Bootstrap¶
| Endpoint | Access | Purpose |
|---|---|---|
| GET /api/v1/bootstrap/trader | Any valid key | One-request startup payload for TRADER / MARKET_MAKER / ADMIN |
| GET /api/v1/bootstrap/mm | MARKET_MAKER key | One-request startup payload for MARKET_MAKER (adds quote state) |
| GET /api/v1/bootstrap/admin | Admin role | One-request startup payload for ADMIN |
Trading REST¶
| Endpoint | Access | Purpose |
|---|---|---|
| POST /api/v1/orders | Trading key | Submit one order for the caller's gateway |
| DELETE /api/v1/orders/{order_id} | Trading key | Cancel one live order |
| PATCH /api/v1/orders/{order_id} | Trading key | Amend price and/or quantity on one live order |
| POST /api/v1/orders/{order_id}/replace | Trading key | Cancel then replace one live order |
| GET /api/v1/orders | Trading key | Return the caller gateway's live order cache |
| GET /api/v1/orders/{order_id} | Trading key | Return one cached order |
| POST /api/v1/oco | Trading key | Submit an OCO pair |
| DELETE /api/v1/oco/{oco_id} | Trading key | Cancel an OCO pair |
| POST /api/v1/combos | Trading key | Submit a combo order |
| DELETE /api/v1/combos/{combo_id} | Trading key | Cancel a combo order |
| POST /api/v1/quotes | Trading key | Submit a two-sided market-maker quote |
| DELETE /api/v1/quotes/{symbol} | Trading key | Cancel the active quote for one symbol |
| POST /api/v1/mass-cancel | Trading key | Cancel all resting exposure for the caller or one symbol |
| GET /api/v1/symbols | Trading key | Return instrument metadata |
| GET /api/v1/news | Authenticated key | Return the latest market-sim headlines and sector map |
| GET /api/v1/companies/{symbol} | Authenticated key | Return one company profile from the company database |
| GET /api/v1/session | Authenticated key | Return the session phase, exchange timezone and trading date |
| GET /api/v1/halts | Authenticated key | Return currently-halted symbols |
| GET /api/v1/status | Trading key | Return the caller's gateway id and role |
| GET /api/v1/healthz | Public | Liveness probe |
| GET /api/v1/quotes | Trading key | Return the caller's active market-maker quotes |
| GET /api/v1/quotes/legs | Trading key | Return current quote-leg state |
| GET /api/v1/positions | Trading key | Return current net positions |
Reference data¶
| Endpoint | Access | Purpose |
|---|---|---|
| GET /api/v1/reference | Authenticated key | Return the full reference bundle |
| GET /api/v1/reference/config-version | Authenticated key | Return the reference bundle version |
| GET /api/v1/reference/symbols | Authenticated key | Return per-symbol tick and risk metadata |
| GET /api/v1/reference/risk | Authenticated key | Return risk-band definitions |
| GET /api/v1/reference/indexes | Authenticated key | Return configured exchange index definitions |
| GET /api/v1/reference/schedule | Authenticated key | Return session schedule metadata |
Market data¶
| Endpoint | Access | Purpose |
|---|---|---|
| GET /api/v1/book | Authenticated key | Return best bid, best ask and last price for every symbol |
| GET /api/v1/book/{symbol} | Authenticated key | Return one symbol's book levels, last trade and recent prints |
History¶
| Endpoint | Access | Purpose |
|---|---|---|
| GET /api/v1/history/orders | Trading key | Return the caller gateway's order lifecycle events |
| GET /api/v1/history/orders/{order_id} | Trading key | Return the full lifecycle of one order |
| GET /api/v1/history/fills | Trading key | Return fill events |
| GET /api/v1/history/trades | Authenticated key | Return public trade tape rows |
| GET /api/v1/history/daily | Authenticated key | Return daily OHLCV rows |
| GET /api/v1/history/price-snapshots | Authenticated key | Return intraday price snapshots |
| GET /api/v1/history/index-daily | Authenticated key | Return daily index OHLC rows |
| GET /api/v1/history/index-snapshots | Authenticated key | Return intraday index snapshots |
| GET /api/v1/history/indexes | Authenticated key | List index ids with recorded data |
| GET /api/v1/history/index-events | Authenticated key | Return index structural and audit events |
Clearing¶
| Endpoint | Access | Purpose |
|---|---|---|
| GET /api/v1/clearing/summary | Admin role | Venue clearing overview: totals, freshness, feed gaps, last EOD run |
| GET /api/v1/clearing/participants | Admin role | P&L and position counts per participant gateway |
| GET /api/v1/clearing/participants/{gateway_id} | Admin role, or the gateway itself | One gateway's totals, positions and the routes for its other views |
| GET /api/v1/clearing/positions | Admin role, or own gateway | Current positions at their marks |
| GET /api/v1/clearing/position-replay | Admin role, or own gateway | One position replayed fill by fill through one day, checked against the ledger |
| GET /api/v1/clearing/exposure | Admin role, or own gateway | Net/gross notional and P&L per position |
| GET /api/v1/clearing/trades | Admin role, or own gateway | Retained raw executions, keyset-paginated |
| GET /api/v1/clearing/daily | Admin role, or own gateway | Daily activity, realized P&L and end-of-day position |
| GET /api/v1/clearing/close-snapshots | Admin role, or own gateway | Position and cumulative P&L at each session close |
| GET /api/v1/clearing/symbols | Admin role | Activity, aggregate net position and its long and short sides per symbol |
| GET /api/v1/clearing/flows | Admin role | Who bought from whom on one trading day, per gateway pair |
| GET /api/v1/clearing/netting | Admin role, or own gateway | One trading day's trades against the net amount each gateway is left with |
| GET /api/v1/clearing/session-events | Admin role | PHASE, EOD and GAP events clearing observed |
| GET /api/v1/clearing/gateway-sessions | Admin role, or own gateway | Gateway connect/disconnect history |
| GET /api/v1/clearing/reconciliation | Admin role | Raw trades against daily rows, in an explicit date range |
| GET /api/v1/clearing/health | Admin role | Database facts and process liveness, separately |
| GET /api/v1/clearing/settlements | Admin role, or own gateway | pm-eod daily settlement amounts (minor units) and runs |
| GET /api/v1/clearing/balances | Admin role, or own gateway | Opening balance plus settlements: the derived balance |
Admin REST¶
| Endpoint | Access | Purpose |
|---|---|---|
| POST /api/v1/admin/session/transition | Admin role | Request a session-phase transition |
| GET /api/v1/admin/sim | Admin role | Market simulator state and its true fair values |
| GET /api/v1/admin/gateways | Admin role | List configured gateways and live connection state |
| POST /api/v1/admin/gateways/{gateway_id}/disconnect | Admin role | Forcibly disconnect one gateway |
| POST /api/v1/admin/symbols/{symbol}/halt | Admin role | Halt one symbol through the circuit breaker |
| POST /api/v1/admin/symbols/{symbol}/resume | Admin role | Resume one halted symbol |
| GET /api/v1/admin/risk/state | Admin role | Return live per-symbol risk state |
| GET /api/v1/admin/orders | Admin role | Return the cross-gateway active-order table |
| GET /api/v1/admin/orders/{order_id}/audit | Admin role | Return the full cross-gateway lifecycle of one order |
| GET /api/v1/admin/gateways/{gateway_id}/positions | Admin role | Return net position and average cost for any one gateway |
| POST /api/v1/admin/symbols/{symbol}/cancel-orders | Admin role | Cancel all resting exposure on one symbol |
| POST /api/v1/admin/gateways/{gateway_id}/kill-switch | Admin role | Cancel all resting exposure for one gateway |
| POST /api/v1/admin/market/halt | Admin role | Halt every symbol and cancel every quote |
| POST /api/v1/admin/market/resume | Admin role | Resume every symbol halted by a market halt |
| GET /api/v1/admin/market/volume | Admin role | Today's traded volume per symbol and in total |
| POST /api/v1/admin/symbols/{symbol}/reopen | Admin role | Uncross and reopen a symbol, optionally at an operator price |
| GET /api/v1/admin/symbols/{symbol}/orders | Admin role | Every resting order on a symbol, optionally one price level |
| GET /api/v1/admin/gateways/{gateway_id}/orders | Admin role | One gateway's orders as the engine holds them |
| DELETE /api/v1/admin/gateways/{gateway_id}/quotes/{symbol} | Admin role | Withdraw one gateway's quote on one symbol |
| POST /api/v1/admin/market/kill-switch | Admin role | Cancel all resting exposure across every gateway and symbol |
| POST /api/v1/admin/indexes/{index_id}/rebalance | Admin role | Rebalance one configured index |
| POST /api/v1/admin/reference/reload | Admin role | Request a reference-data reload (currently refused by the engine) |
Audit (ADMIN)¶
| Endpoint | Access | Purpose |
|---|---|---|
| GET /api/v1/audit/collections | Admin role | The configured audit evidence collections, by id |
| POST /api/v1/audit/snapshots | Admin role | Pin a collection as an evidence snapshot |
| GET /api/v1/audit/snapshots/{snapshot_id} | Admin role | A snapshot's descriptor and capabilities |
| GET /api/v1/audit/snapshots/{snapshot_id}/coverage | Admin role | Integrity & Coverage: the four kinds of confidence, separately |
| GET /api/v1/audit/events | Admin role | A snapshot's records in canonical order |
| GET /api/v1/audit/stories/{entity_kind}/{entity_id} | Admin role | The replay story of one order, trade, quote, OCO, combo or command |
| GET /api/v1/audit/findings | Admin role | The replay's findings, by lane |
| GET /api/v1/audit/market/{symbol}/heatmap | Admin role | Displayed depth per price level and time bin, from recorded book observations |
| GET /api/v1/audit/market/{symbol}/lifelines | Admin role | Each order's life on the book, from admission to its end |
| GET /api/v1/audit/market/{symbol}/quality | Admin role | Time-weighted spread, depth and presence; effective and realized spread, price impact |
| GET /api/v1/audit/findings/{pos} | Admin role | One finding's evidence card: claim, limits, counter-explanations, rule, sources |
| GET /api/v1/audit/market/{symbol}/book | Admin role | The recorded book at a cursor time |
| GET /api/v1/audit/activity | Admin role | Orders, executions, cancellations and refused entries per time bin |
| GET /api/v1/audit/flows | Admin role | Seller -> buyer flows per gateway pair and symbol, per bucket |
| GET /api/v1/audit/frames | Admin role | Playback frames of one illustration |
| GET /api/v1/audit/context | Admin role | Simulator context: news and true-value jumps, with provenance and clock offset |
| GET /api/v1/audit/summary | Admin role | Scope, activity, findings per lane and evidence health |
| GET /api/v1/audit/participants | Admin role | Descriptive metrics per gateway |
| GET /api/v1/audit/participants/{gateway} | Admin role | One gateway, per symbol |
| GET /api/v1/audit/symbols | Admin role | Descriptive metrics per symbol |
| GET /api/v1/audit/episodes | Admin role | The replay's episodes, filtered, with censoring and the raw scope |
| GET /api/v1/audit/episodes/{episode_id} | Admin role | One episode, its findings and its records |
| GET /api/v1/audit/graph | Admin role | The bounded causal neighbourhood of one episode |
| POST /api/v1/audit/analyze | Admin role | Pivot: an enumerated measure by up to two dimensions |
| POST /api/v1/audit/jobs | Admin role | Queue derivative work: prepare, verify or forensics_import |
| GET /api/v1/audit/jobs/{job_id} | Admin role | A job's state, stage, progress and heartbeat |
| POST /api/v1/audit/jobs/{job_id}/cancel | Admin role | Cancel derivative work (never an order) |
| GET /api/v1/audit/exports/{job_id} | Admin role | Download an export's archive |
| GET /api/v1/audit/results/{job_id} | Admin role | A succeeded job's typed result |
| POST /api/v1/audit/dispositions | Admin role | Set a review disposition |
| GET /api/v1/audit/dispositions | Admin role | Review dispositions |
| POST /api/v1/audit/cases | Admin role | Open a review case |
| GET /api/v1/audit/cases | Admin role | Review cases |
| GET /api/v1/audit/cases/{case_id} | Admin role | A review case |
| PATCH /api/v1/audit/cases/{case_id} | Admin role | Change a review case |
| POST /api/v1/audit/cases/{case_id}/items | Admin role | Add an item to a case |
| DELETE /api/v1/audit/cases/{case_id}/items/{item_id} | Admin role | Remove an item from a case |
| POST /api/v1/audit/cases/{case_id}/notes | Admin role | Add a note to a case |
| GET /api/v1/audit/review-log | Admin role | The review change log |
| GET /api/v1/audit/behaviour | Admin role | The behavioural lane |
Auth and roles¶
- Trading and admin REST requests use
Authorization: Bearer <api_key>. gateway_id: nullcredentials are read-only and may access public data — reference data, public history,GET /session,GET /halts, news and company profiles — but no gateway-scoped or admin endpoint.- ADMIN endpoints require a credential whose resolved engine gateway role is
ADMIN. /clearingendpoints are scoped by role:ADMINreads the venue, aTRADERorMARKET_MAKERonly its own gateway (naming another is403 SCOPE_DENIED), a read-only credential nothing. See Clearing.
Key types and provisioning¶
This appendix uses two access labels in endpoint tables:
Authenticated key(also calledAuthentication key): any configured API key accepted bypm-api-gwy. This includes both read-only and trading keys.Trading key: an authenticated key whose configuredgateway_idis notnull. This key is bound to one engine gateway identity and can submit and manage that gateway's orders.
How keys are specified:
- Keys are configured by operators in
engine_config.yamlunderapi_gateways.<INSTANCE>.credentials. - Each credential entry has
api_keyandgateway_id. gateway_id: nullcreates a read-only authenticated key.gateway_id: <GW_ID>creates a trading-capable key for that gateway.
Example:
api_gateways:
default:
credentials:
- api_key: key-trader-demo
gateway_id: TRADER01
description: Trading client for TRADER01
- api_key: key-dashboard-demo
gateway_id: null
description: Read-only dashboard client
How to get a key:
- API keys are provisioned out-of-band by the venue/operator team.
- There is no REST endpoint in
pm-api-gwyto self-issue or rotate keys. - After updating credentials, restart/redeploy the API gateway instance so the new key set is loaded.
Common error codes¶
Every non-2xx reply carries one of these error.code values. reject_code
is the engine vocabulary shared with ALF; it is UNKNOWN where no engine
reject applies.
Every endpoint can answer AUTH, ENGINE_AUTH, ENGINE_UNAVAILABLE (the
engine could not be reached to confirm a trading key) and INTERNAL_ERROR.
Each endpoint's Errors table lists exactly the other codes it can return;
the OpenAPI document lists all of them per operation.
| Code | HTTP status | reject_code |
Meaning |
|---|---|---|---|
VALIDATION |
400 |
MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
A body field, query parameter or history filter (date, cursor, event_type) failed validation; field names it. A price off the instrument's tick grid carries TICK_VIOLATION |
AUTH |
401 |
AUTH_REQUIRED |
Missing, malformed or unknown API key. The reply carries WWW-Authenticate: Bearer |
ENGINE_AUTH |
403 |
AUTH_FAILED |
The engine refused the key's gateway identity |
READ_ONLY |
403 |
ROLE_DENIED |
Read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
ROLE_DENIED |
The key's gateway lacks the role the endpoint needs (ADMIN, or MARKET_MAKER for /bootstrap/mm) |
SCOPE_DENIED |
403 |
ROLE_DENIED |
A TRADER or MARKET_MAKER key asked a /clearing route for another gateway's data (or the EXCHANGE account); only ADMIN reads beyond its own gateway |
NOT_FOUND |
404 |
UNKNOWN |
No such path |
UNKNOWN_ORDER |
404 |
UNKNOWN |
Order id unknown to the gateway (GET /orders/{id}) or absent from the audit trail (GET /admin/orders/{id}) |
UNKNOWN_COMPANY |
404 |
UNKNOWN |
No company profile for the symbol |
UNKNOWN_GATEWAY |
404 |
UNKNOWN |
No participant has the gateway id (GET /admin/gateways/{id}/positions, /orders) |
UNKNOWN_SYMBOL |
404 |
UNKNOWN |
The symbol is not in the venue's reference data (GET /book/{symbol}) |
UNKNOWN_COLLECTION |
404 |
UNKNOWN |
No audit evidence collection with this id is configured |
UNKNOWN_SNAPSHOT |
404 |
UNKNOWN |
No audit evidence snapshot has this id |
UNKNOWN_ENTITY |
404 |
UNKNOWN |
The snapshot holds no episode for this order, trade, quote, OCO, combo or command id, or no record of this symbol |
METHOD_NOT_ALLOWED |
405 |
UNKNOWN |
The path exists but not for this method; the reply carries Allow |
TRANSITION_REJECTED |
409 |
UNKNOWN |
The engine refused the session transition |
RELOAD_REJECTED |
409 |
UNKNOWN |
The engine refused the reference reload |
HALT_REJECTED |
409 |
UNKNOWN |
The engine refused the halt (for example Unknown symbol: XYZ) |
RESUME_REJECTED |
409 |
UNKNOWN |
The engine refused the resume (for example TSLA is not halted) |
KILL_SWITCH_REJECTED |
409 |
UNKNOWN |
The engine refused a symbol, gateway or global kill switch |
REOPEN_REJECTED |
409 |
UNKNOWN |
The engine refused a symbol reopen (force-uncross), for example the symbol is not halted |
DISCONNECT_REJECTED |
409 |
UNKNOWN |
The engine refused to disconnect a gateway: not configured, not connected, or the caller's own |
QUERY_REJECTED |
409 |
UNKNOWN |
The engine refused an admin query, for example Unknown symbol: XYZ |
REBALANCE_REJECTED |
409 |
UNKNOWN |
pm-index refused the rebalance |
REPLACE_REJECTED |
409 |
engine's | The engine refused replace's cancel (for example the order already filled); nothing was sent |
IDEMPOTENCY_KEY_REUSED |
409 |
UNKNOWN |
The Idempotency-Key was already used for a different request |
NOT_PREPARED |
409 |
UNKNOWN |
The snapshot's read models are not built yet; job_id names the prepare job building them |
GENERATION_EXPIRED |
409 |
UNKNOWN |
A cursor's read-model generation was replaced and removed; generation names it. Start the listing again |
UNKNOWN_JOB |
404 |
UNKNOWN |
No audit job has this id |
JOB_NOT_SUCCEEDED |
409 |
UNKNOWN |
The job has no result: it has not finished or did not succeed; state and reason say how |
UNKNOWN_CASE |
404 |
UNKNOWN |
No review case has this id |
UNKNOWN_ITEM |
404 |
UNKNOWN |
The case holds no item with this id (or it was already removed) |
CASE_CLOSED |
409 |
UNKNOWN |
The case is closed: reopen it (PATCH status: open) to change it |
AMBIGUOUS_ID |
409 |
UNKNOWN |
An id prefix matches more than one entity; matches lists them (at most 20, more when there are others), repeat with more of the id |
AMBIGUOUS_RUN |
409 |
UNKNOWN |
An audit id appears in more than one engine run of the snapshot; runs lists them, repeat with run_id |
CAPABILITY_UNAVAILABLE |
409 |
UNKNOWN |
The snapshot's evidence cannot support the analysis; reason is a stable code. Never an empty result |
RATE_LIMIT |
429 |
RATE_LIMITED |
Per-key write limit exceeded |
INTERNAL_ERROR |
500 |
INTERNAL_ERROR |
A gateway bug; the message carries no internals |
INDEX_ERROR |
502 |
UNKNOWN |
pm-index answered with an error |
ENGINE_TIMEOUT |
503 |
INTERNAL_ERROR |
No engine reply in time to a read, or to replace's cancel. Transient — retry. A write whose ack is late is not an error: 202 with ack_timeout: true |
ENGINE_UNAVAILABLE |
503 |
INTERNAL_ERROR |
The command could not be handed to the engine (down or backpressured). Transient — retry |
SYMBOLS_NOT_READY |
503 |
SYMBOL_NOT_READY |
Order entry before the symbol's tick precision reached the gateway. Transient — retry |
INDEX_TIMEOUT |
503 |
UNKNOWN |
No pm-index reply in time |
STATS_DB |
503 |
UNKNOWN |
The pm-stats database is not present |
AUDIT_INDEX_UNAVAILABLE |
503 |
UNKNOWN |
The pm-audit index is not built or not running |
AUDIT_SOURCE_UNAVAILABLE |
503 |
UNKNOWN |
Audit evidence is missing, or a retained file changed after the snapshot pinned it; reason is SOURCE_MISSING or SOURCE_CHANGED. Never an empty result |
COMPANY_DB_UNAVAILABLE |
503 |
UNKNOWN |
The company database is missing or unreadable |
NEWS_DB_UNAVAILABLE |
503 |
UNKNOWN |
pm-market-sim's news history cannot be read |
CLEARING_DB |
503 |
UNKNOWN |
The pm-clearing ledger is missing, locked or unreadable. Never answered as an empty ledger |
EOD_DB |
503 |
UNKNOWN |
The pm-eod ledger is unreadable, or its roster is malformed. A missing ledger (pm-eod has not run yet) is eod_db_available: false, and a day without settlement an empty list, not this |
For an engine refusal (409), message is the engine's own reason. New codes
may be added within v1; clients must treat an unknown code by its HTTP status.
Swagger/OpenAPI documentation¶
The API gateway supports live API documentation through FastAPI:
- OpenAPI schema:
/openapi.json - Swagger UI:
/docs
The same document is committed in the repository as
spec/rest/openapi.json,
so a client can be generated or reviewed without a running gateway. It does not
depend on deployment configuration: every v1 gateway publishes exactly that
document, and CI fails if the code and the committed copy disagree.
These endpoints are available when swagger_enabled: true in the
api_gateways configuration. When disabled, /docs and /openapi.json are
not exposed.
Common reply shapes¶
200 OKmeans the response body carries the outcome: every read, and every command the gateway waited for (admin commands,POST /mass-cancel, and any order, cancel, amend, replace, OCO, combo or quote write with?wait=ackwhose verdict arrived in time).202 Acceptedmeans the request was handed on and the outcome follows on a WebSocket: those writes without?wait=ack(or with it, when the verdict was late:ack_timeout: true).- Pagination endpoints return
count,has_more, andnext_cursorwhere applicable;afteris the opaque cursor input.
Response contract¶
Every reply has a declared schema in the OpenAPI document (/openapi.json),
and the gateway validates what it sends against it. The schemas of replies the
gateway forwards from the engine are generated from the same message specs
as the engine's own bindings, so the REST shape and the bus payload cannot
drift apart (see Messages).
- Omitted versus null. A field the schema marks optional is omitted when
it does not apply (an ordinary order has no
oco_group_id); a field it marks required is always present, and isnullonly where the schema allows it. - Collections are
{ "<plural>": [...], "count": n }; a paginated one addshas_moreandnext_cursor. Envelopes do not nest: a bootstrap'sordersis the list itself, not{ "orders": [...] }. - Status fields are closed enums declared in the schema.
- Time.
*_nsfields are epoch nanoseconds;tsfields and every historyfrom/toare ISO-8601 (or aYYYY-MM-DDdate);dateis a trading day in the exchange timezone (session_timezoneinGET /session). - Prices are JSON numbers in display units (
187.25), always on the symbol's tick grid. A field named*_tickscarries the same price as an integer tick count; it supplements a display field and never replaces one. - Extension. New optional fields, new endpoints and new enum members may be added within v1. A client must ignore fields and enum values it does not recognise.
Canonical error envelope¶
All non-2xx replies MUST use this JSON envelope shape — including an unknown
path (404 NOT_FOUND), a wrong method (405 METHOD_NOT_ALLOWED) and an
unhandled gateway error (500 INTERNAL_ERROR).
| Field | Type | Required | Description |
|---|---|---|---|
error |
Object |
yes | Top-level error container |
error.code |
String |
yes | Stable machine-readable code (for example VALIDATION) |
error.message |
String |
yes | Human-readable summary |
error.field |
String |
no | Field name when validation pinpoints one input field |
error.reject_code |
String |
no | Canonical order-rejection class for ALF/REST comparison, when applicable |
error.client_tag |
String |
no | Echo of the submitted order correlation tag, when available |
error.request_tag |
String |
no | Echo of the amend/cancel request tag, when available |
Canonical example:
{
"error": {
"code": "VALIDATION",
"reject_code": "INVALID_VALUE",
"message": "Input should be greater than 0",
"field": "quantity",
"client_tag": "desk1-aapl-00042"
}
}
Pagination contract¶
Endpoints that support pagination use keyset cursoring with these rules:
- Clients MAY pass
after(opaque cursor from a previous response). - Replies include
count,has_moreandnext_cursor. next_cursoris a string when another page exists andnullon the last.- Clients fetch the next page by passing
after=<next_cursor>unchanged. - Ordering is deterministic and backend-defined per endpoint; cursors are valid only for the same endpoint and compatible filter set.
- A malformed, stale, or cross-endpoint cursor returns
400 VALIDATIONwithfield: "after".
Write outcomes and safe retries¶
Every write that creates or changes orders (POST /orders, DELETE and
PATCH /orders/{order_id}, POST /orders/{order_id}/replace, POST and
DELETE on /oco, /combos and /quotes) answers in one of three ways, so a
client can always tell whether something reached the engine:
| Reply | Sent to the engine? | What to do |
|---|---|---|
200 OK, status: "ACKED" |
Yes, and the verdict is in the body (accepted, reject_code, event) |
Done |
202 Accepted, ack_timeout: false |
Yes; no ?wait=ack, the verdict follows on the private WebSocket |
Watch the WebSocket |
202 Accepted, ack_timeout: true |
Yes; ?wait=ack gave up waiting (wait_ack_sec) |
Watch the WebSocket or GET /orders; do not resubmit |
4xx or 5xx |
No (503 ENGINE_UNAVAILABLE, 400, 429, ...) |
Fix and retry |
The reply always carries the id to cancel or track (order_id, oco_id,
combo_id, symbol), including after an ack timeout. Two exceptions, both on
replace, which only sends the replacement once the original's cancel is
confirmed: a refused cancel is 409 REPLACE_REJECTED (nothing sent), and a
cancel whose outcome did not arrive is 503 ENGINE_TIMEOUT (no replacement
sent; check the original with GET /orders/{order_id}).
Idempotency-Key. A client whose connection dropped cannot know which of
those replies it missed. The submit writes (POST /orders, /oco, /combos,
/quotes and /orders/{order_id}/replace) accept an optional
Idempotency-Key header (1–255 characters; a UUID per logical request):
- The first request with a key runs. A later one with the same key, from the
same gateway, is not sent again: it gets the first reply (same status, same
body) with the header
Idempotent-Replayed: true. A duplicate that arrives while the first is still waiting for its ack waits for it too. - The same key on a different request (another path, query or body) is
409 IDEMPOTENCY_KEY_REUSED. - A request that failed before the engine was reached is not remembered, so it may be retried with the same key.
replaceis two writes — cancel, then submit the replacement — and the key records which of them succeeded. If the cancel is confirmed but the replacement fails, a retry with the same key resumes at the replacement: it does not cancel again, and it does not leave you with no order. A retry after both steps succeeded replays the first reply as usual.- Keys are kept for
order_retention_secand are lost when the gateway restarts.
client_tag is unrelated: it is an opaque, non-unique label (below).
Order correlation with client_tag¶
Order submit supports client_tag as an optional client-supplied correlation
tag.
- Scope: the tag is client-scoped and opaque.
- Behavior: the gateway and engine do not enforce uniqueness.
- Lifetime: when supplied, the tag is echoed on order lifecycle events and on
cached order reads so clients can map exchange-assigned
order_idvalues back to their own submissions. That includes events the client did not ask for — an unsolicited cancel, an expiry at the close — which are precisely the ones it cannot correlate any other way.
Unsolicited cancels and cancel_reason¶
An order.cancelled event does not always answer a DELETE. When the exchange
cancels an order itself, request_tag is absent and cancel_reason says why:
cancel_reason |
Meaning |
|---|---|
SELF_MATCH_PREVENTED |
The order would have traded against another order from the same gateway |
INSUFFICIENT_LIQUIDITY |
A MARKET or IOC order exhausted the book; this cancels the remainder, which never rests |
KILL_SWITCH |
The gateway's kill switch (KILL / KILL_ACK) cancelled this resting order |
CIRCUIT_BREAKER_HALT |
A circuit-breaker halt cancelled this resting order |
GATEWAY_DISCONNECT |
The owning gateway disconnected and its disconnect_behaviour cancelled this order |
ADMIN_CANCEL_SYMBOL |
An operator-issued admin cancel for the symbol cancelled this order |
QUOTE_REPLACED |
A market-maker's new quote replaced this quote leg |
QUOTE_LEG_FILLED |
The sibling leg of a two-sided quote filled, cancelling this leg |
Both fields are omitted rather than null when they do not apply, so
request_tag absent with cancel_reason also absent means the exchange
cancelled the order for a cause not yet classified under this vocabulary.
cancel_reason is a separate vocabulary from reject_code: a cancel is not
a rejection. New members may be added; existing members are never removed or
renamed. Clients must ignore values they do not recognise. See
Messages — order.cancelled.{gateway_id}
for the same enum at the engine-message level.
Category examples¶
The examples below are normative shape examples for each category. Values are illustrative.
Trading example (POST /api/v1/orders)¶
Minimal request:
Full request:
{
"symbol": "AAPL",
"side": "BUY",
"order_type": "LIMIT",
"quantity": 100,
"price": 187.25,
"tif": "DAY",
"smp_action": "CANCEL_AGGRESSOR",
"client_tag": "desk1-aapl-00042"
}
Minimal response:
{
"order_id": "867b2a3876a765ce6bdd66d02283fb22",
"client_tag": null,
"status": "PENDING",
"accepted": null,
"reject_code": null,
"event": null,
"ack_timeout": false
}
Full response (with ?wait=ack; event is the engine's acknowledgement,
shortened here):
{
"order_id": "7acb7b382343ca92003b35e49bffebf9",
"client_tag": "desk1-aapl-00042",
"status": "ACKED",
"accepted": true,
"reject_code": null,
"event": {
"order_id": "7acb7b382343ca92003b35e49bffebf9",
"accepted": true,
"reason": "",
"symbol": "AAPL",
"side": "BUY",
"order_type": "LIMIT",
"tif": "DAY",
"qty": 100,
"price": 187.25,
"price_ticks": 18725,
"smp_action": "CANCEL_AGGRESSOR",
"client_tag": "desk1-aapl-00042",
"tick_decimals": 2,
"ts_ns": 1795131572219373690
},
"ack_timeout": false
}
Reference data example (GET /api/v1/reference)¶
Minimal response (no symbols, no risk levels, sessions disabled):
{
"symbols": [],
"risk": {"levels": []},
"indexes": [],
"schedule": {"sessions_enabled": false, "country": "SE", "schedule": null},
"config_version": "sha256:..."
}
Full response (one entry of each list shown; the weekday blocks tue to
sun, holidays and most upcoming_holidays left out):
{
"symbols": [
{
"symbol": "AAL",
"tick_decimals": 2,
"level": "DEFAULT",
"collar": {"static_band_pct": 0.2, "dynamic_band_pct": 0.03},
"circuit_breaker": {
"reference_window_ns": 300000000000,
"levels": [
{"name": "L1", "price_shift_pct": 0.04, "halt_duration_ns": 180000000000},
{"name": "L3", "price_shift_pct": 0.15, "halt_duration_ns": null}
]
}
}
],
"risk": {
"default_level": "DEFAULT",
"levels": [
{"name": "DEFAULT", "collar": {"static_band_pct": 0.2, "dynamic_band_pct": 0.03}}
]
},
"indexes": [
{
"id": "EDU50",
"description": "EduMatcher 50, the 50 largest companies by market cap",
"base_value": 1000.0,
"constituents": ["NVDA", "AAPL", "MSFT"]
}
],
"schedule": {
"sessions_enabled": true,
"country": "SE",
"schedule": {
"mon": {
"pre_open": "09:00",
"opening_auction_start": "09:25",
"continuous_start": "09:30",
"closing_auction_start": "16:00",
"closing_auction_end": "16:05"
},
"today": {
"pre_open": "09:00",
"opening_auction_start": "09:25",
"continuous_start": "09:30",
"closing_auction_start": "16:00",
"closing_auction_end": "16:05"
},
"today_is_holiday": false,
"upcoming_holidays": [{"date": "2026-12-25", "name": "Juldagen"}]
}
},
"config_version": "sha256:6d8d..."
}
History example (GET /api/v1/history/trades)¶
Minimal response:
Full response:
{
"trades": [
{
"ts": "2026-08-06T09:30:00.000+00:00",
"trade_id": "000001-000000001",
"symbol": "AAPL",
"price": 187.3,
"quantity": 50,
"tick_decimals": 2,
"buy_gateway_id": "TRADER02",
"sell_gateway_id": "MM01",
"aggressor_side": "BUY"
}
],
"count": 1,
"has_more": true,
"next_cursor": "eyJhZnRlciI6Ii4uLiJ9"
}
Admin example (POST /api/v1/admin/session/transition)¶
Minimal request:
Full request:
Response (the only shape; a refusal is 409 TRANSITION_REJECTED):
{
"requested_state": "CONTINUOUS",
"status": "APPLIED",
"command_id": "cmd-f41bb1b161cc9fb8d6d54353608f1bcc"
}
Compatibility and deprecation policy¶
- Versioning: this surface is namespaced under
/api/v1. The WebSocket streams under/api/v1/ws/(the WebSocket API Reference) are part of the same v1 contract and follow every rule below. - Backward compatibility: additive changes (new optional fields/endpoints) MAY be introduced within v1 without changing the base path.
- Breaking changes (field removal, required-field additions, semantic redefinition) MUST ship under a new versioned base path.
- Deprecation: deprecated fields/endpoints SHOULD be documented with migration guidance before removal in a later major API version.
- The contract:
spec/rest/openapi.jsonis the v1 contract. Any change to it is a reviewed diff, and each diff is judged against these rules. - Additive in practice:
- A new endpoint is additive.
- A new optional request field is additive.
- A new response field is additive. Clients must ignore unknown response fields.
- A new error
codeis additive. Clients handle an unknown one by its HTTP status. - A new enum value in a response is additive only if the gateway and engine
are deployed together. The gateway validates its responses, so a gateway
older than the engine answers
500on a value it does not know. EduMatcher releases both from one spec. - What clients MUST tolerate, so that the additive changes above stay additive for them:
- Unknown fields, in any REST response body and in any WebSocket frame
or
data: ignore them. - Unknown enum values, in any enum (
status,reject_code,cancel_reason,order_type, ...): treat them as "other", not as an error. New members may be added to any enum within v1. - Unknown WebSocket
typevalues: ignore the frame. New event types may be added within v1. - Unknown error
codevalues: handle them by HTTP status. - What is breaking for error codes: removing a
codea route can return, changing acode's HTTP status or meaning, or returning a differentcodefor a condition that already has one. Adding acode, or returning an existingcodefrom one more route, is additive.
Bootstrap¶
Bootstrap endpoints return a single composed response that a browser client
can fetch immediately after authenticating, replacing the 6–13 sequential
round-trips the current login flow requires. Sub-queries inside each handler
run in parallel using asyncio.gather.
Each response includes an incomplete array. When a field is listed there
its value is null; the rest of the response is still usable. Required
fields (marked below) return 503 ENGINE_TIMEOUT on failure — the response
would be too incomplete to be useful without them.
GET /api/v1/bootstrap/trader¶
Purpose: one-request startup payload for TRADER, MARKET_MAKER, and ADMIN sessions. Returns identity, full reference data, live session state, positions, active orders, today's recent fills, and capability flags.
Access: any valid key (read-only keys receive gateway_role: "READ_ONLY",
empty positions and orders and null recent_fills, but session and
halts like any key).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
fills_limit |
Int |
no | Maximum number of today's fill events in recent_fills; 1..500, default 50 |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
the object below | Startup payload |
{
"ts": "2026-07-27T09:30:01.123Z",
"incomplete": [], // field names that timed out (values are null)
"gateway_id": "TRADER01", // null for read-only keys
"gateway_role": "TRADER", // TRADER | MARKET_MAKER | ADMIN | READ_ONLY
"session_timezone": "Europe/Stockholm", // IANA name; the zone clients render wall-clock times in
// identical to GET /reference
"reference": {
"symbols": [ { "symbol": "AAPL", "tick_decimals": 2, ... } ],
"risk": { "default_level": "L2", "levels": { ... } },
"schedule": { "sessions_enabled": true, "country": "Sweden", "schedule": { ... } },
"config_version": "7f3a2c1"
},
// identical to GET /session; null if engine timed out (optional)
"session": { "state": "CONTINUOUS", "sessions_enabled": true, "next": { ... },
"session_timezone": "Europe/Stockholm", "session_date": "2026-07-27" },
// identical to GET /positions: an engine round trip (required — 503 on failure)
"positions": [ { "symbol": "AAPL", "net_qty": 200, "avg_cost": 208.40, "last_price": 210.25,
"market_value": 42050.0, "unrealized_pnl": 370.0,
"realized_pnl_session": 0.0, "realized_pnl_mtd": 0.0, "realized_pnl_ytd": 0.0 } ],
// the `orders` list of GET /orders (required — 503 on failure)
"orders": [ /* OrderDisplay[] */ ],
// today's fill events, at most fills_limit; null if stats DB absent (optional)
"recent_fills": [ /* OrderEvent[] */ ],
// the `halted` list of GET /halts; null if engine timed out (optional)
"halts": [ ],
// capability flags — assembled from config, never null
"capabilities": {
"sessions_enabled": true, // from reference.schedule.sessions_enabled
"stats_db_available": true, // false → history unavailable
"audit_db_available": false, // false → order lifecycle drill-down unavailable
"index_available": false // false → index tab unavailable
}
}
Required fields (return 503 ENGINE_TIMEOUT if they fail):
reference, orders and positions (the last two are empty, without an
engine query, for read-only keys).
Optional fields (appear as null + listed in incomplete on failure):
session, recent_fills, halts.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
fills_limit is not an integer in 1–500 |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ENGINE_TIMEOUT |
503 |
reference, orders or positions could not be fetched |
GET /api/v1/bootstrap/mm¶
Purpose: one-request startup payload for MARKET_MAKER sessions. Superset of
/bootstrap/trader — adds active quote bootstrap state and quote legs.
Access: MARKET_MAKER key only. TRADER and ADMIN keys receive 403.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
fills_limit |
Int |
no | As for /bootstrap/trader |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
the object below | Startup payload |
All fields from /bootstrap/trader, plus:
{
// ...trader fields...
"gateway_role": "MARKET_MAKER",
// the `quotes` list of GET /quotes; null if engine timed out (optional)
"quotes": [ /* ActiveQuote[] */ ],
// the `legs` list of GET /quotes/legs; null if engine timed out (optional)
"quote_legs": [ /* QuoteLeg[] */ ]
}
Required fields: reference, orders, positions.
Optional fields: session, recent_fills, halts, quotes, quote_legs.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
fills_limit is not an integer in 1–500 |
READ_ONLY |
403 |
Read-only key (no gateway_id) |
ROLE_DENIED |
403 |
Key resolves to TRADER or ADMIN role |
ENGINE_TIMEOUT |
503 |
reference, orders or positions could not be fetched |
GET /api/v1/bootstrap/admin¶
Purpose: one-request startup payload for ADMIN sessions. Returns reference data, session state, the full gateway roster, active halts, per-gateway active-order counts, per-gateway drop-copy sequence numbers, and capability flags.
Access: ADMIN role required. TRADER and MARKET_MAKER keys receive 403.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
the object below | Startup payload |
{
"ts": "2026-07-27T09:30:01.250Z",
"incomplete": [],
"gateway_id": "INSTRUCTOR",
"gateway_role": "ADMIN",
// identical to GET /reference (required — 503 on failure)
"reference": { /* symbols, risk, schedule, config_version */ },
// identical to GET /session; null if engine timed out (optional)
"session": { "state": "CONTINUOUS", "sessions_enabled": true, "session_timezone": "...", "session_date": "..." },
// the `gateways` list of GET /admin/gateways; null if engine timed out (optional)
"gateways": [
{ "id": "TRADER01", "role": "TRADER", "description": "...", "connected": true }
],
// the `halted` list of GET /halts; null if engine timed out (optional)
"halts": [ { "symbol": "AAPL", "level": "L2", ... } ],
// per-gateway active (non-terminal) order count — pure cache, never null
"active_order_counts": { "TRADER01": 3, "MM01": 12 },
// each active gateway's private-stream stream_seq now — pure cache, never null;
// per pm-api-gwy process: compare it only with /ws/admin/monitor events
// from the same instance
"monitor_last_seq": { "TRADER01": 100482, "MM01": 88213 },
"capabilities": {
"sessions_enabled": true,
"stats_db_available": true,
"audit_db_available": false,
"index_available": false
}
}
Required fields: reference.
Optional fields: session, gateways, halts.
The gateways and halts fields are also supplied by the monitor.snapshot
frame that the WS /api/v1/ws/admin/monitor socket sends immediately after auth
— a partial bootstrap response is therefore recoverable without a manual retry.
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Key is not ADMIN |
ENGINE_TIMEOUT |
503 |
reference could not be fetched |
Trading REST¶
POST /api/v1/orders¶
Purpose: submit one order for the caller's gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes | Instrument symbol |
side |
Side |
yes | BUY or SELL |
order_type |
OrderType |
yes | MARKET, LIMIT, STOP, STOP_LIMIT, FOK, ICEBERG, IOC, or TRAILING_STOP |
quantity |
Int |
yes | Positive order quantity |
tif |
Tif |
no | Time-in-force; defaults to DAY |
price |
Price |
conditional | Required for LIMIT, FOK, IOC, STOP_LIMIT, ICEBERG |
stop_price |
Price |
conditional | Required for STOP, STOP_LIMIT; optional initial stop for TRAILING_STOP (default: last trade ± trail_offset) |
visible_qty |
Qty |
conditional | Required for ICEBERG; must be less than quantity |
trail_offset |
Price |
conditional | Required for TRAILING_STOP |
smp_action |
SmpAction |
no | Self-match prevention action |
client_tag |
Str |
no | Optional opaque client correlation tag |
wait |
Bool |
no | ?wait=ack waits for the engine's verdict (see Write outcomes and safe retries) |
Idempotency-Key |
header | no | Makes a retry safe; see Write outcomes and safe retries |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{"order_id": "...", "status": "PENDING", "ack_timeout": false, ...} |
Default immediate reply |
200 OK |
{"order_id": "...", "status": "ACKED", "accepted": false, "reject_code": "COLLAR_BREACH", "event": {..., "reason": "collar breach"}, "ack_timeout": false} |
Returned when ?wait=ack waits for the matching ACK; a rejected ACK carries the stable machine-readable reject_code, and the engine's order.ack in event has the human-readable reason |
202 Accepted |
{"order_id": "...", "status": "PENDING", "ack_timeout": true, ...} |
?wait=ack and the ACK did not arrive in time; the order was sent |
Takes an optional Idempotency-Key header; see
Write outcomes and safe retries.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Body does not match the order type, or a price is not an exact multiple of the instrument's tick size (reject_code: TICK_VIOLATION) |
READ_ONLY |
403 |
Read-only credential used |
IDEMPOTENCY_KEY_REUSED |
409 |
The Idempotency-Key was used for a different request |
RATE_LIMIT |
429 |
Write limit exceeded |
SYMBOLS_NOT_READY |
503 |
Symbol metadata has not reached the gateway yet (reject_code: SYMBOL_NOT_READY) |
A conditional field the order_type does not use is rejected
(400 VALIDATION, reject_code: UNSUPPORTED_FIELD, for example
"LIMIT forbids trail_offset"), never silently dropped; a missing one is
MISSING_FIELD. The same per-type rule applies to OCO and combo legs, and ALF,
BALF and the engine apply it too, so an order gets the same reject_code on
every transport.
Prices are refused rather than rounded to the nearest tick: rounding would rest the order at a price the client never sent. See Tick precision.
DELETE /api/v1/orders/{order_id}¶
Purpose: cancel one live order in the caller's gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
order_id |
Str |
yes (path) | Order to cancel |
wait |
Bool |
no | ?wait=ack waits for order.cancelled.* or the refusal (order.ack with request: CANCEL) |
request_tag |
Str |
no | Query parameter echoed on order.cancelled.* or rejected ACK; max 64 chars |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{"order_id": "...", "request_tag": "...", "status": "PENDING_CANCEL"} |
Default: cancel sent; the outcome follows on the private WebSocket |
200 OK |
{"order_id": "...", "status": "ACKED" \| "REJECTED", "accepted": ..., "reject_code": ..., "event": {...}} |
With ?wait=ack: the cancel's outcome |
202 Accepted |
{..., "status": "PENDING_CANCEL", "ack_timeout": true} |
?wait=ack and the outcome did not arrive in time; the cancel was sent |
A refused cancel is REJECTED with or without a request_tag: the refusal is
the order.ack whose request is CANCEL. A request_tag additionally tells
two cancels of the same order apart.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Bad path or query |
READ_ONLY |
403 |
Read-only credential used |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
PATCH /api/v1/orders/{order_id}¶
Purpose: amend price and/or quantity on one live order.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
order_id |
Str |
yes (path) | Order to amend |
price |
Price |
conditional | New order price |
quantity |
Qty |
conditional | New order quantity |
request_tag |
Str |
no | Body field echoed on order.amended.* or rejected ACK; max 64 chars |
wait |
Bool |
no | ?wait=ack waits for order.amended.* or the refusal (order.ack with request: AMEND) |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{"order_id": "...", "request_tag": "...", "status": "PENDING_AMEND"} |
Default: amend sent; the outcome follows on the private WebSocket |
200 OK |
{"order_id": "...", "status": "ACKED" \| "REJECTED", "accepted": ..., "reject_code": ..., "event": {...}} |
With ?wait=ack: the amend's outcome |
202 Accepted |
{..., "status": "PENDING_AMEND", "ack_timeout": true} |
?wait=ack and the outcome did not arrive in time; the amend was sent |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Neither or both fields invalid |
READ_ONLY |
403 |
Read-only credential used |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
POST /api/v1/orders/{order_id}/replace¶
Purpose: cancel one live order and submit a replacement in one workflow.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
order_id |
Str |
yes (path) | Order to replace |
| body | Order fields |
yes | Same shape as POST /orders, on the same symbol |
wait |
Bool |
no | ?wait=ack also waits for the replacement's order.ack |
Idempotency-Key |
header | no | See Write outcomes and safe retries |
The gateway always waits for the original's cancel, and sends the replacement only once the engine has confirmed it.
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{"cancelled_order_id": "...", "replacement_order_id": "...", "status": "PENDING", "accepted": null, ...} |
Original cancelled; replacement sent |
200 OK |
{..., "status": "ACKED", "accepted": true \| false, "reject_code": ..., "event": {...}} |
With ?wait=ack: the replacement's verdict |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Replacement body invalid, or names another symbol than the original (field: symbol) |
READ_ONLY |
403 |
Read-only credential used |
IDEMPOTENCY_KEY_REUSED |
409 |
The Idempotency-Key was used for a different request |
REPLACE_REJECTED |
409 |
The engine refused the cancel (the order already filled, say; reject_code says why); nothing was sent |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
The cancel's outcome did not arrive in time; no replacement was sent |
SYMBOLS_NOT_READY |
503 |
The symbol's metadata is not loaded; nothing was cancelled |
GET /api/v1/orders¶
Purpose: return the caller gateway's orders as the engine holds them: resting orders plus recently finished ones.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "orders": [...] } |
The engine's order snapshot for the caller |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
Read-only credential used |
ENGINE_TIMEOUT |
503 |
The engine did not answer in time. There is no fallback to the gateway's cache |
GET /api/v1/orders/{order_id}¶
Purpose: return one cached order from the caller gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
order_id |
Str |
yes (path) | Order to fetch |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
cached order object | Current order state |
404 Not Found |
error envelope | Order id not in cache |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
Read-only credential used |
UNKNOWN_ORDER |
404 |
Order id unknown to the cache |
POST /api/v1/oco¶
Purpose: submit an OCO pair.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
oco_id |
Str |
yes | Your id for the pair, unique among your live pairs: reusing one is refused (accepted: false). Free again once the pair is done |
symbol |
Symbol |
yes | Instrument symbol |
quantity |
Qty |
yes | Total quantity |
leg1 |
OrderLeg |
yes | First leg definition: side, order_type, and the price / stop_price / trail_offset that type needs (same rule as POST /orders; ICEBERG is not supported on a leg) |
leg2 |
OrderLeg |
yes | Second leg definition, same shape |
tif |
Tif |
no | Time-in-force of both legs; defaults to DAY |
client_tag |
Str |
no | Opaque label echoed on both legs' events; max 64 chars |
wait |
Bool |
no | ?wait=ack waits for the engine's verdict (see Write outcomes and safe retries) |
Idempotency-Key |
header | no | Makes a retry safe; see Write outcomes and safe retries |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "oco_id": "...", "status": "PENDING", "accepted": null, "reason": null, "event": null, "ack_timeout": false } |
Sent; the verdict follows on the private WebSocket (oco.ack) |
200 OK |
{ "oco_id": "...", "status": "ACKED", "accepted": true \| false, "reason": ..., "event": {...}, "ack_timeout": false } |
With ?wait=ack: the engine's oco.ack |
202 Accepted |
{..., "status": "PENDING", "ack_timeout": true} |
?wait=ack and the verdict did not arrive in time; it was sent |
Takes ?wait=ack and an optional Idempotency-Key header; see
Write outcomes and safe retries.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Body invalid |
READ_ONLY |
403 |
Read-only credential used |
IDEMPOTENCY_KEY_REUSED |
409 |
The Idempotency-Key was used for a different request |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
SYMBOLS_NOT_READY |
503 |
Order entry before the symbol's tick precision reached the gateway. Transient; retry |
DELETE /api/v1/oco/{oco_id}¶
Purpose: cancel an OCO pair.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
oco_id |
Str |
yes (path) | One of your own OCO pairs; another gateway's id is ORDER_NOT_FOUND |
request_tag |
Str |
no | Query: echoed on the engine's oco.cancel_ack; max 64 chars |
wait |
Bool |
no | ?wait=ack waits for the oco.cancel_ack |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "oco_id": "...", "request_tag": ..., "status": "PENDING_CANCEL", "accepted": null, ..., "ack_timeout": false } |
Default: cancel sent; the outcome follows on the private WebSocket (oco.cancel_ack) |
200 OK |
{ ..., "status": "ACKED" \| "REJECTED", "accepted": ..., "reject_code": ..., "event": {...} } |
With ?wait=ack: the engine's oco.cancel_ack. A refusal (ORDER_NOT_FOUND, ORDER_ALREADY_TERMINAL) is REJECTED, not an error |
202 Accepted |
{ ..., "status": "PENDING_CANCEL", "ack_timeout": true } |
?wait=ack and the ack did not arrive in time; the cancel was sent |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
Read-only credential used |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
POST /api/v1/combos¶
Purpose: submit a combo order.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
combo_id |
Str |
yes | Combo group id |
legs |
List<ComboLeg> |
yes | 2–10 legs: symbol, side, order_type (default LIMIT), quantity, and the price / stop_price that type needs (same rule as POST /orders; ICEBERG and TRAILING_STOP are not supported on a leg) |
combo_type |
ComboType |
no | Fill rule; AON (all or none), the default and only value |
tif |
Tif |
no | Time-in-force of every leg; defaults to DAY |
smp_action |
SmpAction |
no | Self-match prevention action, as on POST /orders |
client_tag |
Str |
no | Opaque label echoed on every leg's events; max 64 chars |
wait |
Bool |
no | ?wait=ack waits for the engine's verdict (see Write outcomes and safe retries) |
Idempotency-Key |
header | no | Makes a retry safe; see Write outcomes and safe retries |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "combo_id": "...", "status": "PENDING", "accepted": null, "reason": null, "event": null, "ack_timeout": false } |
Sent; the verdict follows on the private WebSocket (combo.ack) |
200 OK |
{ "combo_id": "...", "status": "ACKED", "accepted": true \| false, "reason": ..., "event": {...}, "ack_timeout": false } |
With ?wait=ack: the engine's combo.ack |
202 Accepted |
{..., "status": "PENDING", "ack_timeout": true} |
?wait=ack and the verdict did not arrive in time; it was sent |
Takes ?wait=ack and an optional Idempotency-Key header; see
Write outcomes and safe retries.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Body invalid |
READ_ONLY |
403 |
Read-only credential used |
IDEMPOTENCY_KEY_REUSED |
409 |
The Idempotency-Key was used for a different request |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
SYMBOLS_NOT_READY |
503 |
Order entry before the symbol's tick precision reached the gateway. Transient; retry |
DELETE /api/v1/combos/{combo_id}¶
Purpose: cancel a combo order.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
combo_id |
Str |
yes (path) | Combo group to cancel |
request_tag |
Str |
no | Query: echoed on the engine's combo.cancel_ack; max 64 chars |
wait |
Bool |
no | ?wait=ack waits for the combo.cancel_ack |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "combo_id": "...", "request_tag": ..., "status": "PENDING_CANCEL", "accepted": null, ..., "ack_timeout": false } |
Default: cancel sent; the outcome follows on the private WebSocket (combo.cancel_ack) |
200 OK |
{ ..., "status": "ACKED" \| "REJECTED", "accepted": ..., "reject_code": ..., "event": {...} } |
With ?wait=ack: the engine's combo.cancel_ack. A refusal (ORDER_NOT_FOUND, ORDER_ALREADY_TERMINAL) is REJECTED, not an error |
202 Accepted |
{ ..., "status": "PENDING_CANCEL", "ack_timeout": true } |
?wait=ack and the ack did not arrive in time; the cancel was sent |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
Read-only credential used |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
POST /api/v1/quotes¶
Purpose: submit a two-sided market-maker quote.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes | Quoted instrument |
bid_price |
Price |
yes | Bid price |
bid_qty |
Qty |
yes | Bid quantity |
ask_price |
Price |
yes | Ask price |
ask_qty |
Qty |
yes | Ask quantity |
tif |
Tif |
no | Time-in-force of both sides; defaults to DAY |
quote_id |
Str |
no | Your id for the quote; defaults to the symbol |
wait |
Bool |
no | ?wait=ack waits for the engine's verdict (see Write outcomes and safe retries) |
Idempotency-Key |
header | no | Makes a retry safe; see Write outcomes and safe retries |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "symbol": "...", "quote_id": "..." \| null, "status": "PENDING", "accepted": null, "reason": null, "event": null, "ack_timeout": false } |
Sent; the verdict follows on the private WebSocket (quote.ack) |
200 OK |
{ "symbol": "...", ..., "status": "ACKED", "accepted": true \| false, "reason": ..., "event": {...} } |
With ?wait=ack: the engine's quote.ack |
202 Accepted |
{..., "status": "PENDING", "ack_timeout": true} |
?wait=ack and the verdict did not arrive in time; it was sent |
Takes ?wait=ack and an optional Idempotency-Key header; see
Write outcomes and safe retries.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Quote body invalid |
READ_ONLY |
403 |
Read-only credential used |
IDEMPOTENCY_KEY_REUSED |
409 |
The Idempotency-Key was used for a different request |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
SYMBOLS_NOT_READY |
503 |
Order entry before the symbol's tick precision reached the gateway. Transient; retry |
DELETE /api/v1/quotes/{symbol}¶
Purpose: cancel the active quote for one symbol.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | Quoted instrument |
request_tag |
Str |
no | Query: echoed on the engine's quote.cancel_ack; max 64 chars |
wait |
Bool |
no | ?wait=ack waits for the quote.cancel_ack |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "symbol": "...", "request_tag": ..., "status": "PENDING_CANCEL", "accepted": null, ..., "ack_timeout": false } |
Default: cancel sent; the outcome follows on the private WebSocket (quote.cancel_ack) |
200 OK |
{ ..., "status": "ACKED" \| "REJECTED", "accepted": ..., "reject_code": ..., "event": {...} } |
With ?wait=ack: the engine's quote.cancel_ack. A refusal (ORDER_NOT_FOUND, ORDER_ALREADY_TERMINAL) is REJECTED, not an error |
202 Accepted |
{ ..., "status": "PENDING_CANCEL", "ack_timeout": true } |
?wait=ack and the ack did not arrive in time; the cancel was sent |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
Read-only credential used |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
POST /api/v1/mass-cancel¶
Purpose: cancel all resting exposure for the caller or one symbol.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
no | Restrict the cancel to one symbol |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
kill-switch ack | What the engine cancelled (the call waits for the ack) |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
Read-only credential used |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not ACK in time |
GET /api/v1/symbols¶
Purpose: return instrument metadata for the caller gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbols": [...] } |
Current symbol metadata |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/news¶
Purpose: return one page of market-sim headlines, newest first, plus the
sector → symbol mapping. The gateway reads them read-only from
pm-market-sim's news history (market_sim_news.db in the data directory),
which keeps a headline for news.retention_days (default 90), so a
restarted gateway still serves them all. Access: Authenticated key (read-only keys included)
— unlike most endpoints in this section, it does not require a trading key,
since this is public information, not a trading action.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
limit |
int | No | Headlines per page, 1-500 (default 50) |
offset |
int | No | Headlines to skip, newest first (default 0) |
from |
ISO-8601 | No | Only headlines at or after this time; one without a timezone is UTC |
to |
ISO-8601 | No | Only headlines at or before this time; one without a timezone is UTC |
filter |
string | No | A symbol or a sector, any case. A symbol also matches its sector's headlines, a sector its symbols'; MARKET headlines always match |
status |
string | No | RUMOUR, CONFIRMED or RETRACTED |
sentiment |
string | No | positive (sentiment above 0) or negative (below 0) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "news": [...], "count": n, "total": n, "has_more": bool, "sectors": {...} } |
news is a list of news.event-shaped objects (see Message Reference — news.event), newest first, each with an added resolution: CONFIRMED or RETRACTED for a rumour that has been resolved (looked up across the whole history, so it is right on any page), and null for an open rumour or any other headline. total counts every match across all pages. sectors maps each sector name to its sorted list of symbols. The news list is empty when pm-market-sim has never run. |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
An argument is out of range or not one of its values |
NEWS_DB_UNAVAILABLE |
503 |
market_sim_news.db exists but cannot be read (locked or damaged) |
GET /api/v1/companies/{symbol}¶
Purpose: return the company profile behind one symbol, from the company
database pm-compdb-cli init builds (companies.db in the data directory).
The gateway opens it read-only. Access: Authenticated key (read-only keys included) — the profiles
are public information.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
path | Yes | Ticker, case-insensitive |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbol": "AAPL", "name": ..., "pe_ratio": ..., ... } |
Every column of company_view: the stored fields plus the derived years_in_business, ceo_tenure_years, pe_ratio, ps_ratio and net_margin_pct. Money is in millions of USD; a field the database has no value for is null. pm-compdb-cli columns lists them all. |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
UNKNOWN_COMPANY |
404 |
The database has no profile for symbol |
COMPANY_DB_UNAVAILABLE |
503 |
No companies.db in the data directory, or it cannot be read |
GET /api/v1/session¶
Purpose: return the venue's session phase and the locale clients render it in. Open to every key, read-only included.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "state", "state_since", "sessions_enabled", "next", "session_timezone", "session_date" } |
state, state_since (the UTC instant the engine entered state) and next come from the engine; session_timezone (IANA) is the exchange timezone every wall-clock time and history date filter is in, and session_date today's trading date in it |
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/halts¶
Purpose: return the currently-halted symbols table, for any key, read-only included. Halt state is public: every client needs it at bootstrap and again on every market-data reconnect, or a halt missed while disconnected leaves a stale badge for the rest of the session.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "halted": [...] } |
Currently-halted symbols; each { symbol, resume_at_ns?, level?, halt_source? } |
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/status¶
Purpose: return who the caller is: its gateway id and engine role.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "gateway_id", "gateway_role", "gateway_count"? } |
gateway_role is TRADER, MARKET_MAKER or ADMIN; ADMIN keys also get gateway_count, the connected gateways |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
GET /api/v1/healthz¶
Purpose: liveness probe for the API gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No auth required |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "ok": true, ... } |
Gateway is enabled and its engine listener is alive |
503 Service Unavailable |
{ "ok": false, ... } |
Gateway is disabled or its engine listener has stopped; probes read the status code |
Errors
| Code | When |
|---|---|
| none | This endpoint does not require auth |
GET /api/v1/quotes¶
Purpose: return the caller's active market-maker quotes: both legs' order ids, sizes, remaining quantities, statuses and prices.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "quotes": [...] } |
The caller's active quotes |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/quotes/legs¶
Purpose: return the current quote-leg state for the caller.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "legs": [...] } |
Current quote legs |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/positions¶
Purpose: return current net positions by symbol.
To query a different gateway's position (e.g. checking on a running
pm-mm-bot), see GET /api/v1/admin/gateways/{gateway_id}/positions,
which requires the ADMIN role.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "positions": [{ "symbol", "net_qty", "avg_cost", "last_price", "market_value", "unrealized_pnl", "realized_pnl_session", "realized_pnl_mtd", "realized_pnl_ytd" }, ...] } |
Net positions for the caller gateway, from the engine; P&L fields are null when unknown |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
Reference data¶
Base path: /api/v1/reference. These endpoints expose compiled reference data
that changes only when an admin reloads it.
GET /api/v1/reference¶
Purpose: return the full reference bundle in one round-trip.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbols", "risk", "indexes", "schedule", "config_version" } |
Full resolved reference bundle |
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/reference/config-version¶
Purpose: return the content-hash version of the reference bundle.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "config_version": "..." } |
Opaque bundle version hash |
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/reference/symbols¶
Purpose: return per-symbol tick and risk metadata.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbols": [...], "config_version": "..." } |
One object per symbol (each carries its own symbol) |
Each symbol object carries tick_decimals, level, and — when configured —
collar, order_limits (max_order_qty / max_order_value) and
circuit_breaker. collar is the symbol's effective band, its risk
level's defaults already merged under any per-symbol override; order_limits
is configured per symbol only, so it is simply what that symbol declared.
Either is omitted entirely when not configured. Full field law:
ReferenceSymbol in the message reference.
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/reference/risk¶
Purpose: return risk-band definitions and the default risk level.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "default_level", "levels", "config_version" } |
Risk-band configuration |
Each entry of levels carries its name and, when the level configures one,
collar — as configured, before any per-symbol override. Levels do not carry
order limits; those are per symbol and appear on /reference/symbols. Full
field law: RiskLevel in the message reference.
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/reference/indexes¶
Purpose: return configured exchange index definitions.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "indexes": [...], "config_version": "..." } |
Static index definitions |
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/reference/schedule¶
Purpose: return session schedule metadata.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
schedule object | sessions_enabled, country, and session transition times |
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
Market data¶
Base path: /api/v1/book. The order book as of now, without a WebSocket.
Both endpoints read the gateway's copy of the book.{symbol} stream, the one
a WebSocket snapshot is answered from, so a REST read and a WebSocket
subscription agree on the same snapshot.
seqis the market-data sequence of the snapshot on topicbook.{symbol}, theseqits WebSocketbookframe carries. A client that reads here and then subscribes ignoresbookframes whoseseqis at or below it (the subscription replays the latest snapshot first).ts_nsis when the engine produced the snapshot. The engine publishes a book when it changes, so a quiet book keeps an oldts_nsand is still current.- Every price is a display price with a
*_tickssibling: the integerprice * 10**tick_decimals(see Prices in Response contract). Use the ticks to compare or sum prices exactly. - Iceberg orders contribute their displayed size only.
GET /api/v1/book/{symbol}¶
Purpose: return one symbol's latest book: bid and ask levels (best first), the last trade, and the last five prints. Access: Authenticated key (read-only keys included) — market data is public.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
path | Yes | Ticker, case-insensitive |
levels |
query | No | Price levels per side, 1–100, default 10 |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbol", "tick_decimals", "ts_ns", "seq", "bids": [...], "asks": [...], "last_price", "last_price_ticks", "last_qty", "last_buy_price", "last_buy_price_ticks", "last_sell_price", "last_sell_price_ticks", "recent_trades": [...] } |
bids descending and asks ascending, each level { price, price_ticks, qty, count }; last_* are null until the symbol has traded; recent_trades are the last five prints, oldest first, each as in trade.executed plus price_ticks |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
levels outside 1–100, or symbol over-long |
UNKNOWN_SYMBOL |
404 |
symbol is not in the reference data |
ENGINE_TIMEOUT |
503 |
The engine did not publish the book in time (only on the first read of a book the gateway has not seen) |
GET /api/v1/book¶
Purpose: return best bid, best ask and last price for every symbol in the reference data, sorted by symbol, in one call. Access: Authenticated key (read-only keys included).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "books": [...], "count": n } |
One entry per symbol: { symbol, tick_decimals, ts_ns, seq, best_bid, best_ask, last_price, last_price_ticks }. A side with no orders is null; best_bid and best_ask are levels as above |
Errors
| Code | Status | When |
|---|---|---|
ENGINE_TIMEOUT |
503 |
The engine did not reply in time. The list is all or nothing: one book that cannot be had fails the call |
History¶
Base path: /api/v1/history. Trading endpoints are scoped to the caller's
gateway id; public history accepts any valid key.
GET /api/v1/history/orders¶
Purpose: return the caller gateway's order lifecycle events.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
no | Filter by symbol |
event_type |
Str |
no | Filter by event type |
date |
Date |
no | Single trading date |
from |
DateTime |
no | Range start |
to |
DateTime |
no | Range end |
limit |
Int |
no | Page size |
after |
Cursor |
no | Opaque page cursor |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope | Order lifecycle events for the caller gateway |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Query invalid |
READ_ONLY |
403 |
Read-only credential used |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/orders/{order_id}¶
Purpose: return the full lifecycle of one order for the caller gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
order_id |
Str |
yes (path) | Order to fetch |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "order_id", "count", "events" } |
Full lifecycle for one order |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Path invalid |
READ_ONLY |
403 |
Read-only credential used |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/fills¶
Purpose: return fill events for the caller gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
no | Filter by symbol |
date |
Date |
no | Trading date |
from |
DateTime |
no | Range start |
to |
DateTime |
no | Range end |
limit |
Int |
no | Page size |
after |
Cursor |
no | Opaque page cursor |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope | Fill history for the caller gateway |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
Read-only credential used |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/trades¶
Purpose: return public trade tape rows.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
no | Filter by symbol |
date |
Date |
no | Trading date |
from |
DateTime |
no | Range start |
to |
DateTime |
no | Range end |
limit |
Int |
no | Page size |
after |
Cursor |
no | Opaque page cursor |
order |
asc | desc |
no | asc (default) is oldest first; desc is newest first, so limit returns the most recent trades. The cursor continues in the chosen direction |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope | Public trade rows |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/daily¶
Purpose: return daily OHLCV rows.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
no | Filter by symbol |
date |
Date |
no | Single trading day |
from |
Date |
no | Range start |
to |
Date |
no | Range end |
limit |
Int |
no | Page size |
after |
Cursor |
no | Opaque page cursor |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope | Daily OHLCV rows |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/price-snapshots¶
Purpose: return intraday price snapshots.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes | Instrument symbol |
date |
Date |
no | Trading day |
from |
DateTime |
no | Range start |
to |
DateTime |
no | Range end |
limit |
Int |
no | Page size |
after |
Cursor |
no | Opaque page cursor |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope | Intraday mid/bid/ask series |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/index-daily¶
Purpose: return daily index OHLC rows.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
index_id |
IndexId |
no | Index id |
date |
Date |
no | Single trading day |
from |
Date |
no | Range start |
to |
Date |
no | Range end |
limit |
Int |
no | Page size |
after |
Cursor |
no | Opaque page cursor |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope | Daily index rows |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/index-snapshots¶
Purpose: return intraday index snapshots.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
index_id |
IndexId |
yes | Index id |
date |
Date |
no | Trading day |
from |
DateTime |
no | Range start |
to |
DateTime |
no | Range end |
limit |
Int |
no | Page size |
after |
Cursor |
no | Opaque page cursor |
interval |
1m | 5m | 15m | 1h |
no | Return only the last level in each bucket of this width, aligned in UTC; omit for every raw tick |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope | Intraday index series |
pm-index publishes many updates a second, so a whole session of raw ticks runs
to tens of thousands of rows. To chart a session in one page, pass interval:
each row is then the last snapshot of its bucket (the bar's close), with its
real ts. The row shape and the cursor are unchanged.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/indexes¶
Purpose: list index ids with recorded data.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
date |
Date |
no | Filter by trading day |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "index_ids": [...], "count": N } |
Index ids with data |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
STATS_DB |
503 |
pm-stats database missing |
GET /api/v1/history/index-events¶
Purpose: return index structural and audit events from pm-index.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
index_id |
IndexId |
yes | Index id |
from |
Timestamp |
no | ISO-8601 or YYYY-MM-DD, like every history range (no offset = exchange time); default 30 days ago |
to |
Timestamp |
no | Same form; default now |
types |
Str |
no | Repeatable event-type filter |
max_records |
Int |
no | Reply cap |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "events": [...], "count": N } |
Structural audit log |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
INDEX_ERROR |
502 |
pm-index rejected the request |
INDEX_TIMEOUT |
503 |
pm-index did not reply in time |
Clearing¶
Base path: /api/v1/clearing. Read-only views of pm-clearing's ledger
(clearing.db) and pm-eod's settlement ledger (eod.db), opened read-only
by the gateway (clearing_db, eod_db in its config). Nothing here writes,
and nothing is derived that the ledgers do not hold: there is no margin,
equity, collateral, buying power or open interest.
Scope. The identity is the gateway; there are no client accounts. An
ADMIN key reads the venue and may narrow any route with gateway. A
TRADER or MARKET_MAKER key reads its own gateway: without gateway it is
scoped to itself, and naming any other gateway is 403 SCOPE_DENIED — never a
silent substitution. A read-only key reads no clearing data (403
READ_ONLY). Venue-wide routes (summary, participants, symbols) are
ADMIN only.
Units. Clearing stores money in integer ticks of each symbol's
tick_decimals. Every money column of a row is returned twice: <name>_ticks
as stored and <name> in display currency (<name>_ticks /
10**tick_decimals). One tick is a different amount of money per symbol, so
only display values may be added across rows; the cross-symbol totals the API
returns (participants, summary) are sums of display values. Averages and
P&L are weighted-average results, so their _ticks are not whole numbers.
Freshness and retention. pm-clearing writes fills in batches — every
100 trades or 5 seconds by default — so a fill can take up to one flush to
appear (last_flush_ts_ns on summary). Raw trades are pruned after
pm-clearing --retention-days (90 by default; retained_from on trades);
daily rows and close snapshots are kept. Session and gateway-lifecycle times
are when clearing observed the event, not engine times. A GAP is a jump
clearing saw in the trade ids of its feed; the absence of one does not prove
the feed was complete.
Lists. A list reply is {"<plural>": [...], "count", "has_more"}, at most
limit rows in a stable order; has_more: true means more rows match — narrow
the filters. trades is keyset-paginated like the history endpoints
(has_more, next_cursor, passed back as after). Dates are YYYY-MM-DD
trading days in the session timezone; a malformed date, or a from after
to, is 400 VALIDATION. A missing, locked or unreadable clearing.db is
503 CLEARING_DB, never an empty list; an empty list is a true zero.
GET /api/v1/clearing/summary¶
Purpose: the venue's clearing state — participant and open-position counts, realized/unrealized P&L in display currency, the latest trade and flush times, feed gaps on the latest session date (gap_count, latest_gap), and pm-eod's newest run (last_eod_run; eod_db_status: ok, not_run when there is no ledger yet because pm-eod has not run here, or unreadable; none of them is an error here).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
ClearingSummary |
Venue clearing state |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
Read-only key: no clearing data |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/participants¶
Purpose: per gateway with a position row, realized/unrealized/total P&L in display currency (each position converted before the sum), position_count, open_position_count and last_update_ts_ns.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (participants) |
One row per gateway, by gateway id |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/participants/{gateway_id}¶
Purpose: one gateway's totals (as in participants), its positions, latest_close_date, and links — the scoped routes for its trades, daily rows, close snapshots, gateway sessions, settlements and balances. A gateway clearing has no rows for answers zeros and positions: [].
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway_id |
GatewayId |
yes (path) | The gateway; a participant may name only itself |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
ParticipantDetail |
The gateway's current clearing state |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/positions¶
Purpose: current position per gateway and symbol: signed net_qty, avg_cost, mark_price, realized and unrealized P&L, cumulative buy/sell quantities and values, last_trade_ts_ns (exchange time) and updated_ts_ns (clearing write time). Ordered by gateway, symbol.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
symbol |
Symbol |
no | Only this symbol |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (positions) |
Positions as of the latest flush |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/position-replay¶
Purpose: how one gateway's position in one symbol was built through one trading day, fill by fill, by pm-clearing's own position rules. start is the position before the day's first fill (the previous daily row's end, or flat). Each step is one of the gateway's fills in the order clearing applied it, with kind (open from flat, add, reduce, close to flat, flip through flat to the other side) and, after the fill, net_qty, avg_cost, realized_delta, realized_day (the day's so far) and unrealized at the fill's price; money as display value and _ticks beside the step's tick_decimals. matches_daily_row says whether the replay ends on the day's stored daily row (net quantity, average cost, realized P&L, which is echoed as daily_row), and on the pair's latest day matches_position whether it ends on the stored position; null when there is nothing to compare or the replay was cut (has_more, beyond 5 000 fills). A mismatch is reported, never corrected. A day whose raw trades retention has pruned has trades_retained: false and no steps; a pair that never traded has trade_date: null.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes | The symbol |
gateway |
GatewayId |
no | This gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
date |
Date |
no | The trading day, session timezone; default the latest day the pair traded |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
PositionReplay |
The day's fills, step by step |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/exposure¶
Purpose: each position valued at its mark: net_notional (signed), gross_notional, realized, unrealized and total P&L. A position without a mark has null notionals. Ranked by sort in display currency, so symbols of different precision compare correctly.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
symbol |
Symbol |
no | Only this symbol |
sort |
gross_notional | net_notional | realized_pnl | unrealized_pnl | total_pnl |
no | Largest first by this measure; default gross_notional |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (exposure) |
Marked positions |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/trades¶
Purpose: the raw executions clearing still holds, newest first by exchange time (ts_ns, then trade_id). Each row carries ingest_ts_ns (clearing's write time), trade_date, price/price_ticks/tick_decimals, both order ids, aggressor_side, match_type and the audit msg_id. A participant sees its own side only: the counterparty's gateway and order id are null. retained_from is the oldest trading day still held.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
symbol |
Symbol |
no | Only this symbol |
date |
Date |
no | One trading day, session timezone |
from |
Date |
no | First trading day, inclusive |
to |
Date |
no | Last trading day, inclusive; not before from |
limit |
Int |
no | Page size, 1-5000, default 500 |
after |
Cursor |
no | Opaque page cursor: the previous page's next_cursor |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope (trades) + retained_from |
One page of retained trades |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/daily¶
Purpose: per trading day, gateway and symbol traded that day: traded/bought/sold quantity and value, net_amount, the day's realized_pnl, and the position, average cost and open P&L after the day's last trade. Kept after raw trades are pruned. Newest day first.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
symbol |
Symbol |
no | Only this symbol |
date |
Date |
no | One trading day, session timezone |
from |
Date |
no | First trading day, inclusive |
to |
Date |
no | Last trading day, inclusive; not before from |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (daily) |
Daily rows |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/close-snapshots¶
Purpose: one row per gateway and symbol at every session close, whether or not it traded that day: net_qty, cumulative realized and unrealized P&L, and the closing mark. This close-to-close series is what EOD settlement uses; there is no intraday history. Newest close first.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
symbol |
Symbol |
no | Only this symbol |
date |
Date |
no | One trading day, session timezone |
from |
Date |
no | First trading day, inclusive |
to |
Date |
no | Last trading day, inclusive; not before from |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (snapshots) |
Close snapshots |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/symbols¶
Purpose: per symbol traded in the date range: traded_qty (counted once per side), traded value and realized P&L, plus the current aggregate signed position (open_net_qty) and its open P&L. open_net_qty sums signed positions, so it is zero while every holder is a gateway; it is not open interest. The two sides are reported separately: open_long_qty and open_short_qty (both positive; long − short = open_net_qty) and the number of gateways on each, long_holders and short_holders. Money is converted to the symbol's finest recorded precision.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
date |
Date |
no | One trading day, session timezone |
from |
Date |
no | First trading day, inclusive |
to |
Date |
no | Last trading day, inclusive; not before from |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (symbols) |
Activity per symbol |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/flows¶
Purpose: who bought from whom on one trading day — per buyer/seller gateway pair, its trades, quantity and value (display currency, each trade converted with its own precision), largest value first. ADMIN only: it names every trade's counterparty, which a participant never sees. Read from the raw trades, so a day whose raw trades retention has pruned has trades_retained: false and no pairs; an empty ledger has trade_date: null.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
date |
Date |
no | The trading day, session timezone; default the latest day with a daily row |
symbol |
Symbol |
no | Only this symbol |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
ClearingFlows |
Buyer/seller pairs, largest first |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/netting¶
Purpose: one trading day's trades against the one net amount each gateway is left with — an ADMIN sees every gateway (or the one gateway names), a TRADER or MARKET_MAKER only its own. Per gateway: bought_value, sold_value, net_amount (bought − sold: positive is what the gateway pays for the day's trades, negative what it receives) and trade_count. Totals count each trade once (a participant: its buys plus its sells): trade_count, traded_qty, gross_value, payment_count (gateways with a non-zero net), net_paid and net_received. Values are in display currency, every symbol converted before the sum. Trade counts come from the raw trades: once retention has pruned the day, trades_retained is false and the counts are null, while the daily-row figures still answer. A day without trades is an empty netting; an empty ledger has trade_date: null. This is the cash the day's trades net to, not pm-eod's settlement, which moves the day's change in P&L (/settlements).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
date |
Date |
no | The trading day, session timezone; default the latest day with a daily row |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
ClearingNetting |
The day's netting |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/session-events¶
Purpose: the events clearing recorded, newest first: PHASE (session state changes, phase: {state, prev_state}), EOD (the engine's end of day, eod: {symbols_count, marked_symbols}) and GAP (a jump in the trade ids clearing received, gap: {run_seq, last_seq, next_seq, missing_trades}). Exactly one payload field is present, the one event_type names; the stored JSON is not part of the contract. ts_ns is when clearing observed the event (for a GAP, the exchange time of the trade after it). No GAP does not prove the feed was complete.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
type |
EOD | PHASE | GAP |
no | Only this event type (case-insensitive); anything else is 400 |
from |
Date |
no | First trading day, inclusive |
to |
Date |
no | Last trading day, inclusive; not before from |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (events) |
Session events |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/gateway-sessions¶
Purpose: when clearing saw each gateway connect and disconnect, and the recorded disconnect_reason, newest connect first. from/to select by the trading day of the connect in the session timezone. A session without disconnected_at_ns is still connected, or its disconnect was not seen.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this gateway. ADMIN only; a participant may name only itself and is scoped to itself without it |
from |
Date |
no | First trading day of the connect, inclusive |
to |
Date |
no | Last trading day of the connect, inclusive |
connected_only |
Bool |
no | Only sessions without a recorded disconnect |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (sessions) |
Gateway sessions |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/reconciliation¶
Purpose: every day, side, gateway and symbol where the quantity or value counted from the raw trades differs from the daily row (raw_*, summary_*, *_diff, notionals with _ticks and tick_decimals). It scans the raw trades of the range, so the range is required and the route is an explicit operator action, not a polling query. Raw trades are pruned after the retention window while daily rows stay, so only days from retained_from on are compared; compared_from/compared_to give the window actually compared (both null when no day of the range has raw trades left). An empty list means no discrepancy in the compared, retained data — not a verified complete history.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
from |
Date |
yes | First trading day |
to |
Date |
yes | Last trading day; not before from |
gateway |
GatewayId |
no | Only this gateway |
symbol |
Symbol |
no | Only this symbol |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (discrepancies) + retained_from, compared_from, compared_to |
Discrepancies in the compared window |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
CLEARING_DB |
503 |
clearing.db missing, locked or unreadable |
GET /api/v1/clearing/health¶
Purpose: two separate facts. database: whether clearing.db is readable (available, detail), its journal mode, row counts and latest trade and flush times. process: whether pm-clearing's receive loop answered a ping within 0.5 s (alive, detail) — the check pm-clearing-cli health makes. A readable database does not prove the process is alive, and a silent process does not hide the database facts; either failure is reported inside a 200. Each call pings once: poll it sparingly. No file path or socket address is returned.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
ClearingHealth |
Database and process health |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
Read-only key: no clearing data |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
GET /api/v1/clearing/settlements¶
Purpose: pm-eod's daily settlement per account, newest day first, then account. amount_minor is an integer in minor units of the display currency (2 decimals: 1234 is 12.34) — a different unit from clearing's ticks; amount is the same value as a signed decimal string. Positive means the exchange owes the gateway, negative the gateway owes the exchange; the rows of a day sum to zero. detail gives the unrounded day P&L per symbol as decimal strings. run_status is the day's pm-eod run (ok, failed, report-failed); runs lists the runs in the date range, including days that ran but did not settle (step messages for ADMIN only). A settlement is the transfer of a day's close-to-close P&L — not margin, collateral or a completed payment. EXCHANGE holds the rounding residual and is visible to ADMIN only. A day without a settlement is an empty list; a missing ledger is 503 EOD_DB.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this account: a gateway, or EXCHANGE (ADMIN only). A participant may name only itself and is scoped to itself without it |
date |
Date |
no | One trading day |
from |
Date |
no | First trading day, inclusive |
to |
Date |
no | Last trading day, inclusive; not before from |
limit |
Int |
no | 1-5000, default 1000; has_more says more rows match |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
bounded list envelope (settlements) + runs + eod_db_available |
Settlement rows and pm-eod runs; eod_db_available is false before pm-eod's first run (no ledger, nothing settled) |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
EOD_DB |
503 |
eod.db unreadable, or its roster malformed. A missing eod.db (pm-eod has not run yet) is a 200 with eod_db_available: false |
GET /api/v1/clearing/balances¶
Purpose: per account, the opening balance from pm-eod's roster (ref_data/roster.yaml beside eod.db), the sum of its settlements up to as_of, and their total — all integer minor units with decimal-string twins. The balance is derived by the gateway; pm-eod stores none. It is a running total of mark-to-market settlements, not cash, equity or collateral. ADMIN sees every account on the roster or in the ledger, EXCHANGE included; a participant its own (zeros when it is on neither). last_settled_date is the latest settled day the sums include.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
GatewayId |
no | Only this account: a gateway, or EXCHANGE (ADMIN only). A participant may name only itself and is scoped to itself without it |
as_of |
Date |
no | Sum settlements up to and including this trading day; all without it |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "balances", "count", "as_of", "last_settled_date", "eod_db_available" } |
Derived balance per account |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A filter is malformed (date, range, limit, cursor, sort); field names it |
READ_ONLY |
403 |
Read-only key: no clearing data |
SCOPE_DENIED |
403 |
A TRADER or MARKET_MAKER key named another gateway |
EOD_DB |
503 |
eod.db unreadable, or its roster malformed. A missing eod.db (pm-eod has not run yet) is a 200 with eod_db_available: false |
Admin REST¶
Base path: /api/v1/admin. ADMIN role required.
POST /api/v1/admin/session/transition¶
Purpose: request a session-phase transition from the engine.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
to_state |
SessionState |
yes | Requested session phase |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{"requested_state": "...", "status": "APPLIED", "command_id": "..."} |
Transition applied |
409 Conflict |
error envelope | The engine refused the transition |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Invalid to_state |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
TRANSITION_REJECTED |
409 |
Engine rejected the transition |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/admin/sim¶
Purpose: the market simulator's latest state and the model's true (hidden)
fair value per symbol, from pm-market-sim. For instructors: students see
only prices, never these values.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "available": true, "state": {...}, "values": {...} } |
available is false, and state/values null, when the simulator is not running |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
The key's gateway is not ADMIN |
GET /api/v1/admin/gateways¶
Purpose: list configured gateways and live connection state.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "gateways": [...] } |
Gateway roster and connection status |
Each entry has id, role, description and connected. A connected
gateway also carries connected_since_ns: when the engine accepted its current
connection, in epoch nanoseconds. The field is absent while the gateway is
offline.
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/gateways/{gateway_id}/disconnect¶
Purpose: forcibly disconnect one gateway. Sends the ADMIN message
risk.gateway_kick and waits for the engine's answer; the target's
disconnect_behaviour runs, and the disconnect names the caller.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway_id |
GatewayId |
yes (path) | Gateway to disconnect (case-insensitive) |
reason |
Str |
no | Body, optional: note recorded on the admin monitor and in the disconnect (kicked by <ADMIN>: <reason>) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "accepted": true, "target_gateway_id": "...", "reason": "", "command_id": "..." } |
The engine ended the session; GET /admin/gateways already shows it offline |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
DISCONNECT_REJECTED |
409 |
The engine refused: the gateway is not configured, not connected, or the caller's own; message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/symbols/{symbol}/halt¶
Purpose: halt one symbol through the engine's circuit-breaker path. The body is optional.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | Symbol to halt (case-insensitive) |
level |
Str |
no | A rung of the symbol's ladder; omit for an indefinite halt until resumed |
reason |
Str |
no | Optional note |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
halt ack | The symbol is halted |
409 Conflict |
error envelope | The engine refused the halt |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Body invalid |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
HALT_REJECTED |
409 |
Engine refused (unknown symbol, no circuit breaker, unknown level); message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/symbols/{symbol}/resume¶
Purpose: resume one halted symbol.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | Symbol to resume (case-insensitive) |
reason |
Str |
no | Body, optional: note for the audit log |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
resume ack | The symbol is trading again |
409 Conflict |
error envelope | The engine refused the resume |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
RESUME_REJECTED |
409 |
Engine refused (for example the symbol is not halted); message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/admin/risk/state¶
Purpose: return live per-symbol risk state.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbols": [...] } |
Current collar and circuit-breaker state (one object per symbol) |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/admin/gateways/{gateway_id}/orders¶
Purpose: one gateway's resting and recently finished orders as the engine holds
them: the authoritative view. GET /admin/orders is the gateway's own read
model across all gateways, faster and filterable but limited to what this
gateway has seen since it started.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway_id |
GatewayId |
yes (path) | Whose orders (case-insensitive) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "orders": [...], "count": N, "status" } |
Same shape as GET /orders; status is OK for a connected gateway, NOT_CONNECTED for a logged-off participant, whose orders are still listed |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_GATEWAY |
404 |
No participant has this gateway id |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/admin/symbols/{symbol}/orders¶
Purpose: every resting order on one symbol across all gateways, each with its
gateway_id, ordered by price then arrival (time priority). With price, only
that level: the per-order composition behind the book's aggregated levels.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | Instrument (case-insensitive) |
price |
Price |
no | Query: only this price level |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbol", "price"?, "rejected": false, "orders": [...], "count": N } |
The resting orders |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
QUERY_REJECTED |
409 |
Engine refused (for example Unknown symbol: XYZ) |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/admin/orders¶
Purpose: return the cross-gateway active-order table.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
no | Filter by symbol |
gateway_id |
GatewayId |
no | Filter by gateway |
status |
OrderStatus |
no | Filter by status |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "count": N, "orders": [...], "retention_sec": N } |
Current cross-gateway active orders |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
GET /api/v1/admin/orders/{order_id}/audit¶
Purpose: return the full cross-gateway lifecycle of one order.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
order_id |
Str |
yes (path) | Order to fetch |
limit |
Int |
no | Maximum number of events |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "order_id", "count", "events" } |
Full audited lifecycle |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_ORDER |
404 |
No audited events for the order |
AUDIT_INDEX_UNAVAILABLE |
503 |
No audit index available |
GET /api/v1/admin/gateways/{gateway_id}/positions¶
Purpose: return net position and average cost for any one gateway (not
just the caller's own) -- the admin counterpart to
GET /api/v1/positions, which serves the same engine
round trip for the caller enriched with prices and P&L. It is the REST
equivalent of pm-alf-console's and pm-alf-gwy's POS|GW=<gateway_id>
command -- all three read the same system.position_request /
system.position_snapshot.<gateway_id> pair, so they always agree.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway_id |
GatewayId |
yes (path) | Gateway to query (any gateway, case-insensitive) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "gateway_id", "count", "positions": [{ "symbol", "net_qty", "avg_cost" }, ...] } |
Net position and average cost per symbol for the target gateway, connected or not |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_GATEWAY |
404 |
No participant has this gateway id |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/symbols/{symbol}/cancel-orders¶
Purpose: cancel all resting exposure on one symbol, across every gateway.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | Symbol to clear (case-insensitive) |
reason |
Str |
no | Body, optional: note for the audit log |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
kill-switch ack | What the engine cancelled |
409 Conflict |
error envelope | The engine refused the command |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
KILL_SWITCH_REJECTED |
409 |
Engine refused; message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/gateways/{gateway_id}/kill-switch¶
Purpose: cancel all resting exposure for one target gateway, without disconnecting it.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway_id |
GatewayId |
yes (path) | Gateway whose orders and quotes to cancel (case-insensitive) |
symbol |
Symbol |
no | Query: only this instrument; omit for all |
reason |
Str |
no | Body, optional: note for the audit log |
The target need not be connected, and the audit trail names the ADMIN. It
must be a configured participant: an unknown id is refused with 409
KILL_SWITCH_REJECTED (Gateway not configured: X), not acknowledged with
nothing cancelled.
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
kill-switch ack | What the engine cancelled; symbol is echoed when the cancel was scoped |
409 Conflict |
error envelope | The engine refused the command |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
KILL_SWITCH_REJECTED |
409 |
Engine refused; message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
DELETE /api/v1/admin/gateways/{gateway_id}/quotes/{symbol}¶
Purpose: withdraw one participant's two-sided quote on one symbol, leaving its
other orders. Runs through the ADMIN kill switch (quotes_only), so it works
whether or not that gateway is connected and the audit trail names the ADMIN;
an id that is not a configured participant is refused (409).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway_id |
GatewayId |
yes (path) | Whose quote (case-insensitive) |
symbol |
Symbol |
yes (path) | Instrument (case-insensitive) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
kill-switch ack, quotes_only: true |
The quote legs cancelled; cancelled_quotes is 0 when there was no quote |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
KILL_SWITCH_REJECTED |
409 |
Engine refused; message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/market/halt¶
Purpose: halt every symbol (halt source ADMIN) and cancel every market-maker
quote. Resting orders stay on the book; POST /admin/market/kill-switch
cancels those.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No arguments |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "accepted": true, "halted_symbols": 3, "halted_symbol_ids": [...], "cancelled_quotes": 4, ... } |
What the engine halted |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
HALT_REJECTED |
409 |
Engine refused; message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/market/resume¶
Purpose: lift the halt of POST /admin/market/halt on every symbol.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No arguments |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "accepted": true, "resumed_symbols": 3, "resumed_symbol_ids": [...], ... } |
What the engine resumed |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
RESUME_REJECTED |
409 |
Engine refused; message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
GET /api/v1/admin/market/volume¶
Purpose: today's traded quantity, value and trade count per symbol, and the venue totals.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No query parameters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "symbols": [{ "symbol", "qty", "value", "trades" }], "count": 2, "total_qty", "total_value", "total_trades" } |
Today's volume; value is display money |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/symbols/{symbol}/reopen¶
Purpose: force one symbol to uncross now and clear any halt in one step. Without
price it opens at the natural equilibrium; with one, at that operator price,
for when a failed auction left no equilibrium. dry_run reports the indicative
print without changing anything.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | Instrument (case-insensitive) |
price |
Price |
no | Body: operator opening price, on the tick grid (refused, not rounded, otherwise) |
dry_run |
Bool |
no | Body: report the indicative print only; default false |
reason |
Str |
no | Body: note for the audit log |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "accepted": true, "symbol", "dry_run", "indicative_price", "indicative_qty", "surplus", "imbalance_side"?, "printed_price", "traded_qty" } |
The uncross result; printed_price is null on a dry run |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
REOPEN_REJECTED |
409 |
Engine refused (for example the symbol is not halted); message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
SYMBOLS_NOT_READY |
503 |
price given before the symbol's tick precision reached the gateway |
POST /api/v1/admin/market/kill-switch¶
Purpose: cancel all resting exposure across every gateway and symbol.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
reason |
Str |
no | Optional note |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
kill-switch ack | What the engine cancelled |
409 Conflict |
error envelope | The engine refused the command |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A body field, query parameter, header or history filter failed validation; field names it. reject_code is one of MISSING_FIELD, UNSUPPORTED_FIELD, INVALID_VALUE, TICK_VIOLATION |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
KILL_SWITCH_REJECTED |
409 |
Engine refused; message is its reason |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
POST /api/v1/admin/indexes/{index_id}/rebalance¶
Purpose: rebalance one configured index through pm-index.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
index_id |
IndexId |
yes (path) | Index to rebalance |
updates |
List<RebalanceUpdate> |
yes | Shares-outstanding updates |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
rebalance ack | Update applied |
409 Conflict |
error envelope | Rebalance rejected |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
Batch body invalid |
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
REBALANCE_REJECTED |
409 |
pm-index rejected the request |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
INDEX_TIMEOUT |
503 |
pm-index did not reply in time |
POST /api/v1/admin/reference/reload¶
Purpose: request a reference-data reload. The current engine rejects this request because the active configuration cannot be both reloaded and reconstructed from the audit trail. Deploy a compiled config artifact and restart the engine to apply configuration changes.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none | — | — | No request body |
Reply (if an engine accepts the request)
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "status": "RELOADED", "config_version": "..." } |
Reload accepted by an engine that supports it |
409 Conflict |
error envelope | RELOAD_REJECTED: the current engine rejects reloads that cannot be recorded |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
A read-only key used on a gateway-scoped endpoint |
ROLE_DENIED |
403 |
Caller is not ADMIN |
RELOAD_REJECTED |
409 |
Reload would change the symbol or index set |
RATE_LIMIT |
429 |
Per-key write limit exceeded; retry after a short pause |
ENGINE_TIMEOUT |
503 |
Engine did not reply in time |
Audit (ADMIN)¶
The Audit GUI's reads over audit evidence (design
docs-design/EduMatcher-Audit-GUI.md). Collections are configured on the
server (api_gateways.<name>.audit_collections) and named by id; no route
accepts a path. A client pins a collection as a snapshot and names that
snapshot in every read, so pages, stories and findings stay on the evidence
it pinned even while audit.log grows. Nanosecond times are decimal
strings. Missing evidence and analyses the evidence cannot support are
errors with a stable reason, never empty results.
Pinning is synchronous and parses every record (about 90,000 records/s);
the reconstruction every other read needs runs in the audit worker process
(prepare, see POST /audit/jobs), never in a request.
Filters. /audit/events, /audit/findings,
/audit/market/{symbol}/lifelines, /audit/episodes and /audit/analyze take a typed filter in q, the grammar of
the Audit GUI's filter bar. It is not an expression language:
A filter is clauses separated by spaces, all of which must hold. A clause is
a field, an operator and a value: : is equals (for topic, starts
with), and <, <=, >, >= compare an ordered field. After : a comma
list is a set of alternatives (gateway:GW1,GW2); a value in double quotes
keeps its spaces and commas. A field appears twice only to bound a range
(lifetime>1s lifetime<5s). At most 500 characters, 12 clauses and 20 values
in a list. Field names are lower case; enum values are accepted in any case.
| Field | Routes | Type | Values |
|---|---|---|---|
topic |
events | prefix | Topic prefix, e.g. order. |
symbol |
events | id | A symbol |
gateway |
events, lifelines | id | Events: the record's actor, gateway_id, or a trade's buyer or seller. Lifelines: the order's gateway |
order |
events | id | An order id, in full |
time |
events | time | Receipt time: ISO-8601 (UTC without an offset) or epoch ns |
run |
events, lifelines | int | The engine restart epoch |
lane |
findings | enum | evidence, consistency, operations, behaviour |
severity |
findings | ordered | info < warn < error; severity>=warn is warn and error |
code |
findings | id | A finding code, e.g. ESEQ_GAP |
origin |
findings | enum | replay, forensics |
kind |
findings | enum | The episode kind: order, trade, quote, oco, combo, command, market_phase, session, gateway, index, recovery, orphan |
side |
lifelines | enum | BUY, SELL |
type |
lifelines | id | The order type as recorded, e.g. LIMIT |
end |
lifelines | enum | filled, cancel.owner, cancel.system, expired, open (still resting when its run's records end) |
lifetime |
lifelines | duration | Admission to end, with a unit: ns, us, ms, s, m, h. An order that never ended has none, and no bound admits it |
phase |
lifelines, episodes | enum | The market phase it was admitted in: PRE_OPEN, OPENING_AUCTION, CONTINUOUS, CLOSING_AUCTION, CLOSED |
kind |
episodes | enum | The episode kind, as for findings |
outcome |
episodes | id | Its outcome as the replay states it, e.g. FILLED |
id |
episodes | id | Its anchor (order, trade, quote, OCO, combo or command id), in full |
chain |
episodes | id | Its causal chain (correlation_id) |
code |
episodes | id | It carries this finding code |
severity |
episodes | ordered | Its worst finding, as for findings |
confidence |
episodes | ordered | Its weakest link: NONE < HEURISTIC < STRONG < CERTAIN < RECORDED |
side, type, end, lifetime |
episodes | as lifelines | An order's (no other kind has them); gateway, symbol and run also apply |
A route's own filter parameters (symbol, lane, gateway, ...) are
clauses of the same filter: ?symbol=AAA and ?q=symbol:AAA are one filter
and share cursors; a parameter and a clause on the same field are 400. A
lifelines filter tests each order as it really was, whatever the window
cuts. An unknown field or value, a malformed clause or a broken bound is
400 VALIDATION with field: "q", the clause, and suggestions for
term (the field name or value in the clause they would replace); it is
never ignored. Values reach the read models only as bound parameters.
Every filtered list returns filter ({ "text", "clauses" }, the canonical
form, its clauses sorted and every value as the server read it: durations
and times in ns) and total ({ "value", "qualifier" }: every match, not the
page; exact, or lower_bound when counting stopped, at 10,000 for events).
Reproduce. Every snapshot read returns reproduce: api (method,
url), the request that returns the same response again, with the filter in
canonical form and the cursor; and cli, the pm-audit-replay command line
that selects the same entities ({ "command", "collection_id", "env", "note" }),
or null with cli_reason. A command line never holds a path: it reads the
collection through $AUDIT_COLLECTION, which you set to that collection's
directory, and it reads the files as they are now, so it agrees with the
snapshot while nothing has been written since the pin. Stories have one
(without run_id), and findings when the filter is a severity floor and
episode kinds over the replay's findings only.
GET /api/v1/audit/collections¶
Purpose: the configured evidence collections, by id, and whether each can be read now.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "collections": [{ "id", "available", "reason", "files" }], "count" } |
reason is SOURCE_MISSING when the directory cannot be read |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
POST /api/v1/audit/snapshots¶
Purpose: pin a collection as it is now: every file's size and SHA-256, the
active audit.log's complete lines (a partial last line is reported as
torn_bytes and left out), the engine runs, the receipt-time extent, and per
analysis whether the evidence supports it. The id is derived from that
content: pinning an unchanged collection again returns the same snapshot.
Pinning also queues the snapshot's prepare job (prepare, see
POST /audit/jobs), which builds the read models every other read needs, in
the worker process and never in the gateway. generation is null until that
job has published; until then every read answers 409 NOT_PREPARED with its
job_id. GET /audit/snapshots/{snapshot_id} returns the same descriptor with
the published generation and the latest prepare job.
symbols lists every symbol a priced record names, with the
tick_decimals its records state (null when none does).
The source catalogue:
files: each audit file pinned, with itsday(null for the active file) andtorn_bytes(a partial last line of the active file, left out).runs: each engine run, numbered asrunon/audit/events(0, then +1 at each latersystem.startup), with itsrun_seqandstarted_ts(null when the records begin without a startup), first and last receipt time,records,with_envelopeandordering:eseq(every record carries the engine's sequence),legacy(none does) ormixed.days: each trading day the files or the manifest know of, asretained(archived and entered in the manifest),unmanifested(archived, no entry),unsealed(open day parts),retired(removed by retention, by tombstone) ormissing(entered, but its archive is gone), with its files andcontent_okfor an archived day.
manifest is the evidence manifest (audit/manifest.jsonl) as pm-audit-cli
verify checks it when pinned: state is absent, verified or failed;
chain_ok (the hash chain links) and content_ok (every current day
matches its archive) are separate results, null without a manifest; each of
problems has its day and kind (chain or content); with its entry
count, head_sha256 and checked_at. anchored is always false in this
release: no copy of the head kept elsewhere is checked, so verified shows an
edited entry but not a rewritten chain ("checked, unanchored"), and anchor
is null. A retired day is verified, not a failure. The head is part of the
snapshot id.
A pm-sim-forensics report in forensics/ beside the collection (the
tool's default --out) is pinned too: copied, hashed (the hash is part of
the id) and described in forensics (hash, size, tool version, trade cut,
checks per status, every input it read, and whether its audit inputs are
exactly the snapshot's files: inputs_match, differing). The forensics
capability is available only for a matching report; otherwise its reason is
NOT_ATTACHED, REPORT_UNREADABLE (forensics: null) or
DIFFERENT_INPUTS.
gaps is the gap map: each break of the engine-wide sequence (eseq)
within a run, as gap (values skipped: missing messages lost) or
discontinuity (repeated or decreasing), with after_eseq, next_eseq,
the receipt times either side and the file/line of the record after it.
topics counts the lost messages per topic when every one is accounted for
by a later message on its topic whose own seq jumped across that gap and
no other; otherwise it is null, the scope is unknown, and affects lists
every capability that depends on a whole trail (stories, causality,
book, rerun, queue, forensics). A known scope still affects a
re-run and an exact queue.
eligibility says whether the trail can be re-run (rerun) and an exact
queue computed (queue, which needs the re-run), by pm-audit-replay
rerun's own rules. Each of prerequisites, in checking order, is met,
missing or unknown (the records cannot show it), with detail and where
it first fails (at, file, line): sequenced (every record carries the
engine's sequence section), engine_start (the trail begins at an engine
start), run_config (every run's system.startup carries its
configuration), whole_sequence (the engine-wide sequence never jumps within
a run) and recorder_continuous (pm-audit never restarted while the engine
published). earliest_missing is the one that fails first in the trail. The
rerun and queue capabilities give its reason: NO_SEQUENCE,
NO_ENGINE_START, NO_RECORDED_CONFIG, SEQUENCE_GAP or RECORDER_RESTART.
sim_context is the simulator's history (market_sim_news.db beside the
trail) when there is one, pinned as context: copied, hashed by its rows (the
hash is part of the snapshot id), with its counts, its extent on the
simulator's clock, evidence: false and the clock offset to the engine:
measured from the engine session.state messages pm-market-sim recorded
receiving (engine_observations) and the trail holds, the median of the
differences, with half their spread plus a millisecond as uncertainty_ns;
measured: false, NO_CO_OBSERVED_EVENTS when no record is observed on
both clocks (an older database). It turns the sim_context capability on; without it the reason is
NOT_ATTACHED.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
collection_id |
Str |
yes | The collection, by id. No other field is accepted |
Reply
| Status | Shape | Meaning |
|---|---|---|
201 Created |
{ "snapshot_id", "generation", "prepare", "collection_id", "created_at", "entries", "first_ts", "last_ts", "files", "runs", "days", "capabilities", "symbols", "manifest", "forensics", "gaps", "eligibility", "sim_context" } |
The snapshot's descriptor; each capability is { "available", "reason", "detail" } |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A query parameter, path value or body field is malformed (limit out of 1-1000, a cursor from another snapshot or filter, an unknown field); field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_COLLECTION |
404 |
No collection with this id |
AUDIT_SOURCE_UNAVAILABLE |
503 |
The collection's directory does not exist (SOURCE_MISSING) |
GET /api/v1/audit/snapshots/{snapshot_id}¶
Purpose: a snapshot's descriptor, as POST /audit/snapshots returned it.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes (path) | The snapshot |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
as POST /audit/snapshots |
The descriptor |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A query parameter, path value or body field is malformed (limit out of 1-1000, a cursor from another snapshot or filter, an unknown field); field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
GET /api/v1/audit/snapshots/{snapshot_id}/coverage¶
Purpose: what can be trusted in a snapshot, as the four kinds of confidence of the Audit GUI's Integrity & Coverage workspace, each its own block and never folded into one verdict:
integrity: themanifestas pinned, the pinnedfilesanddays, the retained files now (sources:ok, orfailedwithSOURCE_MISSINGorSOURCE_CHANGED) and the latestverifyjob (verify: what it foundchangedormissing; null when none ran).stateisfailedwhen the manifest, a retained file or that verify failed;checked_unanchoredwhen they pass (no copy of the head is kept off this host, so a rewritten chain would not show);absentwithout a manifest. It is never "verified". A changed or missing retained file is reported here, not raised: every other read answers503then.coverage: extent,runs, the gap map (gaps, as on the descriptor),torn_bytes, andevidence: per evidence code of the replay (ESEQ_GAP,ESEQ_DISCONTINUITY,SEQ_GAP,RECORDER_RESTART,RUN_SEQ_CHANGE,CONFIG_NOT_RECORDED,ENVELOPE_MISSING,LATE_ARRIVAL,PARSE_FAILURE,UNKNOWN_TOPIC,UNKNOWN_ENUM,TICK_SCALE_UNKNOWN) itscount(zero is a measured zero) andfirstoccurrence.links: link confidence as the replay states it (by_confidence:RECORDED,CERTAIN,STRONG,HEURISTIC,NONE), and how many records carry a causal envelope.behaviour: behavioural strength: available once ascanhas succeeded (detailnames the scan, its profile and how many detectors completed), elseavailable: false,reason: NO_SCAN.
Also clocks (CLOCK_SKEW, CLIENT_CLOCK_ABSURD, counted as evidence
is), eligibility (as on the descriptor) and index: the read model that
answered, what built it (built_at, records, detection, version,
rules_version) beside this gateway's (current_*), stale with
stale_reason when they differ (rebuild with prepare and force), and
the latest prepare job. A view names the generation it opened on: a
rebuild never moves it, and current_generation says a newer one exists.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes (path) | The snapshot |
generation |
Int |
no | The read-model generation a view opened on (default: the current one) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "current_generation", "integrity", "coverage", "links", "behaviour", "clocks", "eligibility", "index", "reproduce" } |
The four kinds of confidence, eligibility and the read model |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
generation below 1, or another malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
That generation was replaced and removed |
GET /api/v1/audit/events¶
Purpose: the snapshot's records in canonical order (engine restart epoch
run, then the engine's sequence), each with its key, both clocks' raw
values (receipt_ts/receipt_ns, the payload's *_ns fields as strings),
every price with its recorded tick_decimals, and its source file and
line.
A next_cursor carries the read-model generation it was issued from: a
rebuild (prepare with force) never moves a listing onto new rows. The
current and the previous generation are kept; a cursor into an older one is
409 GENERATION_EXPIRED.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
topic |
Str |
no | Topic prefix, e.g. trade.executed |
symbol |
Symbol |
no | Records of this symbol |
gateway |
GatewayId |
no | Records of this gateway: its actor, gateway id, or a trade's buyer or seller |
order_id |
Str |
no | Records naming this order |
q |
Str |
no | A typed filter (see Filters above) |
limit |
Int |
no | Page size, 1-1000, default 100 |
after |
Cursor |
no | The previous page's next_cursor, with the same snapshot and filters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope (events) + snapshot_id, generation, filter, total, reproduce |
One page of records, from one read-model generation; each record's flags name what the replay could not (UNKNOWN_TOPIC, UNKNOWN_ENUM), highlighted, never dropped |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed parameter or cursor (field names it), or a filter that does not parse (field: "q", with clause and suggestions) |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/stories/{entity_kind}/{entity_id}¶
Purpose: pm-audit-replay's story of one entity: its episodes and those
within depth links, every fact narrated (beats[].text), every link with
its confidence (RECORDED, CERTAIN, STRONG, HEURISTIC, NONE), and the
findings on them with their lane. A story never crosses into another engine
run.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
entity_kind |
Str |
yes (path) | order, trade, quote, oco, combo or command |
entity_id |
Str |
yes (path) | The id; an unambiguous prefix is accepted (the reply names it in full) |
snapshot_id |
Str |
yes | The snapshot |
run_id |
Int |
no | The engine restart epoch (run on /audit/events), required when the id appears in several |
depth |
Int |
no | Links to follow, 0-3, default 2 |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "entity_kind", "entity_id", "run_id", "depth", "episodes", "beats", "links", "anomalies", "reproduce" } |
The story, in pm-audit-replay --format json's vocabulary |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A query parameter, path value or body field is malformed (limit out of 1-1000, a cursor from another snapshot or filter, an unknown field); field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
No episode for this id in the snapshot |
AMBIGUOUS_ID |
409 |
The prefix matches several ids; matches lists them, more when there are others |
AMBIGUOUS_RUN |
409 |
The id appears in several runs; runs lists them |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/findings¶
Purpose: the replay's findings, worst first, each in its lane: evidence
(the trail is incomplete here: gaps, restarts, missing envelopes or
configuration), consistency (recorded facts break an exchange invariant),
operations (participants, configuration, infrastructure). Codes and
severities are the replay's own; window-edge findings such as
TERMINAL_MISSING keep info. lanes counts every finding per lane; the
behaviour lane counts the candidate groups of the latest succeeded
scan's completed detectors, and its detail names the scan and how many
of its rules completed. Without a scan it is available: false with
reason: NO_SCAN, and when none of its detectors completed
NO_COMPLETED_DETECTOR: never zero. Its
candidates are a scan's, not the replay's findings: they are read with
GET /api/v1/audit/behaviour, and lane=behaviour here is a 400.
A matching pm-sim-forensics report (see POST /audit/snapshots) adds its
checks to the consistency lane as origin: "forensics",
code: "SIM_FORENSICS" rows: FAIL as error, ERROR (the check itself
broke) as warn, SKIPPED (its data was absent) as info, each with
check (id, oracle, title, status, violations, note, samples,
and scope: the stores it reads and the trade cut) and no episode, time or
source. They sort after the replay's findings of the same severity. PASS
and INFO checks are never findings; forensics.statuses counts every
check. A report on other inputs is not merged (forensics.reason:
DIFFERENT_INPUTS).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
lane |
Str |
no | evidence, consistency, operations or behaviour |
severity |
Str |
no | info, warn or error: that severity or worse (severity>=) |
code |
Str |
no | Only this finding code |
q |
Str |
no | A typed filter (see Filters above) |
limit |
Int |
no | Page size, 1-1000, default 100 |
after |
Cursor |
no | The previous page's next_cursor, with the same snapshot and filters |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope (findings) + snapshot_id, generation, filter, total, rules ({ "detection", "rules_version", "version" }), lanes (every finding, whatever the filter), forensics ({ "available", "reason", "detail", "statuses" }), reproduce |
One page of findings, from one read-model generation; each with its pos (its place in the snapshot's ordered findings), its episode's symbol and gateway, and recurrence (findings of its code) |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed parameter or cursor (field names it), a filter that does not parse (field: "q", with clause and suggestions), or lane=behaviour (field: "lane": read GET /behaviour) |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/findings/{pos}¶
Purpose: one finding (pos on /audit/findings) and its evidence card, the
same for a code wherever it is shown:
claim: what the finding states, in plain language;not_established: what it does not show;counter_explanations: the strongest other explanations to rule out, especially window edges, lost records, clocks and system-driven cancellations. For a consistency finding on a snapshot with engine-wide sequence gaps, those come first: an absent message inside a proven gap is not an engine defect;rule: code, lane, severity, what itmeasured(its detail), the detection settings, index rules version and the version that built the read model; an imported check's own record incheck.
episode is the episode it is on (summary, outcome, weakest link; null for
an imported check) and sources its source lines. A position is stable
within a generation: name the generation to keep a link to the same
finding.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
pos |
Int |
yes (path) | The finding's place in the snapshot's ordered findings |
snapshot_id |
Str |
yes | The snapshot |
generation |
Int |
no | The read-model generation pos was read in (default: the current one) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "finding", "card", "episode", "sources", "reproduce" } |
The finding and its card |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A negative pos, or another malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
No finding at this position |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
That generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/market/{symbol}/heatmap¶
Purpose: displayed quantity per price level and time bin for one symbol,
from the recorded book.<symbol> observations only (depth.* carries no
levels). Each observation is valid from its receipt until the next one, a
phase change, an uncross of the symbol (auction.result), lost records or
the end of its engine run; nothing is interpolated. A cell is the level's quantity weighted by the time each
observation covered in the bin. Prices are integer ticks; levels gives
each one as money at the recorded tick_decimals. All times are epoch
nanoseconds (strings) on the receipt clock (clock: "receipt").
cadenceis measured over the whole snapshot (observations, median, shortest and longest interval within one run). Bins are never finer than the median interval:binscan be fewer thanrequested_bins.masks:gapwhere records were lost (anESEQ_GAP, from the last record before it to the first after; no cells),haltfrom the symbol's halt to its resume (the observed book keeps its cells). Each column lists the masks it touches.phasesis the session-phase band. A run's first phase comes from its STARTUP book checkpoint;phase: nullwhere neither a checkpoint nor asession.statesays.- A column with
covered_ns: "0"had no valid observation (before the first, after a phase change or uncross until the next, inside a gap, or while the engine was down).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | The symbol |
snapshot_id |
Str |
yes | The snapshot |
from |
Int |
no | Window start, epoch ns (default: the snapshot's first record) |
to |
Int |
no | Window end, exclusive (default: just after the last record) |
bins |
Int |
no | Time bins wanted, 1-2000, default 300 |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "symbol", "clock", "tick_decimals", "from_ns", "to_ns", "bin_ns", "bins", "requested_bins", "cadence", "levels", "columns", "masks", "phases", "reproduce" } |
The heatmap; each column { "start_ns", "end_ns", "covered_ns", "observations", "age_ns", "masks", "bids", "asks" } with cells as [price_ticks, qty] |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
bins out of 1-2000, a negative time, or from not before to (field: "to") |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
The snapshot holds no record of this symbol |
CAPABILITY_UNAVAILABLE |
409 |
No book observation was recorded for the symbol (NO_BOOK_OBSERVATIONS) or none states its scale (NO_TICK_SCALE) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/market/{symbol}/lifelines¶
Purpose: every admitted order and quote leg of one symbol, per engine run,
from its accepted order.ack or quote.ack to its end, clipped to the
window. end is filled, cancel.owner (no cancel_reason: the owner's
cancel, quote cancel or OCO cancel), cancel.system (with the engine's
end_reason, or an OCO sibling's), expired, open (still resting when
its run's records end) or censored (the window ends first);
start_censored is true when it was admitted before the window.
Each segment is one price (ticks), displayed quantity and state (book;
stop, held at its stop price and not shown; market, triggered to
market). An amendment, fill, iceberg refill or stop trigger starts a new
one (cause); changes at the same instant are one segment. Iceberg slices
follow the engine's rule: the next slice shows only once the shown one is
used up. Above segment_cap (5000) segments the response is
aggregated: true: lifelines is empty and levels sums the segments per
side, state and price. without_admission counts the symbol's orders with
events but no admission in their run (restored by a restart, say), which
have no lifeline. Times are on the receipt clock.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | The symbol |
snapshot_id |
Str |
yes | The snapshot |
from |
Int |
no | Window start, epoch ns (default: the snapshot's first record) |
to |
Int |
no | Window end, exclusive (default: just after the last record) |
gateway |
GatewayId |
no | Only this gateway's orders |
q |
Str |
no | A typed filter (see Filters above) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "symbol", "clock", "tick_decimals", "from_ns", "to_ns", "filter", "total", "aggregated", "segment_cap", "segments", "without_admission", "lifelines", "levels", "reproduce" } |
The lifelines, or their per-level aggregates |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A negative time, or from not before to (field: "to"); a filter that does not parse (field: "q", with clause and suggestions) |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
The snapshot holds no record of this symbol |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/market/{symbol}/book¶
Purpose: the book at the Replay cursor. It is the recorded observation of
book.<symbol> valid at at, with age_ns since it was observed and each
side best first (bids high to low, asks low to high). Each level gives
its price in ticks and at the recorded scale, and its displayed shares. An
observation is valid until the next one, a phase change, an uncross, lost
records or the end of its engine run, and is never carried past that. When
none is valid, state is ended and ended names the last observation
and what ended it (gap, phase_change, run_end, uncross). Before
the first observation, state is none. phase is the phase at at.
masks holds the gap or halt at at; a halt keeps the observed book. No
queue is implied: that is a queue job's (POST /api/v1/audit/jobs).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Str |
yes | The symbol (path) |
snapshot_id |
Str |
yes | The snapshot |
at |
Int |
yes | The cursor, epoch ns on the receipt clock |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "symbol", "generation", "clock", "source", "tick_decimals", "at_ns", "state", "observation", "ended", "phase", "masks", "reproduce" } |
The book at the cursor |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
No at, or a negative one |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
The snapshot holds no record of this symbol |
CAPABILITY_UNAVAILABLE |
409 |
No book observation in the snapshot (NO_BOOK_OBSERVATIONS), or no audit record (NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/activity¶
Purpose: the Overview's activity strip. Per time bin of the window, on the
receipt clock: orders (orders and quote legs admitted, at admission),
executions (once per trade), owner_cancels and system_cancels (at the
order's end) and rejects (order entries the engine refused), for one
symbol or every symbol. phases and masks (gaps; with a symbol, its
halts) shade it. news says whether simulator news can be marked on it:
news carries the simulator's clock, so only with a measured clock offset
(reason: CLOCK_OFFSET_UNKNOWN otherwise, NOT_ATTACHED without the
simulator database).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
symbol |
Symbol |
no | One symbol (default: every symbol) |
from |
Int |
no | Window start, epoch ns |
to |
Int |
no | Window end, exclusive |
bins |
Int |
no | Time bins, 10 to 600 (default 120) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "symbol", "clock", "from_ns", "to_ns", "bin_ns", "bins", "phases", "masks", "news", "metrics_version", "metrics", "reproduce" } |
The strip |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
bins out of range, a negative time, or from not before to |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
The snapshot holds no record of this symbol |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/flows¶
Purpose: directed flows, seller -> buyer, per gateway pair and symbol: each
pair's trades, volume (the symbol's shares), value (ticks, and money at
the recorded scale) and its share of all its seller sold (seller_share) and
all its buyer bought (buyer_share) in that symbol and window. Each
execution counts once (a self-trade once, from a gateway to itself), as in
/audit/frames's flow ring and Sankey. Nothing is summed across symbols.
gateways gives each gateway's bought and sold shares per symbol, as
maker (its resting order was hit), taker (the aggressor) or auction
(an uncross, no aggressor), and its volume_share: bought plus sold over
twice the symbol's volume.
With bucket, buckets holds the window's non-empty buckets, each with its
pairs' trades and volume.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
symbol |
Symbol |
no | One symbol (default: every symbol) |
from |
Int |
no | Window start, epoch ns |
to |
Int |
no | Window end, exclusive |
bucket |
Str |
no | 1s, 10s, 1m, 5m, 15m or 1h; at most 2,000 buckets |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "symbol", "bucket", "from_ns", "to_ns", "pairs", "gateways", "buckets", "metrics_version", "metrics", "reproduce" } |
The flows |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
An unknown bucket, more than 2,000 buckets (field: "bucket"), a negative time, or from not before to |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
The snapshot holds no record of this symbol |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/frames¶
Purpose: playback frames for one illustration of one symbol. Every frame is
a recorded event, never an invented state: one trade frame per execution in
canonical order (key as /audit/events names it, its time, seller, buyer,
quantity and price) with the state it leaves (pairs: the cumulative pair
flows; flow_ring adds each gateway's net traded in the window), and a freeze frame
(gap, halt, freeze: true) for every gap and halt in the window, which a
player never tweens across. skipped lists the idle spans (over 5 s) a
player skips, skipped_ns their total. source is recorded. Over budget
(2,000) frames the window is cut into equal buckets, one bucket frame each
(its trades, volume, first and last key, masks, state), and bucketed is
true. news_absorption places news on the engine's clock: unavailable while
the simulator's clock offset is not measured.
The replay illustrations put each frame's state in state and the kind's
facts in context:
queue_ladder: recorded level bars,context.blocks: false, the queue order not determinable. Withjob(a succeededqueuejob of the symbol's whole book) it has a block per order in priority order andsource: reproduced.layering,momentum: onegateway's live orders against the recorded book, and the trades with their aggressors.domino: stop triggers, each linked to its trade,RECORDEDwhen the trigger names it,HEURISTICotherwise.corridor: the trades and the engine's halts with its own reference and corridor. Thresholds come from the recorded configuration only.auction: the call's recorded book, the indicatives and the uncross. Without a book during the call, the indicative price alone.smp: the resting orders, the incoming order, the cancel and the configured policies.swimlane: oneorder's records between lanes, each with its own clocks. A delta is only ever between two stamps of one clock. A finding on the order is amissingframe.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
kind |
Str |
yes | flow_ring, sankey, news_absorption, queue_ladder, layering, domino, momentum, corridor, auction, smp or swimlane |
symbol |
Str |
no | The symbol (required by every kind but swimlane) |
from |
Int |
no | Window start, epoch ns |
to |
Int |
no | Window end, exclusive |
gateway |
Str |
no | layering, momentum: the gateway whose orders are followed (required there) |
order |
Str |
no | swimlane: the order, its full id (required there) |
job |
Str |
no | queue_ladder: a succeeded queue job of the symbol's whole book |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "kind", "symbol", "source", "from_ns", "to_ns", "budget", "bucketed", "frames", "skipped", "skipped_ns", "context", "reproduce" } |
The frames |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
An unknown kind, no symbol (no order for swimlane, no gateway for layering or momentum), job on another kind or not a whole-book queue job of the symbol, a window of more than 50,000 records for a replay illustration (narrow it), a negative time, or from not before to |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
The snapshot holds no record of this symbol (or order) |
UNKNOWN_JOB |
404 |
No job with this id |
JOB_NOT_SUCCEEDED |
409 |
The job has not succeeded |
CAPABILITY_UNAVAILABLE |
409 |
news_absorption without simulator context (NOT_ATTACHED) or a measured clock offset (CLOCK_OFFSET_UNKNOWN); no audit record (NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/context¶
Purpose: context attached to the snapshot that is not audit evidence: the
simulator's news events (kind=news) and true-value jumps (kind=value),
read from the copy pinned with the snapshot, with their provenance
(source, hash, the simulator's clock, evidence: false, the clock offset).
Times are on the simulator's clock. The offset to the engine is measured only
from events both clocks observed; none is recorded today, so it is not
measured, no news event has an engine-clock time (engine_ts_ns: null) and
each event's pre_publication analysis is unavailable
(CLOCK_OFFSET_UNKNOWN; with a measured offset wider than the window,
CLOCK_OFFSET_EXCEEDS_WINDOW). kind=preset (no gateway-to-preset mapping is
recorded: NO_PRESET_MAPPING) and kind=scenario_label (NOT_IN_RELEASE)
are not available. ADMIN only: the true value is ground truth.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
kind |
Str |
yes | news, value, preset or scenario_label |
symbol |
Symbol |
no | News naming it (and market-wide news); its value jumps |
from |
Int |
no | From, epoch ns on the simulator's clock |
to |
Int |
no | To, exclusive |
window |
Str |
no | The pre-publication window: 1s, 5s (default), 30s, 60s |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "kind", "provenance", "window", "news", "value_jumps", "reproduce" } |
The context |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
An unknown kind or window, or another malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
CAPABILITY_UNAVAILABLE |
409 |
No simulator context for this snapshot (NOT_ATTACHED), no preset mapping (NO_PRESET_MAPPING), scenario labels (NOT_IN_RELEASE) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/summary¶
Purpose: the snapshot at a glance. scope: records, runs, extent, the
gateways and symbols active. activity: executions (one per
trade.executed identity within its run, whatever fills and drop copies
say; duplicate_trades counts repeated identities, never counted twice),
admitted orders, quote legs (a quote is not an order), owner cancellations,
system cancellations by the engine's reason (a quote replacement and a halt
cancel stay apart), and commands per family. findings per lane (the
behavioural lane is R2's: available: false). evidence: gaps, the
manifest state and what the evidence cannot support.
The descriptive routes (summary, participants, symbols) are built
once per generation by prepare and carry metrics (each metric's label,
unit, definition, formula, denominator and policy) and metrics_version.
Quantities and values are per symbol, in its own shares and integer ticks,
and in money only at its recorded tick_decimals (null with
NO_TICK_SCALE without one); nothing is summed across symbols. A ratio
with a zero denominator is null, with its numerator.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "scope", "activity", "findings", "evidence", "metrics_version", "metrics", "reproduce" } |
The summary |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/participants¶
Purpose: one row per gateway that submitted a command, traded or had an
order admitted: commands per family, executions (a self-trade once),
orders_admitted, quote_legs, owner_cancels, system_cancels by
reason, open (still resting at the end), cancelled_order_rate (owner
cancellations over the entry cohort, every order and leg admitted in the
snapshot; censored open orders shown), message_to_trade (counted
commands: order entry, amendment, cancel, OCO, combo, quote and quote
cancel, over the executions it took part in; null with its numerator
without one), lifetime (median over ended orders, right-censored), its
symbols, and outcomes: the order outcome funnel of its order entries
(quote legs apart), submitted = rejected (per the engine's reject code)
+ admitted, and each admitted order's end once in ends (filled,
cancel.owner, cancel.system per reason, expired, open), with the
partially filled ones counted within their end. No quantity: those are per
symbol.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
counted list envelope (participants) + snapshot_id, generation, metrics_version, metrics, reproduce |
One row per gateway |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/participants/{gateway}¶
Purpose: one gateway's row and its activity per symbol, in that symbol's
shares and ticks: bought_qty, sold_qty and their value, admitted and
executed shares and fill_ratio under the amendment policy max_quantity@1
(an order's admitted shares are the largest quantity it carried, admitted or
amended up; a reduction does not shrink them).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
gateway |
Str |
yes (path) | The gateway |
snapshot_id |
Str |
yes | The snapshot |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "participant", "symbols", "metrics_version", "metrics", "reproduce" } |
The gateway |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
No activity of this gateway in the snapshot |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/symbols¶
Purpose: one row per symbol, in its own shares and price scale:
executions, volume, value and the price range (low, high, first,
last) in integer ticks and money, admitted orders and legs,
cancellations, and the gateways active in it.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
counted list envelope (symbols) + snapshot_id, generation, metrics_version, metrics, reproduce |
One row per symbol |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
CAPABILITY_UNAVAILABLE |
409 |
The snapshot holds no audit record (reason: NO_EVENTS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/episodes¶
Purpose: the replay's episodes in opening order, in its own kinds (order,
trade, quote, oco, combo, command, market_phase, session,
gateway, index, recovery, orphan), each with its summary (the
replay's narration), outcome, findings (count) and worst severity, its
weakest_link, what in its records the replay could not name (unknown),
and for an order its lifeline's side, type, end, lifetime_ns and
phase at admission (null for other kinds).
With a window (from, to) the episodes overlapping it are listed, each as
it was recorded over the whole snapshot. One the window cuts is
start_censored (it began before) or end_censored (it continues after),
never a lifecycle violation; one still open when the records end is always
end_censored. raw is the /audit/events filter with the same scope
(gateway, symbol, run and the window as receipt-time bounds) and the
clauses no raw record has (dropped): the Explorer's Raw toggle.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
q |
Str |
no | A typed filter (see Filters above) |
from |
Int |
no | Window start, epoch ns |
to |
Int |
no | Window end, exclusive |
limit |
Int |
no | Page size, 1-1000, default 100 |
after |
Cursor |
no | The previous page's next_cursor, with the same snapshot, filter and window |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
paginated list envelope (episodes, each { "id", "kind", "anchor", "actor", "symbol", "run", "opened", "closed", "opened_ns", "closed_ns", "outcome", "summary", "correlation_id", "findings", "worst", "weakest_link", "unknown", "side", "type", "end", "lifetime_ns", "phase", "start_censored", "end_censored" }) + snapshot_id, generation, filter, total, window, raw, reproduce |
One page of episodes |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed parameter or cursor, from not before to (field: "to"), or a filter that does not parse (field: "q") |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/episodes/{episode_id}¶
Purpose: one episode as /audit/episodes lists it, its own findings (code,
severity, lane, time, detail, source line) and its records in full (events,
as /audit/events gives them, in episode order, each with its role).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
episode_id |
Int |
yes (path) | The episode (id on /audit/episodes) |
snapshot_id |
Str |
yes | The snapshot |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "episode", "findings", "events", "reproduce" } |
The episode |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
No episode with this id in the snapshot |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/graph¶
Purpose: the causal neighbourhood of one episode: the episodes within
depth links of root, breadth first and at most node_cap (200), and the
links among them, each with relation, confidence, evidence and
recorded (stated by the records: RECORDED) or not (inferred by the
replay: CERTAIN, STRONG, HEURISTIC). recorded_only follows recorded
links only. Each node is an episode row with its level and more: the
neighbours left out, beyond the depth or the cap; omitted counts them all
and truncated says the cap was reached. Expand a node by asking for its
own graph.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
root |
Int |
yes | The episode to start from |
depth |
Int |
no | Links to follow, 1-3, default 1 |
recorded_only |
Bool |
no | Follow only recorded links (default false) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "root", "depth", "recorded_only", "node_cap", "truncated", "omitted", "nodes", "edges", "reproduce" } |
The bounded graph |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
depth out of 1-3, or another malformed value; field names it |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
No episode root in the snapshot |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
POST /api/v1/audit/analyze¶
Purpose: the Explorer's Pivot. One enumerated measure over the admitted
orders (order episodes that reached the book) that pass q (the episodes
grammar) in the window, grouped by up to two enumerated dimensions; no
expression or column name is accepted. Measures: orders;
owner_cancel_rate (orders cancelled by their own gateway over admitted
orders, with numerator and denominator); median_lifetime (ns, over
orders that ended). Dimensions: gateway, symbol, phase (at admission),
type, side, end, run. Each cell has keys, value, n (the rows
it is over) and drill: the /audit/episodes filter (q, with the window)
whose rows the cell was computed over, null when a key is unknown. measure
carries its definition and population; total is the population. q may
not name kind (the population is orders) nor a field a dimension groups by
with :.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
measure |
Str |
yes | orders, owner_cancel_rate or median_lifetime |
dimensions |
List[Str] |
no | Up to two, different |
q |
Str |
no | An episodes filter |
from_ns |
Str |
no | Window start, epoch ns, as decimal digits |
to_ns |
Str |
no | Window end, exclusive, as decimal digits |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "generation", "measure", "dimensions", "filter", "total", "cells", "reproduce" } |
The pivot; reproduce.api is the POST and its body |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
An unknown measure (field: "measure") or dimension (dimensions.N), too many or repeated dimensions or a dimension also filtered (dimensions), kind or an unparsable filter (q), an unknown field |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The cursor's generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
GET /api/v1/audit/market/{symbol}/quality¶
Purpose: the symbol's market quality in the window, from its recorded book observations (each valid until the next one, a phase change, an uncross, lost records or the end of its run).
coveragecuts the window once:eligible_ns(continuous trading, two-sided, outside gaps and halts) andexcluded(gap_ns,halt_ns,unobserved_ns: no valid observation,other_phase_ns,one_sided_ns), which add up towindow_ns.quoted_spreadanddepth(displayed shares withinwithin_ticksof the best on each side) are weighted by eligible time, never averaged per event;presenceis the two-sided share of the observed continuous time;phasesgives each phase's own observed time and spread.- Trades (
trades) are benchmarked from the taker's side (aggressor_side, BUY +1, SELL -1) againstmid(t-), the last eligible observation that began strictly before the trade:effective_spread= 2 * side_sign * (price - mid(t-)), and per horizonprice_impact= 2 * side_sign * (mid(t + h) - mid(t-))andrealized_spread= 2 * side_sign * (price - mid(t + h)), each per share, share-weighted and trade-weighted, in ticks and money. Auction prints are counted (auction_prints) and never benchmarked against the continuous market; a trade with no eligible mid before (no_mid_before) or after (no_mid_after), or whose horizon runs past the evidence (not_covered), is excluded and counted.
Times are on the receipt clock; metrics defines every measure.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
symbol |
Symbol |
yes (path) | The symbol |
snapshot_id |
Str |
yes | The snapshot |
from |
Int |
no | Window start, epoch ns (default: the snapshot's first record) |
to |
Int |
no | Window end, exclusive (default: just after the last record) |
horizons |
Str |
no | Comma list of 100ms, 1s, 5s, 30s, 60s (default 1s,5s) |
depth |
Int |
no | Depth within this many ticks of the best, 1-20 (default 5) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "symbol", "generation", "clock", "tick_decimals", "from_ns", "to_ns", "coverage", "quoted_spread", "depth", "presence", "phases", "trades", "effective_spread", "horizons", "metrics_version", "metrics", "reproduce" } |
The measures and their coverage |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
An unknown or repeated horizon (field: "horizons"), depth out of 1-20, a negative time, or from not before to (field: "to") |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
The snapshot holds no record of this symbol |
CAPABILITY_UNAVAILABLE |
409 |
No book observation was retained (reason: NO_BOOK_OBSERVATIONS) |
NOT_PREPARED |
409 |
The snapshot's read models are not built yet; job_id names the prepare job |
GENERATION_EXPIRED |
409 |
The generation was replaced and removed |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file the snapshot pinned is missing (SOURCE_MISSING) or changed (SOURCE_CHANGED) |
POST /api/v1/audit/jobs¶
Purpose: queue derivative work, run by the audit worker process (one at a time, started and watched by the gateway; it never runs in a request):
prepare: build the snapshot's read models (canonical events, the replay episode index, the market model) into scratch and publish them as its next generation in one step. Withoutoptions.forcea prepared snapshot answers with the job that prepared it; with it, a rebuild.verify: check every pinned file against its source now (ok,changed,missing) and the manifest and day inventory as they are now.forensics_import: check thepm-sim-forensicsreport now beside the collection against the snapshot (inputs_match, statuses). A report is attached to a snapshot by pinning it; this job does not change the snapshot. No report:unavailable(NOT_ATTACHED).export: one zip archive, downloaded fromGET /api/v1/audit/exports/{job_id}.options.formatbundletakes the basket'sitems(at most 100:order<id>:<run>,episode,findingposition,gap<run>:<eseq>,gateway). It holds the pinned descriptor, one file per item with its content and the API request that answers it again, and a Markdown summary.csvandparquettake a scope (symbol,from_ns,to_ns): the records, order lifecycles, trades and participant metrics, with adescriptor.jsonof columns, units, tick scales and metric definitions. Parquet needspyarrow, theauditextra; without it the job isunavailable(PARQUET_UNAVAILABLE).generationpins the read model; a removed one isunavailable(GENERATION_EXPIRED). Credentials, the recorded configuration text and host paths are redacted, CSV cells that would start a formula are escaped, and every archive carriesinventory.json.debrief: the session debrief, an archive like an export's, downloaded the same way. It holdsreport.mdandreport.html: the timeline, market quality per symbol, every gateway's page, and the notable episodes, each by its stated rule and linking into Market Replay. Withoptions.gatewayit holds that gateway's own page alone (gateway-<id>), every other gateway under a stable alias (Counterparty 1, ...), with no reserve or refill data and no other gateway's records.clipsadds SVG frame strips of the notable episodes under the same rules, each with the snapshot id and the source badge, marked as teaching material, not evidence.true_valueadds the simulator's true value on its own clock:unavailablewithout simulator context (NOT_ATTACHED) or for a session that did not end with its shutdown (SESSION_NOT_FINISHED).rerun: re-execute the snapshot's recorded commands through a fresh engine, in a private data directory in the job's scratch (no socket, no production state), and compare what it publishes with what was recorded.queue: over that re-run, one order's place in its level after every change (options.order), or one price level's orders in priority order (options.symbolandprice_ticks, optionallyside), or the whole book of a symbol in priority order (options.symbolalone: the queue ladder's blocks, at most 5,000 readings).anonymiserelabels the other gatewaysgateway A,B, ... and drops their order ids.scan: run a behavioural detector profile over the snapshot, or overoptions.symbol,from_nsandto_ns.options.profileis required:{ "id", "version", "detectors": { "<detector id>": { ... } } }, and every detector named gives every one of its parameters (there are no defaults): the framework'swindow_ns,min_samples,min_baseline,group_gap_nsandescalate_after(a key's groups in one scan before they are escalated), then the detector's own.*_nsparameters are decimal strings, counts integers, ratios numbers. The detectors arelayering,churn,paired_round_trips,circular_ring,self_trade_smp,price_run_reversal,momentum_ignition,stop_hunting,iceberg_pinging,breaker_gaming,auction_steering,close_window,liquidity_withdrawal,counterparty_concentration,adverse_selection,pre_publicationandlead_lag; another id is refused (field: "options.profile.detectors.<id>"). A calibrated example profile isdocs/examples/detector-profiles/classroom-r2.json; there is no default.threshold_sweep: the threshold workbench. Re-runoptions.detectorof the baseoptions.profilewith each ofvalues(2-12, distinct) of itsparameter, over this snapshot and up to 8 othersnapshots, within the scan's optional scope. Each value is a new profile version,<version>+<parameter>=<value>, with the base's other parameters. Nothing is rewritten: noscanresult changes, and the sweep adds nothing to the baseline store, so each session's baseline is its own earlier windows. A snapshot pinned with scenario labels is scored as the corpus is: each label of the detector's pattern found or missed, each group true or false; an unlabelled snapshot's groups are counted, not judged.
A snapshot the re-run cannot reproduce makes a rerun or queue job
unavailable with the earliest missing prerequisite's reason
(NO_SEQUENCE, NO_ENGINE_START, NO_RECORDED_CONFIG, SEQUENCE_GAP,
RECORDER_RESTART; RERUN_UNAVAILABLE for the re-run's own refusal), and a
queue about an order the trail does not hold, UNKNOWN_ENTITY.
An identical request while one is active returns that job. A job ends
succeeded, failed, cancelled or unavailable; a job ending other than
by succeeding publishes nothing and leaves the last generation as it was, and
its scratch directory is removed. A job whose worker died is failed
(WORKER_LOST) on the next read of it. Limits: one hour per job, 4 GiB per
worker, 512 MiB free disk for a build (DISK_LOW), TIMEOUT beyond.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
kind |
Str |
yes | prepare, verify, forensics_import, rerun, queue, export, debrief, scan or threshold_sweep |
snapshot_id |
Str |
yes | The snapshot |
options |
Object |
no | force (prepare only); for queue either order (a full order id) or symbol and price_ticks with an optional side (BUY, SELL), and anonymise. No other field is accepted |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "job_id", "kind", "snapshot_id", "options", "state", "stage", "progress", "heartbeat_at", "created_at", "started_at", "finished_at", "reason", "detail", "result_id" } |
The job (progress is { "done", "total" } once the total is known, else null) |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
An unknown kind or option, force on another kind (field: "options.force"), a queue option on another kind, a queue naming both or neither an order and a level, a scan without a profile or with an unknown detector, a missing, unknown, mistyped or out-of-bounds parameter (field names it), profile on another kind, a threshold_sweep without a profile, detector, parameter or values, a detector the profile lacks, a parameter it does not have, repeated values or a value that is not a valid parameter (field: "options.values[<i>]"), its own or a repeated snapshot in snapshots, a sweep option on another kind, an unknown field |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id, or one of a sweep's snapshots |
UNKNOWN_ENTITY |
404 |
A level's symbol the snapshot holds no record of |
GET /api/v1/audit/jobs/{job_id}¶
Purpose: a job's state (queued, running, succeeded, failed,
cancelled, unavailable), stage, measured progress, the worker's last
heartbeat_at (it beats every second while running), timestamps, and
reason when it ended other than by succeeding (WORKER_LOST, TIMEOUT,
CANCELLED, JOB_ERROR, DISK_LOW, NOT_ATTACHED, or a source reason
such as SOURCE_CHANGED). Reading a job also resolves stranded ones. Poll
it only while a job is active.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
job_id |
Str |
yes (path) | The job |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "job_id", "kind", "snapshot_id", "options", "state", "stage", "progress", "heartbeat_at", "created_at", "started_at", "finished_at", "reason", "detail", "result_id" } |
The job |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
The id is malformed |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_JOB |
404 |
No job with this id |
POST /api/v1/audit/jobs/{job_id}/cancel¶
Purpose: cancel derivative work, never an exchange order. A queued job ends
cancelled now; a running one is asked to stop and does so at its next
progress report, publishing nothing and removing its scratch. An ended job is
returned unchanged.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
job_id |
Str |
yes (path) | The job |
Reply
| Status | Shape | Meaning |
|---|---|---|
202 Accepted |
{ "job_id", "kind", "snapshot_id", "options", "state", "stage", "progress", "heartbeat_at", "created_at", "started_at", "finished_at", "reason", "detail", "result_id" } |
The job: cancelled, or asked to stop |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
The id is malformed |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_JOB |
404 |
No job with this id |
GET /api/v1/audit/exports/{job_id}¶
Purpose: a succeeded export or debrief job's archive, as application/zip. It holds
the job's members and inventory.json, which lists each member's SHA-256
and size, the redactions (credential, configuration_text, host_path,
with counts) and the truncations (what was cut, how much was kept of how
much). The archive's own SHA-256 and the member list are in the job's
result (GET /api/v1/audit/results/{job_id}). The key is sent as a header,
never in the URL.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
job_id |
Str |
yes | The export job (path) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
application/zip |
The archive |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed job id |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_JOB |
404 |
No job with this id |
JOB_NOT_SUCCEEDED |
409 |
The job is not a succeeded export or debrief |
GET /api/v1/audit/results/{job_id}¶
Purpose: a succeeded job's typed result: for prepare, the published
generation, whether an existing one was reused, and what was built
(records, built_at, detection, version); for verify, checked_at,
each pinned file's state, the manifest and days now; for
forensics_import, the report's sha256, inputs_match, differing,
statuses and the snapshot's own pinned_sha256; for rerun, the
verdict (agree, differ), each check's count and samples (E1
outputs with no recorded input, E2 differing outputs, E4 the final
book), the first_divergence, commands, book (compared or why not:
the engine book pinned with the snapshot), versions and note; for
queue, the target, the rows (position, orders and shares ahead with
their gateways; or the level's orders in priority order), the verdict
and validity. From the first divergence on the question's symbol (or an
input the re-run cannot reproduce, for every symbol) every reading and the
verdict are withheld: validity.state is invalidated, with
invalid_from and the number withheld. A reproduced queue is the re-run's,
never recorded truth past a divergence. For scan, the profile and one
entry per detector: its full detector declaration (rule, required
records, phases, order types, formulas, parameters with units, baseline,
clock, gap policy), the thresholds it ran with, the scope, its state
(completed, insufficient_data: NO_COMPARABLE_WINDOW; unsupported:
MISSING_EVENTS, TOO_MANY_WINDOWS (over 50,000), or for pre_publication
CLOCK_OFFSET_UNKNOWN, CLOCK_OFFSET_EXCEEDS_WINDOW or NOT_ATTACHED; failed:
DETECTOR_ERROR) with reason and detail, the windows (size_ns, total, eligible, evaluated,
insufficient, and excluded spans with their reason: gap, a recording
gap touches it, or partial), the number of comparisons, the
baseline's sources and sample counts (the same key's earlier windows in
this snapshot, and windows other snapshots' scans recorded that end before
this session's first record), and the candidates grouped per
key (each group's components with their inputs and evidence, and escalated when its key recurs escalate_after times; the declaration's privileged inputs, such as stop owners and iceberg refills, are operator-only), with the detector's counter_explanations (its own, then any the scope raises: recording gaps, halts). Only a
completed detector has a candidate list; no_candidates is true only
when that list is empty. For threshold_sweep, the detector
declaration, the parameter, the base (profile id, version and the
parameter's value) and one entry per value: its profile (the new
version, ready for a scan), per snapshot its state and reason, the
labelled scenario, comparisons, groups, escalated, and for a
labelled snapshot labels, found, missed, true_groups and
false_groups (null otherwise), and their totals with
sessions_not_completed. A snapshot it could not read is unavailable
with its reason (UNKNOWN_SNAPSHOT, NOT_PREPARED, a source reason).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
job_id |
Str |
yes (path) | The job |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "job_id", "kind", "snapshot_id", "finished_at", "content" } |
The result |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
The id is malformed |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_JOB |
404 |
No job with this id |
JOB_NOT_SUCCEEDED |
409 |
Not finished, or ended other than by succeeding; state and reason say how |
POST /api/v1/audit/dispositions¶
Purpose: a reviewer's disposition (design §4.3) of a finding or a
behavioural candidate: unreviewed, in_review, explained,
needs_follow_up or escalated, with a reason. It supersedes the subject's
current disposition, which is kept (superseded_by); nothing is deleted,
and explained changes no detector threshold, profile or result. The
reviewer is the calling ADMIN gateway. Review state is the Audit GUI's own
(review.db in its store), never the audit files or read models.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
subject |
Object |
yes | { "kind": "finding" or "candidate", "ref" }: a finding's ref (/findings), or a candidate's <detector>:<group id> (/results of a scan) |
state |
Str |
yes | One of the five |
reason |
Str |
yes | Why (1-2,000 characters) |
Reply
| Status | Shape | Meaning |
|---|---|---|
201 Created |
{ "id", "snapshot_id", "subject", "state", "reason", "reviewer", "at", "superseded_by" } |
The new, current disposition |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
No such finding in the snapshot, or no such candidate in a succeeded scan of it |
NOT_PREPARED |
409 |
A finding was named and the read models are not built yet |
GENERATION_EXPIRED |
409 |
The read-model generation was replaced while reading |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file went or changed since the pin |
GET /api/v1/audit/dispositions¶
Purpose: with kind and ref, one subject's current state (unreviewed
without a disposition) and its history, newest first; without, each
reviewed subject's current disposition in the snapshot (subjects).
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
kind |
Str |
no | finding or candidate, with ref |
ref |
Str |
no | The subject, with kind |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "subject", "state", "history" } or { "snapshot_id", "subjects" } |
One subject, or every reviewed one |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
AUDIT_SOURCE_UNAVAILABLE |
503 |
The snapshot's evidence went or changed |
POST /api/v1/audit/cases¶
Purpose: open a review case (design §9.8) with its title and investigation question; the calling ADMIN gateway owns it. A case is not a legal hold: preserving its evidence needs a retention policy.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
title |
Str |
yes | 1-200 characters |
question |
Str |
yes | The investigation question, 1-2,000 characters |
Reply
| Status | Shape | Meaning |
|---|---|---|
201 Created |
{ "case_id", "title", "question", "owner", "status", "created_at", "updated_at", "items", "snapshots", "notes" } |
The case, empty |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
GET /api/v1/audit/cases¶
Purpose: every case, newest first, with its title, question, owner, status and the number of items not removed.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
| none |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "cases" } |
The cases |
Errors
| Code | Status | When |
|---|---|---|
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
GET /api/v1/audit/cases/{case_id}¶
Purpose: a case: its items (each with the snapshot it comes from, who
added it, and for a finding or candidate its current disposition; a
removed item stays, with removed_by and removed_at), the snapshots its
items come from, and its notes.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
case_id |
Str |
yes (path) | The case |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "case_id", "title", "question", "owner", "status", "created_at", "updated_at", "items", "snapshots", "notes" } |
The case |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_CASE |
404 |
No case with this id |
PATCH /api/v1/audit/cases/{case_id}¶
Purpose: change a case's title, question or status (open,
closed). A closed case takes no new items or notes until it is reopened.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
case_id |
Str |
yes (path) | The case |
title |
Str |
no | 1-200 characters |
question |
Str |
no | 1-2,000 characters |
status |
Str |
no | open or closed |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
The case, as GET |
The case after the change |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_CASE |
404 |
No case with this id |
POST /api/v1/audit/cases/{case_id}/items¶
Purpose: add an evidence-basket item (order, episode, finding, gap,
gateway, with the basket's ref) or a behavioural candidate to a case,
with the snapshot it comes from, which is then linked to the case. A finding
or candidate must exist in the snapshot; the other kinds are references, as
the basket holds them.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
case_id |
Str |
yes (path) | The case |
snapshot_id |
Str |
yes | The snapshot the item comes from |
kind |
Str |
yes | One of the six |
ref |
Str |
yes | The item |
Reply
| Status | Shape | Meaning |
|---|---|---|
201 Created |
{ "item_id", "snapshot_id", "kind", "ref", "added_by", "added_at", "removed_by", "removed_at", "disposition" } |
The item |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
No such finding in the snapshot, or no such candidate in a succeeded scan of it |
NOT_PREPARED |
409 |
A finding was named and the read models are not built yet |
GENERATION_EXPIRED |
409 |
The read-model generation was replaced while reading |
AUDIT_SOURCE_UNAVAILABLE |
503 |
A retained file went or changed since the pin |
UNKNOWN_CASE |
404 |
No case with this id |
CASE_CLOSED |
409 |
The case is closed |
DELETE /api/v1/audit/cases/{case_id}/items/{item_id}¶
Purpose: remove an item from a case. It is marked removed, by whom and when, and stays in the case's record: nothing is deleted.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
case_id |
Str |
yes (path) | The case |
item_id |
Str |
yes (path) | The item |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
The case, as GET |
The case, the item marked removed |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_CASE |
404 |
No case with this id |
UNKNOWN_ITEM |
404 |
No such item, or it was already removed |
CASE_CLOSED |
409 |
The case is closed |
POST /api/v1/audit/cases/{case_id}/notes¶
Purpose: a reviewer's note on a case; the calling ADMIN gateway is its author.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
case_id |
Str |
yes (path) | The case |
body |
Str |
yes | 1-10,000 characters |
Reply
| Status | Shape | Meaning |
|---|---|---|
201 Created |
{ "note_id", "author", "body", "at" } |
The note |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_CASE |
404 |
No case with this id |
CASE_CLOSED |
409 |
The case is closed |
GET /api/v1/audit/review-log¶
Purpose: every review change, newest first: who (actor), when, what
(disposition.set, case.create, case.update, case.item_add,
case.item_remove, case.note), its target, and the state before and
after. Each change and its entry are written in one transaction. A
case's log (case_id) also holds the dispositions set on the findings and
candidates it holds or held, in their snapshots.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
case_id |
Str |
no | One case's changes |
snapshot_id |
Str |
no | One snapshot's changes |
limit |
Int |
no | Entries (1-1,000, default 100) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "entries" } |
The changes |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or body |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
GET /api/v1/audit/behaviour¶
Purpose: the behavioural lane (design §4.3, §9.6). scan is the latest
scan job of the snapshot, in any state; result the latest succeeded
one (null without one: NO_SCAN, never "no candidates"), whose
detectors are shown. Each detector has its detector declaration (its
rule and version), the profile id and version, every thresholds
value, its state, reason and detail, windows, comparisons,
baseline, truncated and counter_explanations, and its candidate
groups in the scope (groups, escalated, no_candidates true only for
a completed detector without one). A candidate has its ref
(<detector>:<id>, what a disposition or case names), key, the
gateways and symbols the key names, its interval, per-rule strength
and escalated (review priority), never a severity, its first 20
components (components_total), and its current disposition (null
when unreviewed). A detector lists its first 200 candidates by time;
groups counts them all, and GET /results/{job_id} has every candidate
and component.
Arguments
| Name | Type | Req | Description |
|---|---|---|---|
snapshot_id |
Str |
yes | The snapshot |
symbol |
Str |
no | Only candidates whose key names this symbol (Market's Patterns tab) |
Reply
| Status | Shape | Meaning |
|---|---|---|
200 OK |
{ "snapshot_id", "symbol", "scan", "result", "detectors" } |
The lane |
Errors
| Code | Status | When |
|---|---|---|
VALIDATION |
400 |
A malformed id or symbol |
READ_ONLY |
403 |
Read-only key |
ROLE_DENIED |
403 |
Caller is not ADMIN |
UNKNOWN_SNAPSHOT |
404 |
No snapshot with this id |
UNKNOWN_ENTITY |
404 |
A symbol the snapshot holds no record of |
AUDIT_SOURCE_UNAVAILABLE |
503 |
The snapshot's evidence went or changed |
Operational notes¶
- Read-only dashboard keys can call reference and public history endpoints, but not trading or admin write endpoints.
order_retention_secbounds the live order cache, the finished orders in the privateorders.snapshotframe, andGET /api/v1/admin/orders.market_data_cache_secbounds the market-data stream cache that backs the snapshot-on-subscribe,snapshot, andresumecontrols onWS /api/v1/ws/market-data(latestbook/depth/auctionsnapshots are kept regardless of age; only thetradestail is bounded).- WebSocket streams are specified in the WebSocket API Reference; this appendix is REST only.