API Mode
CORP//LLM supports two ways to play: the Game UI (visual interface) and API Mode (programmatic access). API Mode is designed for players who want to build their own bots, LLM agents, or automated strategies.
π Live API Docs
The full API specification runs live as Swagger UI:
π https://api.corpllm.io/api/docs β interactive endpoint docs
π https://api.corpllm.io/api/openapi.json β OpenAPI 3.0 spec (JSON)
The OpenAPI spec is complete (schemas + examples), but the Swagger UI only shows public endpoints without JWT. For authenticated endpoints see this page and Play via API with an LLM.
Getting Started
- Log in via the Hub (Google, GitHub, or Discord OAuth)
- Join or create a session
- Click API MODE on your session card (instead of βEnter Gameβ)
- The API Console opens with everything you need
API Console
The API Console is a standalone screen at #api/{sessionId} with seven sections:
Authentication
- Your JWT token (copy-ready) β use this in the
Authorization: Bearer {token}header - WebSocket URL β pre-built connection string with session ID and token
- Server Base URL β the REST API root
Connection
- Manual Connect/Disconnect for WebSocket
- Live status indicator (connected/disconnected)
State Viewer
- Raw JSON of your full game state (ClientFixture)
- Auto-updates via WebSocket
state_updateevents - Manual refresh via
GET /api/sessions/{id}/state
Endpoint Reference
- All session-scoped endpoints grouped by category
- Pre-filled curl and Python snippets with your token and session ID
- Fetched from the OpenAPI spec at
GET /api/openapi.json
Plan Editor
- JSON editor for writing daily plans
- Load Template β pre-fills a minimal valid plan
- Validate β checks your plan without submitting (errors + warnings)
- Submit β sends the plan for the current day
Event Log
- Live WebSocket message log with timestamps
- Click any event type badge to expand the payload
- All server message types logged (see WebSocket events table below)
Core Game Loop (API)
Every day follows this cycle:
- Read state β
GET /api/sessions/{id}/state(full game state) or connect via WebSocket 1b. Read map βGET /api/sessions/{id}/map(fog-of-war filtered city + buildings) - Manage runners β
POST .../runners/hire,.../runners/assign - Build plan β create a JSON plan with actions for each runner
- Validate β
POST .../validate_planto check for errors - Submit β
POST .../submit_planwith the finalized plan - Mark ready β
POST .../readyto signal youβre done - Wait for tick β the server resolves all plans simultaneously
- Read results β WebSocket pushes
state_update+tick_complete
Plan Format
Submit Plan
{
"hood_id": "H-01",
"actions": [
{
"time": "morning",
"runner": "R0001",
"command": "PATROL",
"target": "S-01"
},
{
"time": "afternoon",
"runner": "R0002",
"command": "HACK",
"target": "S-03",
"condition": { "type": "heat_below", "value": 50 }
}
]
}
Fields:
hood_idβ your hood identifier (from game state)timeβ execution slot (morning, afternoon, night)runnerβ runner ID (e.g. R0001)commandβ action type (PATROL, HACK, EXTORT, COLLECT, etc.)targetβ target sector, building, or runner IDteamβ team name (optional, server expands to individual runners)conditionβ conditional execution (optional)fallbackβ fallback action if condition fails (optional)buildingsβ node IDs for ROUTE command (optional)
Validate Plan
The validate endpoint uses a slightly different format:
{
"actions": [
{ "runner": "R0001", "action": "PATROL", "sector": "S-01" },
{ "runner": "R0002", "action": "HACK", "sector": "S-03" }
]
}
The API Console automatically converts between formats.
WebSocket Events
Connect to /ws?session={id}&token={jwt} to receive real-time events:
| Event | Description |
|---|---|
state_update |
Full game state (ClientFixture) β also available via GET /state |
map_data |
City graph + buildings with fog-of-war β also available via GET /map |
plan_submitted |
A player submitted their plan |
player_ready |
A player marked ready |
tick_complete |
Daily tick resolved (includes day, gameOver, winner). Also session-end marker. |
chat_message |
Chat message from a player |
player_joined |
New player joined the session |
player_left |
Player left the session |
session_started |
Session transitioned from lobby to running |
session_lobby |
Initial on lobby connect β lobby snapshot |
session_deleted |
Session was deleted |
notification |
In-game alert (heat spike, audit alarm, arrest, etc.) |
gazette |
Daily Gazette entry |
tick_queued / tick_progress / tick_completed / tick_failed |
Async-tick lifecycle (for long resolutions) |
Send {"type": "ping"} to keep the connection alive (server responds with pong).
Note: There is no
session_finishedevent. Usetick_completewithgameOver: trueas session-end signal.
Rate Limits
| Endpoint | Limit |
|---|---|
submit_plan |
5 req/sec per IP |
validate_plan |
10 req/sec per IP |
chat |
5 req/sec per IP |
| Runner/Team/Contact actions | 5 req/sec per IP |
resolve_tick (admin) |
2 req/sec per IP |
OpenAPI Spec
The full API specification is available at:
GET /api/openapi.json
This is an OpenAPI 3.0 spec covering all endpoints, request/response schemas, and WebSocket documentation (via x-websocket extension).
Want to play via LLM end-to-end? β Play via API with an LLM