Skip to main content

Admin API Documentation

Administrative endpoints for managing Hyperscape server deployments.

Authentication

All admin endpoints require authentication via the x-admin-code header:
Set ADMIN_CODE in your environment variables or .env file.

Graceful Restart

POST /admin/graceful-restart

Request a server restart after the current duel ends. Enables zero-downtime deployments for the duel arena stream. Headers:
  • x-admin-code (required): Admin authentication code
Response:
Behavior:
  • If no duel active (IDLE/ANNOUNCEMENT): Restarts immediately via SIGTERM
  • If duel in progress (FIGHTING/RESOLUTION): Waits until RESOLUTION phase completes
  • PM2 automatically restarts the server with new code
  • No interruption to active duels or streams
Example:
Use Cases:
  • Deploy new code without interrupting active duels
  • Update server configuration during live streams
  • Apply security patches with minimal disruption

GET /admin/restart-status

Check if a graceful restart is pending. Headers:
  • x-admin-code (required): Admin authentication code
Response:
Fields:
  • success (boolean): Request succeeded
  • pendingRestart (boolean): Whether restart is pending
  • currentPhase (string): Current duel phase (IDLE, ANNOUNCEMENT, FIGHTING, RESOLUTION)
Example:

Programmatic API

The graceful restart functionality is also available programmatically via the StreamingDuelScheduler class:

Error Responses

401 Unauthorized:
500 Internal Server Error:

Configuration

Set the admin code in your environment:
Security Notes:
  • Never commit ADMIN_CODE to git
  • Use a strong, randomly generated code
  • Rotate the code periodically
  • Store in GitHub Secrets for CI/CD deployments