Files
Part of the Server API — not a stable public interface yet; see the note there.
A field that holds a file has an address of its own under its item:
GET /api/{collection}/{id}/files/{field} |
The file |
PUT /api/{collection}/{id}/files/{field} |
Stores a new file in the field |
DELETE /api/{collection}/{id}/files/{field} |
Empties the field |
| Collection | Fields |
|---|---|
modules, campaigns |
image, banner — images |
assets |
resource — an image or a video |
maps |
image, floor — images; video — a video |
tokens, tiles, area-effects |
asset — the object’s own artwork: an image or a video |
| entity collections | image, token — images |
The body of a PUT is the file’s bytes, and its name is suggested in Content-Disposition:
curl -X PUT http://192.168.1.20:8080/api/assets/A1/files/resource \ -H "Authorization: Bearer $KEY" \ -H 'Content-Disposition: attachment; filename="Wooden Door.png"' \ --data-binary @wooden-door.pngOr choose the path yourself:
curl -X PUT "http://192.168.1.20:8080/api/assets/A1/files/resource?path=doors/oak/wooden-door.png" \ -H "Authorization: Bearer $KEY" --data-binary @wooden-door.png- The format is read from the bytes, not from
Content-Typeor the name: PNG, JPEG, GIF or WebP images, MP4 or MOV videos. Anything else is415, and so is a video sent to a field that takes images. Convert WebM to MP4 first, or import it in the app. - The server names the file: the suggested name made address-safe (
wooden-door.png), or the item’s slug without one, with the extension the bytes call for.filename*(RFC 5987) is read for names beyond ASCII, and any folders in the name are dropped. - A file is never overwritten: a taken name gets a number (
wooden-door-2.png), even when it is the field’s own file, since browsers keep artwork by its address. ?path=chooses where the file goes instead, relative to the container’s folder, and is stored as given —Content-Dispositionand the field’s usual folder are ignored, and folders are made as needed. It must stay inside the folder (no leading/, no.., no backslash or colon), have no hidden (.git), empty or space-padded parts, and end in an extension the bytes match:.png,.jpgor.jpeg,.gif,.webp,.mp4,.mov(422). Encode spaces as%20.- A chosen path that already holds the same bytes is reused, so a script syncing a folder of
artwork can run again; one holding anything else is
409— choose another path, or leavepathout to let the server name the file. - Assets, maps and map objects’ artwork go at the top of their container’s folder; an entity’s
files in its kind’s folder (
monsters/goblin-token.png). - A token’s, tile’s or area effect’s
assetis its own copy of its artwork. An upload creates the copy when the object has none — named after the object — or replaces its file;DELETEdeletes the copy, so a token shows its entity’s art again. To use artwork from a module’s assets instead, sendassetId. - A map’s
imageorvideosets itswidthandheightfrom the file. A map’s files may be up to 150 MB, every other upload 50 MB. - An image larger than 4096 pixels on a side (8192 for a map), or a file that can’t be read as
what it starts like, is
422. An asset sent a video becomes avideoasset, and one sent a GIF ananimatedImage. - The file the field held before is deleted when nothing else uses it.
PUTandDELETEanswer the item with its newETag, and honourIf-Match. An item without the field is404, as is aGETof an empty field, and aGETof an item the client may not see. The file itself stays at its own address, which isn’t checked.
A container’s folder
Section titled “A container’s folder”Pages, and entities’ text, link images by a path relative to their module’s or campaign’s folder
(), not through a field. Those files go to the folder itself:
PUT /api/modules/{id}/files?path=… |
Stores a file at that path in the module’s folder |
GET /api/modules/{id}/files |
Lists the files in the folder |
The same for /api/campaigns/{id}/files.
curl -X PUT "http://192.168.1.20:8080/api/modules/M1/files?path=images/cave.png" \ -H "Authorization: Bearer $KEY" --data-binary @cave.png{ "path": "images/cave.png", "url": "/modules/M1/images/cave.png" }pathis required: it is where the file goes and what a page links. It is checked as?path=is above, and the bytes as any upload’s — images and videos only, so no script or stylesheet can be uploaded this way.201with the file’s address inLocationwhen the upload wrote the file;200when the path already held the same bytes;409when it holds anything else. A file is never overwritten.urlis where the web server serves the file, outside/api. A page in the container linkspath, which resolves to the same file in the app and in a browser.GETanswers{ entries, total }, each entry{ path, url, size, modified }, by path, paged withoffsetandlimit. Hidden files and folders are left out; every other file is listed, whatever its type. The list names the files of hidden content too, so it needs full access: a player or a guest is refused (403,401).- There is no
DELETE: nothing records which page or entity links a file, so the server can’t tell whether one is still used. Remove files in the Files app. - Uploading needs
write, as every write does. MCP agents upload here over REST too.

