Skip to main content

Patch Market Status

Description

Transition a spot market between listed, halted, and delisted states.

Admin only. Requires the ADMIN_API_KEY environment variable to be set on the server and passed as X-API-Key in the request header.

Critical — delist behavior: Setting status="delisted" first drains the order book (cancels every resting order with refund) via a cancel_market engine call, and only then flips the status in the database. This ensures all locked balances are returned to users before the market is marked terminal. After delist, any new order placement is rejected with 410 MARKET_DELISTED. This operation is irreversible — there is no transition back from delisted.

See Market Status enum for the full state table.

HTTP Request

PATCH /admin/spot/markets/:id/status (X-API-Key: ADMIN_API_KEY)

:id is the market identifier (e.g. DFUSDT). Case-sensitive.

Weight

0 — admin endpoints have no weight limit. Each market mutation pings the engine with a ReloadMarket command so the in-memory MarketCache picks up the change without restart.

Request Parameters

NameTypeRequiredDescription
statusENUMYESTarget market status. Must be one of listed, halted, delisted. See Market Status.

Response Example

200 OK

{
"ok": true,
"id": "DFUSDT",
"status": "halted"
}
FieldNotes
okAlways true on success.
idThe market id that was updated, echoed back.
statusThe new market status as applied.

Error Responses

HTTPerrorWhen
400INVALID_STATUSstatus is not one of listed, halted, delisted.
500DB_ERRORUnexpected Postgres error during the update. Investigate server logs.

Full list: Error Codes.

Code Examples

cURL

ADMIN_API_KEY="your_admin_api_key"
MARKET_ID="DFUSDT"

# Halt a market (pause trading, resting orders stay on the book)
curl -s -X PATCH "https://api-sepolia.p99.world/api/v1/admin/spot/markets/${MARKET_ID}/status" \
-H "X-API-Key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"status": "halted"}'

# Delist a market (drains the book first, then marks terminal)
curl -s -X PATCH "https://api-sepolia.p99.world/api/v1/admin/spot/markets/${MARKET_ID}/status" \
-H "X-API-Key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"status": "delisted"}'

Python

import requests

ADMIN_API_KEY = "your_admin_api_key"
BASE_URL = "https://api-sepolia.p99.world/api/v1"

def set_market_status(market_id: str, status: str) -> dict:
r = requests.patch(
f"{BASE_URL}/admin/spot/markets/{market_id}/status",
json={"status": status},
headers={"X-API-Key": ADMIN_API_KEY, "Content-Type": "application/json"},
timeout=10, # delist may take longer due to book drain
)
r.raise_for_status()
return r.json()

# Halt trading
result = set_market_status("DFUSDT", "halted")
print(result["ok"], result["id"], result["status"])

# Delist (irreversible — drains book first)
result = set_market_status("DFUSDT", "delisted")
print(result["ok"], result["id"], result["status"])