Admin routes let operators provision traders, inspect exchange state, broadcast messages, and control trading globally. All admin endpoints require a bearer token configured at startup.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jamxu88/exchange/llms.txt
Use this file to discover all available pages before exploring further.
Environment configuration
The exchange process reads its configuration from environment variables at startup. All variables have defaults.| Variable | Default | Description |
|---|---|---|
BIND_ADDR | 0.0.0.0:8080 | TCP address to bind the HTTP server to |
ADMIN_API_TOKEN | local-admin-token | Bearer token required for all admin endpoints. Change in production. |
STORAGE_BACKEND | in_memory | in_memory or postgres. Use postgres for durable persistence. |
DATABASE_URL | postgres://exchange:exchange@localhost:5432/exchange | PostgreSQL connection string. Only used when STORAGE_BACKEND=postgres. |
WS_BROADCAST_BUFFER | 1024 | Number of in-flight broadcast messages per channel before receivers lag. Increase for high-throughput markets. |
PER_USER_REQUESTS_PER_SECOND | 100 | Per-user rate limit for authenticated REST routes. |
POSTGRES_WRITE_BATCH_SIZE | 128 | Maximum operations per PostgreSQL write batch. |
POSTGRES_WRITE_FLUSH_INTERVAL_MS | 25 | How often (in ms) the background writer flushes pending operations. |
POSTGRES_WRITE_QUEUE_CAPACITY | 4096 | Depth of the background writer queue. Writes block when the queue is full. |
POSTGRES_WRITE_RETRY_BACKOFF_MS | 250 | Backoff (in ms) between retries after a flush failure. |
RUST_LOG | exchange=info,tower_http=info | Log filter. Use exchange=debug for verbose output. |
Admin authentication
Every admin request must include theADMIN_API_TOKEN value set at startup as a bearer token:
ADMIN_API_TOKEN environment variable when the exchange process starts. There is no way to rotate it without restarting the process.
User provisioning
Provision a trader
UsePOST /api/v1/admin/users to create a new competition trader. Each provisioned user receives a unique API key used for all subsequent trader-facing authentication.
Receive the trader profile
The response includes the
trader_id, username, generated api_key, and created_at timestamp:409 Conflict.
Reset all users
POST /api/v1/admin/users/reset clears all user positions, open orders, and fills. User accounts and API keys are preserved — only trading state is erased.
resync_required system event after the reset.
Exchange state inspection
GET /api/v1/admin/state returns a full snapshot of the exchange: current trading controls, all market definitions, recent admin messages, and persistence backend status.
Trading control
Trading can be enabled or disabled globally. When trading is disabled, new order submissions are rejected. Orders that are already in-flight at the moment trading is stopped still process normally.Start trading
Stop trading
ExchangeControls object:
Admin messages
Admin messages can be broadcast to all connected traders or targeted at a specific username. Delivered messages appear asadmin_message events on connected WebSocket clients.
Send a message
POST /api/v1/admin/messages accepts the following fields:
| Field | Type | Description |
|---|---|---|
target_username | string | null | Target a specific trader by username, or null to broadcast to all. |
market | string | null | Optional market context (e.g. "BTC-USD"). |
level | string | Severity: info, warning, or critical. Required. |
title | string | null | Optional short title for the message. |
body | string | Required message body. |
target_username are routed only to that trader’s WebSocket session. Broadcast messages (where target_username is null) are delivered to all connected clients.
Retrieve recent messages
AdminMessageEntry objects in reverse-chronological order.
Bulk config load
POST /api/v1/admin/config/load applies a complete exchange configuration — trading controls and all market definitions — in a single call. This is the recommended way to initialise the exchange before a competition round.
controls and the full list of resulting markets. If trading_enabled is omitted, the existing value is preserved.
Leaderboard
GET /api/v1/admin/leaderboard returns the full leaderboard ranked by marked net PnL. Unlike the trader-facing leaderboard, this endpoint has no rate limiting and returns all traders.
reference_price as a fallback.