API

Admin & kill switch

Stop everything, or pause one strategy, with an authenticated API call.

Two calls change what the engine does. Both only write a flag and a ledger event; the engine reads the flags every 3 seconds.

Enabling admin calls

Set ADMIN_TOKEN on Vercel to a random string of at least 24 characters, then redeploy:

bash
openssl rand -hex 24

Without it, or with a shorter one, every admin call answers 403 ADMIN_DISABLED. The token is compared in constant time; a wrong token answers 401 UNAUTHORIZED. Keep it secret: it controls the kill switch.

Send it as a bearer token:

text
Authorization: Bearer <ADMIN_TOKEN>

POST /admin/kill

Body: { "on": boolean, "reason"?: string (≤ 200 characters) }. Response: { "killSwitch": boolean }.

bash
# stop everything
curl -X POST https://<your-site>/api/v1/admin/kill \
  -H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
  -d '{"on": true, "reason": "Checking something"}'

# start again
curl -X POST https://<your-site>/api/v1/admin/kill \
  -H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
  -d '{"on": false}'

Within about 3 seconds every strategy stands down, every resting quote is pulled and the app's badge shows Halted. The ledger records Kill switch engaged by an operator (the reason defaults to Stopped by an operator).

Warning

If the switch was engaged by the drawdown limit and NAV is still below the limit, the next snapshot engages it again after you release it.

POST /admin/strategies/:id

Body: { "status": "running" | "paused" }. Response: { "id": string, "status": string }. Ids: harvest, hypercore-mm, montra-mm, hedge, arb.

bash
curl -X POST https://<your-site>/api/v1/admin/strategies/hedge \
  -H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
  -d '{"status": "paused"}'

A paused strategy stands down (cancels its orders) and stays paused until resumed. The ledger records Hedging paused by an operator.

On the engine's own API

With ENGINE_SERVES_API=true, the same calls work on the engine's port at /v1/admin/* and /api/v1/admin/*. They then need ADMIN_TOKEN in the engine's environment.