Maps
Part of the Server API — not a stable public interface yet; see the note there.
/api/maps serves battle maps the same way, nested too, and in the tree like pages. The body is
the Map model exactly as archives carry it — the shape of the map in
GET /api — with moduleId and campaignId added: its grid and background
settings, and its tokens, tiles, lights, markers, measurements, area
effects, walls and drawings inline.
{ "id": "M1", "name": "Cragmaw Hideout", "slug": "cragmaw-hideout", "gridSize": 70, "image": "cragmaw-hideout.jpg", "width": 2800, "height": 2100, "tokens": [ { "id": "T1", "name": "Goblin", "reference": "/monster/goblin", "x": 350, "y": 420, "role": "hostile" } ], "lights": [], "moduleId": "6F0A…"}- Paths —
image,video,floor, an owned asset’sresource— are the strings the app stores, sent and taken as they are. Upload files tofiles/image,files/videoandfiles/floorrather than writing them by hand. gridTypeandgridStylemust be values the app knows (400).- A list the body sends replaces the stored one, matched by
id: an object whose id is on this map is updated in place, any other is created with a new id, and one the list leaves out is deleted, its own artwork with it. Two entries with one id are422. - A body without a list keeps it, and
[]empties it. SoPATCH { "gridSize": 70 }never touches the tokens, and a map read and sent back unchanged rewrites nothing. A merge patch’snullremoves the key, which keeps the list: empty it with[]. - A list sent replaces everything on the map that moved since it was read. Send
If-Matchwith theETagyou read: the map’s version covers its tokens, so a token moved in the meantime makes the write412rather than moving it back. For a single object during play, use its own address (Map objects). - Some fields are the server’s, sent and never written: a token’s
combatant(its own address, Combatants) andcontrolledBy, an area effect’ssource, and the map’sfog,canvas,snapshotandversion. A token’simage,entityId,playerandpathand a light’ssightare read-only views of other state. - A token’s, tile’s, area effect’s or aura’s
assetis that object’s own copy: edit it inline (type,parameters,components,resource); it keeps its id across writes, and a copy replaced or left out is deleted with its file when nothing else draws it.
Map objects
Section titled “Map objects”A map’s tokens, tiles, lights, markers, measurements and area effects each have an address of their own, for the edits a whole-map write is too coarse for — moving one token, adding a light.
GET /api/maps/{id}/{collection} |
A page of the map’s objects, whole |
POST /api/maps/{id}/{collection} |
Adds an object to the map: 201 + Location |
GET /api/{collection}/{id} |
The object, with an ETag |
PUT /api/{collection}/{id} |
Replaces it |
PATCH /api/{collection}/{id} |
A merge patch |
DELETE /api/{collection}/{id} |
Deletes it, its own artwork with it: 204 |
The collections are tokens, tiles, lights, markers, measurements and area-effects.
There is no list of every map’s objects: GET /api/tokens is a 404. An object follows its map’s
visibility: on a map the client may not see, it is a
404 too.
The body is the object as the map’s body carries it inline, and the same rules apply:
- The path’s
idis the object’s; a new object always gets a new one. - The server’s fields are kept: a token’s
combatantandcontrolledBy, an area effect’ssource. Read-only views — a token’simage,entityId,player,path,trackingId, a light’ssight— are ignored. - A token’s combatant follows its
label,roleandhidden. - A tile’s
lightis part of the tile, not a light of the map: it has no address of its own. - A token’s, tile’s or area effect’s
assetis its own copy, edited inline.assetIdtakes an asset of a module, campaign or the library and copies it in, file included, as picking it in the app does;nullclears the artwork. An id that names no such asset is422, andassetIdon a light, marker or measurement is400. The file of the copy is uploaded tofiles/asset.
Lists answer { entries, total } of whole objects in the map’s order, narrowed by ids and paged
by offset and limit; search, where, sort, keys and parentId are 400.
For moving a token during play, prefer the tokenMoved WebSocket event — it animates on every
connected display and respects the host’s remote-interaction setting, where a PATCH does not.

