Appearance
File Uploads
Binary files (images, video, audio, PDFs, fonts, archives, …) are stored in fields of type Bild. They are uploaded together with the regular write request of a contribution — there is no separate upload endpoint.
Supported Routes
| Method | Path | Payload |
|---|---|---|
| PUT | /api/item/:chapter? | single object — create a contribution |
| POST | /api/item/:id | single object — complete update |
| PATCH | /api/item/:id | single object — partial update |
| PUT | /api/collection/:chapter? | array (max 50) — bulk create |
| PATCH | /api/collection/:chapter? | array (max 50) — bulk partial update |
POST/PATCH /api/collection/:any/:id are aliases of the item routes. All routes require a JWT.
Request Format
Send the request as multipart/form-data with these parts:
| Form field | Required | Content |
|---|---|---|
payload | yes | The JSON body of the request, as a string — exactly what you would send as application/json (an object for item routes, an array for collection routes). |
files | for upload / replace | The binary file. Repeat the field for several files (files, files, …). |
- Only the field name
filesis accepted for binaries; files in any other form field are rejected. - If
payloadis missing the request fails with "Multipart Uploads (form-data) require the JSON request as value of the key 'payload'"; invalid JSON fails with "Failed to parse the payload. Not Valid Json." - Requests without files can still be sent as plain
application/json. - Files are held in memory and must not exceed 1000 MB each.
- The MIME type reported by the client must be one of the allowed types; otherwise the request is rejected with
400 Invalid file type ….
Referencing Files from the Payload
The value of a Bild field in payload.fields is an array of asset operations. Each operation names an asset by its key:
json
{
"fields": {
"Image": [
{"key": "photo.jpg", "action": "upload", "captions": ["Caption", "Credit"]}
]
}
}A file part is matched by its original file name (the filename of the multipart part, e.g. what curl -F "files=@./photo.jpg" sends as photo.jpg). The match is exact and happens before sanitizing. All files of a request form one pool, so in bulk requests any item and any field can reference any uploaded file — use unique file names within a request.
Operation Properties
| Property | Type | Description |
|---|---|---|
key | string | Required. For upload: the file name of the multipart part. For all other actions: the stored key of an existing asset (as returned in key by GET). |
action | enum | upload, replace, rename, delete, duplicate. When omitted, the operation acts like rename. |
captions | array | Caption strings, one per caption variant configured on the field (caption_variants). |
replaceKey | string | replace only: file name of the multipart part holding the new binary. |
thumbnail, processed, params | — | Required for duplicate (take them from the GET output). |
src | string | Accepted and ignored — lets you send back objects as returned by GET. |
variants | array | Operations on the additional binaries of the row — only on fields with the variants option, see Variants. |
No other properties are allowed. The {data, _meta} wrapper returned by GET with meta enabled is unwrapped automatically.
Actions
| Action | Needs a file part | Effect |
|---|---|---|
upload | yes, filename = key | Stores the file and adds a new asset. |
replace | yes, filename = replaceKey | Swaps the binary of the existing asset key. The old original, thumbnail and scaled variants are deleted from S3. Captions are updated if given. |
rename | no | Sets the captions of asset key. captions is required. |
delete | no | Removes asset key and deletes its files from S3. |
duplicate | no | Copies asset key including its thumbnail and scaled variants (new keys get a <timestamp>_ prefix). Requires thumbnail, processed and params; otherwise the operation is ignored. Can be used to copy an asset from another contribution. |
On PUT (new contributions) only upload and duplicate are meaningful, since the field has no existing assets.
Keeping, Reordering and Mixing Operations
- Existing assets that are not mentioned in the field value are kept unchanged — also on
POST. To remove an asset, send an explicitdelete. - Several operations can be combined in one request and across several
Bildfields. - Newly uploaded and duplicated assets are placed before the existing ones. Existing assets are sorted by the position of their
keyin the request; to reorder a field, list all existing keys in the desired order (e.g. withrenameand their current captions). - Writes to a single item (
/api/item/...) are serialized server-side, and the field value is re-read from the database after an upload, so parallel uploads to the same field do not overwrite each other.
Variants
With "variants": true in the field configuration, a row can hold additional binaries besides its main file — e.g. a CMYK or responsive version, or a PDF next to an image. Variants have no captions; every variant is stored and scaled exactly like the main file (thumbnail and imagesize versions).
The main file stays the identity of the row: key, src, thumbnail, processed and params of a row still describe it, so clients that don't know about variants keep working. GET additionally returns a variants array per row:
json
{
"key": "photo.jpg",
"src": "…/photo.jpg",
"captions": ["Caption"],
"thumbnail": "…/thumbnail_photo.jpg",
"processed": ["…/800x0_photo.jpg"],
"params": {"width": 4000, "height": 3000, "mime": "image/jpeg"},
"variants": [
{"key": "photo-cmyk.tif", "src": "…/photo-cmyk.tif", "thumbnail": "…/thumbnail_photo-cmyk.tif.jpg", "processed": ["…/800x0_photo-cmyk.tif.jpg"], "params": {"width": 4000, "height": 3000, "mime": "image/tiff"}}
]
}Variant operations are nested in the operation of their row, under variants. Each one names a variant by key and supports these actions:
| Action | Needs a file part | Effect |
|---|---|---|
upload | yes, filename = key | Adds a variant (appended at the end). |
replace | yes, filename = replaceKey | Swaps the binary of variant key; the old files are deleted from S3. |
delete | no | Removes variant key and deletes its files from S3. |
duplicate | no | Copies variant key (requires thumbnail, processed and params). |
Variants that are not mentioned, or mentioned without an action, are kept — sending rows back as returned by GET changes nothing. On a new row (upload or duplicate of the row) variants without an action are copied, so duplicating a row or a contribution includes its variants.
A row operation that only carries variants (no action, no captions) leaves the captions untouched. Replacing the main file keeps the variants; deleting the row deletes its variants as well.
bash
# Add a PDF to an existing row and delete one of its variants
curl -X PATCH http://localhost:8080/api/item/42 \
-H "Authorization: Bearer JWT_TOKEN" \
-F 'payload={"fields": {"Images": [
{"key": "photo.jpg", "variants": [
{"key": "photo.pdf", "action": "upload"},
{"key": "photo-cmyk.tif", "action": "delete"}
]}
]}}' \
-F "files=@./photo.pdf"Fields without the variants option can't get new variants: upload, replace and duplicate variant operations are rejected. Rows without variants keep their stored data and output unchanged (no variants property).
Switching the option off is not destructive: variants stored while it was on stay in the output of their rows, are kept when rows are sent back as returned by GET, can still be deleted, and are copied when their row is duplicated. They are removed from S3 when their row or contribution is deleted. The output schema therefore always declares variants, as a required property with the option and an optional one without it.
Storage and Processing
For every uploaded file the server:
- Sanitizes the file name: accents removed, lower-cased, every character other than
a-z 0-9 - _replaced by-(e.g.Mein Foto (1).JPG→mein-foto-1.jpg). If the name already exists in the bucket, a timestamp is appended (photo_1727170000000.jpg). The resulting name becomes the asset'skey. - Stores the original in S3 under the database-specific folder.
- Creates a thumbnail
thumbnail_<key>.jpg(100 px wide JPEG). - Creates scaled variants
<width>x<height>_<key>for each entry in the field'simagesizeconfiguration (fit: inside; a width or height of0means auto). Images are auto-rotated according to EXIF orientation. Variants keep the source format, except TIFF which is converted to JPEG (.jpgappended). - Reads image metadata into
params(width,height,channels,bits,mime).
Files that are not images (PDF, video, audio, …) get a generated placeholder thumbnail, no scaled variants and empty params.
Deleting a contribution (item or bulk delete) removes all of its assets from S3.
Response
POST and PATCH return the new state of every written field in payload:
json
{
"status": "ok",
"id": 42,
"name": "My Entry",
"payload": {
"Image": [
{
"key": "photo.jpg",
"src": "https://assets.example.com/.../photo.jpg",
"captions": ["Caption", "Credit"],
"thumbnail": "https://assets.example.com/.../thumbnail_photo.jpg",
"processed": ["https://assets.example.com/.../800x0_photo.jpg"],
"params": {"width": 4000, "height": 3000, "channels": 3, "bits": "uchar", "mime": "image/jpeg"}
}
]
}
}PUT returns {"status": "ok", "id": 123, "name": "..."}; fetch the item to get the asset URLs. The collection routes return an array of these objects, one per item.
Examples
bash
# Create an entry with two images
curl -X PUT http://localhost:8080/api/item/Articles \
-H "Authorization: Bearer JWT_TOKEN" \
-F 'payload={"name": "Gallery", "fields": {"Images": [
{"key": "a.jpg", "action": "upload", "captions": ["First"]},
{"key": "b.png", "action": "upload", "captions": ["Second"]}
]}}' \
-F "files=@./a.jpg" \
-F "files=@./b.png"bash
# Replace the binary of an existing asset
curl -X PATCH http://localhost:8080/api/item/42 \
-H "Authorization: Bearer JWT_TOKEN" \
-F 'payload={"fields": {"Images": [
{"key": "a.jpg", "action": "replace", "replaceKey": "a-v2.jpg"}
]}}' \
-F "files=@./a-v2.jpg"bash
# Delete an asset — no file needed, plain JSON works
curl -X PATCH http://localhost:8080/api/item/42 \
-H "Authorization: Bearer JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"fields": {"Images": [{"key": "b.png", "action": "delete"}]}}'js
// Browser / Node 18+
const form = new FormData()
form.append('payload', JSON.stringify({
fields: { Images: [{ key: file.name, action: 'upload', captions: ['Caption'] }] }
}))
form.append('files', file, file.name)
await fetch('/api/item/42', {
method: 'PATCH',
headers: { Authorization: `Bearer ${jwt}` }, // do not set Content-Type manually
body: form
})Allowed MIME Types
image/jpegimage/jpgimage/pngimage/gifimage/avifimage/webpimage/svg+xmlimage/tiffimage/tifvideo/quicktimevideo/mp4video/webmvideo/mpegvideo/oggvideo/x-msvideovideo/x-matroskavideo/3gppaudio/mp3audio/mpegaudio/waveaudio/wavaudio/x-wavaudio/x-m4aaudio/mp4audio/aacaudio/oggaudio/opusaudio/flacaudio/x-aiffaudio/webmapplication/zipapplication/x-zip-compressedapplication/gzipapplication/x-7z-compressedapplication/pdfapplication/epub+zipfont/wofffont/woff2font/ttffont/otfapplication/font-woffapplication/font-woff2application/x-font-ttfapplication/x-font-otfapplication/vnd.ms-fontobjectmodel/objmodel/stlapplication/octet-stream