Skip to content

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’s resource — are the strings the app stores, sent and taken as they are. Upload files to files/image, files/video and files/floor rather than writing them by hand.
  • gridType and gridStyle must 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 are 422.
  • A body without a list keeps it, and [] empties it. So PATCH { "gridSize": 70 } never touches the tokens, and a map read and sent back unchanged rewrites nothing. A merge patch’s null removes 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-Match with the ETag you read: the map’s version covers its tokens, so a token moved in the meantime makes the write 412 rather 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) and controlledBy, an area effect’s source, and the map’s fog, canvas, snapshot and version. A token’s image, entityId, player and path and a light’s sight are read-only views of other state.
  • A token’s, tile’s, area effect’s or aura’s asset is 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.

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 id is the object’s; a new object always gets a new one.
  • The server’s fields are kept: a token’s combatant and controlledBy, an area effect’s source. Read-only views — a token’s image, entityId, player, path, trackingId, a light’s sight — are ignored.
  • A token’s combatant follows its label, role and hidden.
  • A tile’s light is 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 asset is its own copy, edited inline. assetId takes an asset of a module, campaign or the library and copies it in, file included, as picking it in the app does; null clears the artwork. An id that names no such asset is 422, and assetId on a light, marker or measurement is 400. The file of the copy is uploaded to files/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.