Skip to main content

Overview

The Admin API provides server management endpoints for maintenance mode, live logs, and server control. All endpoints require the x-admin-code header for authentication.
Added in PR #1015 (March 12, 2026).

Authentication

All admin endpoints require the x-admin-code header:
Configuration:
Without ADMIN_CODE set, all admin endpoints return 403 Forbidden.

Maintenance Mode

Enter Maintenance Mode

Pauses new duel cycles and waits for safe deploy state. Headers:
Request Body:
Response:
Behavior:
  1. Stops new duel cycles from starting
  2. Waits for current cycle to complete
  3. Locks betting markets
  4. Returns when safeToDeploy: true
Timeout:
  • Default: 5 minutes (300000ms)
  • Returns status even if timeout exceeded
  • Check safeToDeploy field before deploying

Exit Maintenance Mode

Resumes duel cycles and betting markets. Headers:
Response:

Get Maintenance Status

Checks current maintenance mode status. Headers:
Response:
Fields:
  • active - Whether maintenance mode is active
  • enteredAt - Unix timestamp (ms) when entered, or null
  • reason - Reason for maintenance, or null
  • safeToDeploy - Whether it’s safe to restart server
  • currentPhase - Current duel phase (IDLE, FIGHTING, COUNTDOWN, etc.)
  • marketStatus - Betting market status (betting, locked, resolved, none)
  • pendingMarkets - Number of unresolved markets
Safe to Deploy Conditions:
  • active: true (maintenance mode entered)
  • currentPhase not in [FIGHTING, COUNTDOWN, ANNOUNCEMENT]
  • pendingMarkets: 0 (all markets resolved)

Logs

Get Live Logs

Fetches recent server logs from in-memory ring buffer. Headers:
Response:
Log Entry Fields:
  • timestamp - Unix timestamp in milliseconds
  • level - Log level (DEBUG, INFO, WARN, ERROR)
  • system - System name (e.g., “DuelScheduler”, “Combat”)
  • message - Log message
  • data - Optional structured data (object)
Ring Buffer:
  • Stores up to 1000 most recent log entries
  • Oldest entries discarded when buffer full
  • Configurable via LOGGER_MAX_ENTRIES environment variable

Server Control

Restart Server

Restarts the server process (requires PM2). Headers:
Response:
Behavior:
  1. Validates admin code
  2. Waits 2 seconds (allows response to be sent)
  3. Calls process.exit(0)
  4. PM2 automatically restarts the server
This endpoint requires a process manager (PM2) to automatically restart the server. Without PM2, the server will exit and not restart.
PM2 Configuration:

Duel Status

Get Duel Status

Gets current duel cycle status and leaderboard. Headers:
Response:

Error Responses

403 Forbidden

Cause: Missing or incorrect x-admin-code header. Solution: Set correct ADMIN_CODE in server .env and include in request header.

500 Internal Server Error

Cause: Maintenance mode timeout exceeded. Solution: Check duel scheduler status, ensure no stuck duels.

Usage Examples

Deployment Workflow

Log Monitoring

Health Check


Admin Dashboard

Admin dashboard UI and features

Deployment

Production deployment with maintenance mode

Configuration

Environment variables and server config

Monitoring

Health checks and alerting