Game
Part of the Server API — not a stable public interface yet; see the note there.
Game state
Section titled “Game state”GET /api
Section titled “GET /api”A snapshot of everything the player display needs: the current game, the loaded map, the player screen configuration, recent chat, and any tracked physical objects. This is what the web client fetches on load, before it starts following WebSocket events.
{ "version": "5.0", "build": 4212, "game": { "round": 3, "turn": 1, "started": true, "combatantId": "…", "initiativeId": "…", "resources": [ { "…": "…" } ] }, "map": { "id": "…", "name": "Goblin Cave", "…": "…" }, "screen": { "mapId": "…", "overlayType": "…", "…": "…" }, "messages": [ { "…": "…" } ], "trackedObjects": [], "paused": false}| Field | Notes |
|---|---|
version, build |
The running app’s version and build number |
game |
The primary campaign’s Game — initiative order and combat state |
map |
The Map currently on the player screen, absent if none is loaded |
screen |
Player-screen configuration — overlay, fog, table-top mode, remote interaction |
messages |
The 30 most recent Messages, oldest first |
trackedObjects |
Objects reported by object tracking |
paused |
Whether the campaign is paused |
Returns 404 when there is no primary campaign for the loaded system.
game.resources lists the loaded system’s game
resources that are visible to players, each with its
current value. The definition is resolved in, so a client never needs the system’s config.json:
"resources": [ { "id": "fear", "type": "counter", "label": "Fear", "icon": "gi-burning-skull", "min": 0, "max": 12, "value": 5 }]max and icon are absent when the system leaves them out. An image icon is a path on this
server. Resources with gm visibility are never sent, and neither is a countdown at 0. type
is counter or countdown; a client should skip a type it does not know, since later types will
share the list. The list is empty, not absent, when
the system declares no player-visible resources; older app builds leave it out entirely.
GET /api/system
Section titled “GET /api/system”The loaded game system, with every definition a client needs to render its content: entity definitions, type tables, configuration and settings. This is the largest response the API produces and is meant to be fetched once per session.
{ "id": "dnd5e", "name": "D&D 5th Edition", "config": { "…": "…" }, "settings": { "…": "…" }, "definitions": { "entities": { "monster": { "…": "…" }, "spell": { "…": "…" } }, "types": { "size": [ { "…": "…" } ] } }}See System and Entity Definition.
GET /api/clients
Section titled “GET /api/clients”The clients currently connected over WebSocket, with their addresses, so it needs write on
everything: the GM and API keys with write.
[ { "channel": 3, "address": "192.168.1.51", "name": "Ellie", "color": "#4caf50", "screenWidth": 1180, "screenHeight": 820, "runMode": "normal", "device": "iPad", "mapCenterX": 1200, "mapCenterY": 900, "mapZoom": 1.4 }]runMode is normal for a player browser; anything else marks the client as a player display,
which gets its own viewport in the app.
The game
Section titled “The game”The game being played — the loaded system’s primary campaign has one at a time, so it has no id.
GET /api/game
Section titled “GET /api/game”{ "campaignId": "5d1e…", "started": true, "round": 2, "turn": 3, "combatantId": "c41a…", "initiativeId": "9f20…", "combatants": [{ "id": "c41a…", "name": "Goblin", "label": "G1", "data": { "hp": { "current": 3, "maximum": 7 } }, "initiative": [{ "id": "9f20…", "value": 14, "order": 1 }] }], "resources": [{ "id": "fear", "type": "counter", "label": "Fear", "min": 0, "max": 12, "value": 4 }]}combatants are Combatants, hidden ones included, with
hidden: true — hiding is what the table shows, not access (see
Visibility). resources are the
game resources with their values: every one for
the GM and API keys, and only players resources for anyone else. With an ETag;
404 when no campaign is being played.
Starting combat, the next turn and the round are actions with consequences, not fields to write:
see Running the combat. GET /api is still the web client’s
whole snapshot.
POST /api/game/combatants
Section titled “POST /api/game/combatants”Adds an entity to the combat: { "entityId": "…" }, and any combatant fields to
set over what the entity gives it — its name, ranges at their start, a label (G1):
curl -X POST http://192.168.1.42:8080/api/game/combatants \ -H 'Authorization: Bearer epk_…' -H 'Content-Type: application/json' \ -d '{"entityId": "2f1c…", "hidden": true, "initiative": [{"value": 17}]}'201 with the combatant, its address in Location. A character — an entity of a standalone type —
has one combatant that keeps its state between combats, so it can be added once; a second time is
409. Anything else gets a new combatant each time.
Running the combat
Section titled “Running the combat”POST /api/game/start |
Starts combat, putting the turn order straight |
POST /api/game/stop |
Stops it |
POST /api/game/next |
The next combatant’s turn |
POST /api/game/previous |
The previous combatant’s turn |
POST /api/game/roll-initiative |
Rolls initiative for the combatants not in the turn order yet |
They do what the game screen’s buttons do, through the same code, and answer 200 with the
game, as GET /api/game does, and its ETag. No body is needed.
curl -X POST http://192.168.1.42:8080/api/game/next -H 'Authorization: Bearer epk_…'startandstopare idempotent: starting a running combat changes nothing.nextskips defeated combatants, and after the last one starts a new round — re-rolling initiative when the system rolls it every round. Status effects whose duration ended with the turn expire, as in the app.previousgoes back a turn, into the round before at its first; never before the first turn of round 1. Effects that expired stay gone.- Moving the turn of a combat that hasn’t started, or with nobody in the turn order, is
409. - Send
If-Matchwith theETagyou last read to move the turn once even if a request is sent twice — a button pressed twice, a retry: the second one is412. - They need
writeaccess. Resetting the encounter, which removes combatants and their tokens, is only in the app.
POST /api/game/end-turn
Section titled “POST /api/game/end-turn”Ends one combatant’s turn: whoever plays it saying they are done. The body names whose turn ends:
curl -X POST http://192.168.1.42:8080/api/game/end-turn \ -H 'Authorization: Bearer ept_…' -H 'Content-Type: application/json' \ -d '{"combatantId": "c41a…"}'200 with the game, as next answers it. The app decides what comes after: today the next
combatant’s turn, exactly as next.
- Only while that combatant is acting. A turn that already ended — the request sent twice, or the
GM moved the turn meanwhile — is
409, and nobody is skipped. Before combat starts it is409too. combatantIdis required, and the only key; a combatant not in the game is404.- A player may end their own character’s turn — the same rule as changing the combatant over the
WebSocket. A combatant with no entity, a
monster, needs
writeon everything. A guest can’t.
Combatants
Section titled “Combatants”GET /api/combatants/{id} |
The Combatant, with an ETag |
PUT /api/combatants/{id} |
Replaces what can be written |
PATCH /api/combatants/{id} |
A merge patch |
DELETE /api/combatants/{id} |
Takes it out of combat: 204 |
There is no list: the game holds them. The same rules as for entities apply — the
body read can be sent back, If-Match protects a write, errors are problems — with these:
idandreference(the entity the combatant stands for) are the server’s, and so are the derived keys of the body:bloodied,defeated,player,image,entityId,entityType,tokenId.dataholds the ranges the entity type declares —hpunless the system says otherwise — and nothing else. A range holds whole numbers undercurrent,maximum,temporaryandminimum. A change outside them is a422; what is stored and sent back unchanged always passes.- Effects are matched by
id: one left out is removed, one with a new or noidadded, and one that changed replaced. Linked condition flags on the entity follow. - Changing
initiativereorders the combat. - A character’s ranges are its entity’s too: a write passes them on, through the entity’s model schema when it has one.
DELETEremoves a combatant from the order. A character’s combatant, or one with a token on a map, stays, detached; anything else is deleted. One not in combat is a404.
Any client that may read reads every combatant, hidden ones too. Writes need write on
everything. A player changes their own character’s combatant over the WebSocket instead, with
updateCombatant: the same merge
patch, checked by the same rules. They end its turn with end-turn.
Messages
Section titled “Messages”POST /api/messages
Section titled “POST /api/messages”Posts a message to the shared log. The body is a Message; dice expressions in it are rolled, and the stored message — with its results and campaign attached — comes back in the response.
curl -X POST http://192.168.1.42:8080/api/messages \ -H 'Content-Type: application/json' \ -d '{"text": "The door creaks open."}'A 400 means the body did not parse as a message.

