Appearance
Files API
Manage file uploads, variants, and downloads in the CMS.
Putting a file into content is a separate question from managing it - see Images versus files in a component schema for which field kind to declare, and why a crop needs format: "image".
Upload a File
Upload a new file.
Endpoint: POST /api/v1/file
The bytes can be sent two ways. Prefer multipart - base64 is ~33% larger on the wire and forces both ends to hold the whole file in memory.
| Field | Type | Notes |
|---|---|---|
title | string | Required. |
filename | string | Required. Used to derive the stored name. |
data | file or base64 | Optional. The file's bytes - a multipart part, or base64 in a JSON body. |
variants | array | Optional. See Create Variants below - same shape, created inline. |
folder | uuid or null | Optional. The folder to file it in. Absent, null or "root" all mean the top level. |
Omit data entirely to create the record without bytes and upload them later with Update a File.
Example Request (multipart, preferred):
bash
curl -X POST "https://admin.flatnode.net/api/v1/file" \
-H "Authorization: Bearer your-token-here" \
-F "title=Hero image" \
-F "filename=hero.jpg" \
-F "[email protected]"Example Request (base64):
bash
curl -X POST "https://admin.flatnode.net/api/v1/file" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{
"title": "Hero image",
"filename": "hero.jpg",
"data": "'"$(base64 -w0 hero.jpg)"'"
}'Size limits
The ceiling is 64 MB, measured on the decoded bytes, so it is the same whichever transport you use - a base64 body carries the same bytes in about a third more characters, and the limit still applies to the bytes. Going over it is a 422 naming the data field.
A request well over the limit may not get that far: the server can refuse an oversized body with a bare 413 before the API sees it, so treat 413 as the same failure without a field-level message.
File type
The stored extension and MIME type are detected from the bytes, not from filename. Uploading a PNG called invoice.pdf stores a PNG - filename only seeds the display name.
Response: 201 Created
json
{
"message": "File created...",
"data": {
"_uuid": "770e8400-e29b-41d4-a716-446655440002",
"title": "Hero image",
"caption": null,
"name": "hero",
"extension": "jpg",
"mimeType": "image/jpeg",
"byteSize": 271325,
"isImage": true,
"createdAt": "2026-11-08T09:12:44+00:00",
"updatedAt": "2026-11-08T09:12:44+00:00"
}
}extension and mimeType are resolved strings, not codes to look up.
A file created without data has no bytes yet, so extension, mimeType and byteSize are null and isImage is false until an upload replaces them.
Variants passed inline are created, but are not included in this response - call Create Variants separately afterward if you need their uuids back.
Get a File
Retrieve file metadata by ID.
Endpoint: GET /api/v1/file/{uuid}
Example Request:
bash
curl -X GET "https://admin.flatnode.net/api/v1/file/770e8400-e29b-41d4-a716-446655440002" \
-H "Authorization: Bearer your-token-here"Response: 200 OK
The same shape as the data object in the upload response above, plus a variants array - every rendition of this file, each in the shape returned by Create Variants:
json
{
"message": "found.",
"data": {
"_uuid": "770e8400-e29b-41d4-a716-446655440002",
"title": "Hero image",
"extension": "jpg",
"mimeType": "image/jpeg",
"byteSize": 271325,
"isImage": true,
"folder": "aa0e8400-e29b-41d4-a716-446655440010",
"folderPath": "Press/2026",
"...": "...",
"variants": [
{ "_uuid": "990e8400-e29b-41d4-a716-446655440004", "...": "..." }
]
}
}Download a File
Endpoint: GET /api/v1/file/{uuid}/download/{variant}
Parameters:
file- the file's uuidvariant(optional) - a FileVariant uuid (the_uuidin a Create Variants response, or animagefield'svariant_id), not a variant name/key. For a name-based lookup, use Download a Variant by Key instead.
Without variant, this does not return the original file. It always serves a fixed 300×300 square preview.jpg, auto-generated on upload - fine for a thumbnail, too small/wrong-aspect for anything else. Use "Download the Original" below for the real, unmodified upload, or create a variant for a specific resized/cropped rendition.
With variant, the bytes come back at the variant's stored size. To serve a variant at the size a layout needs, pass the same uuid to render as ?variant=.
Example Request:
bash
curl -X GET "https://admin.flatnode.net/api/v1/file/770e8400-e29b-41d4-a716-446655440002/download" \
-H "Authorization: Bearer your-token-here" \
-o downloaded-file.jpgResponse: 200 OK - file bytes with the resolved Content-Type.
Download the Original
Returns the real, unmodified bytes exactly as uploaded - what GET /file/{uuid}/download (above) does not give you.
Endpoint: GET /api/v1/file/{uuid}/original
bash
curl -X GET "https://admin.flatnode.net/api/v1/file/770e8400-e29b-41d4-a716-446655440002/original" \
-H "Authorization: Bearer your-token-here" \
-o original-file.jpgResponse: 200 OK - file bytes with the resolved Content-Type.
Render an Image On the Fly
Resize, crop or convert an image per request, without declaring anything up front. This is what a responsive srcset wants: the frontend asks for the widths its own layout needs, and the CMS never has to know the breakpoints.
Endpoint: GET /api/v1/file/{uuid}/render
| Param | Type | Notes |
|---|---|---|
w | integer | Width in pixels, 1-4000. Required unless h is given. |
h | integer | Height in pixels, 1-4000. Required unless w is given. |
fit | string | contain (default) fits inside the box; cover crops to fill it exactly and needs both w and h. |
format | string | jpg, png or webp. Defaults to the source's format. |
q | integer | Quality 1-100, default 85. For PNG it maps onto the compression level. |
variant | uuid | Render this variant of the file - an editor's crop - instead of the original. Must belong to this file. |
Giving only one of w/h scales the other to preserve the aspect ratio.
These six are the only parameters the endpoint takes. Anything else on the URL is a 422, including a misspelt variant: silently ignoring ?varient= would hand you the uncropped original with a 200, and nothing downstream would notice.
bash
curl -X GET "https://admin.flatnode.net/api/v1/file/770e8400-.../render?w=800&format=webp" \
-H "Authorization: Bearer your-token-here" \
-o hero-800.webpResponse: 200 OK - image bytes, with the rendered format's Content-Type and a long-lived Cache-Control: public, max-age=..., immutable. An X-Flatnode-Render: hit|miss header says whether this request did the work or read an earlier result.
Every parameter is bounded, and out-of-range values are a 422, not a silent clamp: ?w=9000 fails rather than quietly returning 4000px under a URL that claims otherwise. The bounds also keep the cache key space finite, since the query string is caller-controlled.
Caching
Each distinct parameter set is rendered once and written to object storage, so the second request for a given URL is a read. Combined with the immutable header, putting a CDN in front of this endpoint (see Bring your own CDN) means your origin renders each size exactly once. A statically generated site can skip the CDN and pull the sizes it needs at build time.
The cache key includes the file's current bytes, so replacing a file produces different render URLs rather than stale hits - and the old renders are discarded at the same time.
Render vs. variants
| Render | Variants | |
|---|---|---|
| Sizes decided by | the consumer, at request time | an admin or editor, up front |
| Addressed by | query parameters | a uuid, or a name (thumbnail) |
| Produced | synchronously on first request | asynchronously on a queue |
| Good for | srcset, unknown frontends | a fixed set of named crops, art-directed crops |
They compose rather than compete. A variant decides what part of the image is shown; a render decides how big. An image field's value carries the editor's choice as variant_id, and passing it to render as variant is what carries that crop into your srcset:
bash
# field value: {"id": "770e8400-...", "variant_id": "880e8400-..."}
curl -X GET "https://admin.flatnode.net/api/v1/file/770e8400-.../render?w=800&format=webp&variant=880e8400-..." \
-H "Authorization: Bearer your-token-here" \
-o hero-800.webpThe variant is sized by the same w/h/fit rules as an original, so fit=cover into a box of the crop's own ratio is a plain resize and nothing is cut twice. A variant render is cached under its own key; the variant is re-cut when the file's bytes are replaced, and its renders move with it.
Without variant, render always starts from the uncropped original - there is no "the editor's crop" default, because a file can carry any number of variants and the field value is what says which one applies.
Create Variants for a File
Request one or more resized/cropped renditions of an uploaded file.
Endpoint: POST /api/v1/file/{uuid}/variants
Request Body:
json
{
"variants": [
{ "key": "thumbnail" },
{ "crop": { "x": 0, "y": 0, "w": 1200, "h": 800 } }
]
}Each entry in variants is one of:
keyonly - looks up a named definition (crop/transform rules) registered for the project. Manage these with the/file-variant-definitionsendpoints (GET,POST,PATCH /{key},DELETE /{key}), which require thefile-variant-definitionability.croponly (nokey) - an ad-hoc pixel region{x, y, w, h}(all required), no pre-registered definition needed. Unlike the defaultpreview.jpg(always JPEG), the output format falls back to the original's own extension, so this preserves PNG transparency - useful for a specific resized/cropped rendition. For the untouched original itself, use Download the Original instead.- Both
keyandcroptogether - the crop is applied as an override on top of the named definition.
Example Request:
bash
curl -X POST "https://admin.flatnode.net/api/v1/file/770e8400-e29b-41d4-a716-446655440002/variants" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{
"variants": [
{ "crop": { "x": 0, "y": 0, "w": 1920, "h": 1080 } }
]
}'Response: 200 OK
json
{
"message": "Variants queued.",
"data": [
{
"_uuid": "990e8400-e29b-41d4-a716-446655440004",
"title": null,
"caption": null,
"name": "custom-42",
"extension": "jpg",
"mimeType": "image/jpeg",
"byteSize": 18422,
"processed": true,
"processingInstructions": { "crop": { "x": 0, "y": 0, "w": 1200, "h": 800 } },
"createdAt": "2026-11-08T09:12:44+00:00",
"updatedAt": "2026-11-08T09:12:44+00:00"
}
]
}processingInstructions is the decoded crop/transform rules this rendition was produced from, not a JSON string to parse again.
The variant is ready to download as soon as this call returns. Download it via GET /file/770e8400-e29b-41d4-a716-446655440002/download/990e8400-e29b-41d4-a716-446655440004 (the returned _uuid, not name). Omit the last segment entirely for the file's own preview rather than a variant - there is no "variant 0".
Download a Variant by Key
Endpoint: GET /api/v1/file/{uuid}/variants/{variantKey}
Looks up a variant by its key (the name on a variant created with a key, not a crop-only one - those get an auto-generated name like custom-42 and aren't reachable this way; use the uuid download route above instead).
Update a File
Update file metadata, and/or replace the file's actual bytes.
Endpoint: PATCH /api/v1/file/{uuid} or PUT /api/v1/file/{uuid}
Request Body:
| Field | Type | Notes |
|---|---|---|
title | string | Required on every call, even if unchanged. |
caption | string or null | Optional description, independent of title/filename. Omit to leave unchanged; send "" to clear it (comes back as null - the "convert empty strings to null" middleware runs before this ever reaches the controller). |
data | file or base64 | Optional. Replaces the file's bytes - see note below. Same two transports and same size limit as Upload. |
variants | array | Optional. Same shape as Create Variants; queues them the same way. |
folder | uuid or null | Optional. Moves the file to another folder; null or "root" moves it to the top level. Omit it to leave the file where it is - an absent folder never means "unfile this". |
Renaming or re-describing a file (no data) never touches its bytes or variants. Sending data replaces the original, regenerates the preview and every existing variant for the new bytes (not just the ones you pass in variants), and - if the new upload's extension differs from the old one - deletes the stale original object afterward.
Example Request:
bash
curl -X PATCH "https://admin.flatnode.net/api/v1/file/770e8400-e29b-41d4-a716-446655440002" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{
"title": "Updated File Title",
"caption": "A short description, independent of the filename."
}'Response: 200 OK
Delete a File
Delete a file.
Endpoint: DELETE /api/v1/file/{uuid}
Example Request:
bash
curl -X DELETE "https://admin.flatnode.net/api/v1/file/770e8400-e29b-41d4-a716-446655440002" \
-H "Authorization: Bearer your-token-here"Response: 200 OK or 204 No Content
Folders
Assets can be organized into a tree of folders. A folder only ever labels where an asset sits: an asset's stored object is keyed by its own id, so creating, renaming, moving or deleting folders never moves any bytes, never invalidates a render or variant, and never changes a file's _uuid. Anything already pointing at an asset keeps working.
An asset is in at most one folder. No folder at all is the top level, spelled "root" wherever a folder id is accepted - the tree's own root node is internal and has no public id.
List folders
Endpoint: GET /api/v1/file-folder
Returns the project's whole tree, parents before children. It is not paginated: folders are few, and a client drawing a breadcrumb or a "move to..." menu needs all of them.
json
{
"message": "OK",
"data": [
{
"_uuid": "aa0e8400-e29b-41d4-a716-446655440010",
"title": "Press",
"parent": null,
"path": "Press",
"treeLeft": 2, "treeRight": 7, "treeLevel": 1,
"createdAt": "2026-11-15T10:00:00+00:00",
"updatedAt": "2026-11-15T10:00:00+00:00"
},
{
"_uuid": "bb0e8400-e29b-41d4-a716-446655440011",
"title": "2026",
"parent": "aa0e8400-e29b-41d4-a716-446655440010",
"path": "Press/2026",
"treeLeft": 3, "treeRight": 6, "treeLevel": 2,
"...": "..."
}
]
}parent is null for a top-level folder. treeLevel counts from the internal root, so a top-level folder is level 1.
Get one folder
Endpoint: GET /api/v1/file-folder/{uuid}
The folder, plus trail (its rootline, for a breadcrumb), children (its direct subfolders) and assetCount (assets filed directly in it, not counting subfolders).
Create a folder
Endpoint: POST /api/v1/file-folder
| Field | Type | Notes |
|---|---|---|
title | string | Required. |
parent | uuid or null | Optional. Omit or null to create it at the top level. |
bash
curl -X POST "https://admin.flatnode.net/api/v1/file-folder" \
-H "Authorization: Bearer your-token-here" \
-H "Content-Type: application/json" \
-d '{"title": "2026", "parent": "aa0e8400-e29b-41d4-a716-446655440010"}'Response: 201 Created
Rename or move a folder
Endpoint: PATCH /api/v1/file-folder/{uuid}
| Field | Type | Notes |
|---|---|---|
title | string | Optional. Omit to leave the name unchanged. |
parent | uuid or null | Optional. Omit to leave it where it is; send null to move it to the top level. |
Moving a folder takes its whole subtree with it. Moving one into itself or into its own descendant is refused with a 422 on parent.
Delete a folder
Endpoint: DELETE /api/v1/file-folder/{uuid}
Nothing is deleted but the folder itself. Its assets and any folders inside it move up one level, into the deleted folder's parent - or to the top level, if it had none. Deleting a folder is never a way to lose an asset.
Listing assets by folder
GET /api/v1/file takes two extra parameters:
| Parameter | Notes |
|---|---|
folder | A folder uuid, or "root" for assets at the top level. Omitting it lists every asset in the project regardless of folder, which is what callers predating folders get. |
recursive | With folder, also returns assets in that folder's subfolders. |
An unknown folder id is a 404, not an unfiltered listing.
bash
# everything in Press and below
curl -X GET "https://admin.flatnode.net/api/v1/file?offset=1&limit=20&folder=aa0e8400-e29b-41d4-a716-446655440010&recursive=1" \
-H "Authorization: Bearer your-token-here"Search
Folders are indexed for search, and every asset stores the path of the folder it sits in - so searching a folder's name returns both the folder and the assets filed under it. A hit carries folder (the folder's uuid) and folderPath.
A file-folder hit has no page of its own. Hits carry identifiers rather than built URLs, so link to one yourself by opening the media screen on that folder: /backend/{project}/media?folder={uuid}.
Abilities
Folder endpoints are gated by the same file.* abilities as the assets themselves (file.read to list, file.create to create, file.update to rename or move, file.delete to delete). There is no separate folder ability.
Images versus files in a component schema
A component points at an uploaded file with one of two field kinds:
json
{"type": "object", "format": "image"}
{"type": "object", "format": "file"}Both are single references to one file. They take the same value, return the same value, and store the same row - the choice is about what the field is for, and it changes two things.
What is identical
| What you write | {"id": "<file uuid>"}, optionally with variant_id |
| What you read back | {"id", "variant_id", "title", "caption"} |
| Where it is stored | one content row pointing at the same File |
What differs
An image field only accepts an image. Writing the uuid of a PDF or a spreadsheet into one is a 422:
json
{"errors": {"data": ["\"770e8400-...\" is a pdf file, not an image.
A format:\"image\" field only accepts jpg, jpeg, png, gif, bmp, webp;
use format:\"file\" for anything else."]}}The check runs before anything is written, so a rejected update leaves the rest of the content untouched. It applies to both spellings, to array items, and to POST /validation as much as to a write.
Two things it deliberately does not reject:
- A file whose bytes have not been uploaded yet.
POST /filewithoutdatacreates a metadata-only row with no type at all, and "not known yet" is not "not an image" - uploading the bytes afterwards is a supported flow. - A file whose format this CMS does not recognise. Anything outside the list above is stored as an unknown type rather than as a known non-image, and unknown is allowed through.
A file field accepts anything, by design: an attachment field holding a JPEG is an ordinary thing to want.
Only an image field reads variant_id. Variants are the named crops from Create Variants for a File, and the write path looks one up only for image. Send a variant_id to a file field and it is dropped without an error:
json
// into format:"image" -> reads back with the crop attached
{"id": "770e8400-...", "variant_id": "880e8400-..."}
// into format:"file" -> 201, but variant_id reads back null
{"id": "770e8400-...", "variant_id": "880e8400-..."}A frontend honours that crop by passing variant_id to render as ?variant=. Rendering the id alone resizes the uncropped original and the editor's choice is lost.
The admin UI edits them differently. An image field opens a picker narrowed to images only, with thumbnails, a preview in the content outline, and the cropper. A file field opens the full asset list with a download link, and no crop UI at all.
That narrowing is a listing parameter you can use too: GET /file?only=images returns just the files an image field will accept, paged like any other listing. only takes images or is omitted; anything else is a 422.
Choosing
Use image when the value is a picture someone will look at - a hero, a thumbnail, an avatar, anything that might need cropping to fit a layout. Use file for attachments and downloads: a PDF, a spreadsheet, a zip.
image is the stricter of the two, in both directions: it refuses a file that is not an image, and it is the only one that can carry a crop. So if a field might ever need a crop, it has to be image - and if it has to accept whatever an editor has to hand, it has to be file.
What the editor sees
Everything above is the schema author's view, and from the API the two kinds are indistinguishable: same write, same read, same row. The difference is entirely in the editing experience, which is why a builder who only ever sees the JSON tends to pick wrong:
image | file | |
|---|---|---|
| Picker offers | images only | anything uploaded |
| Editor sees | a preview of the picture | a filename and a download |
| Can crop | yes | no |
| Can be locked to a shape | yes, backend.aspectRatio below | no |
So the question to ask is not "what is stored" but "what will the editor do with it": look at it (image) or download it (file). The longer version, with a worked example, is in Modelling pages for editors.
Locking a field to an aspect ratio
An image field can demand a crop shape. backend.aspectRatio makes the picker offer a locked crop at that ratio, and surface any existing variant that already matches it:
json
{
"type": "object",
"properties": {
"hero": {
"type": "object",
"format": "image",
"title": "Hero image",
"backend": {"aspectRatio": "16:9"}
}
}
}backend is editor metadata: it is carried through the schema untouched and never validated against content. On a file field it does nothing.
Both spellings
Each kind can also be written as a $ref, which resolves to exactly the same field:
| Inline | $ref |
|---|---|
{"type": "object", "format": "image"} | http://access.flatnode.net/image-reference.schema.json# |
{"type": "object", "format": "file"} | http://access.flatnode.net/file-reference.schema.json# |
They are interchangeable - see File, Image and Link References. The admin UI's schema builder writes the inline form, and leaves a $ref you authored as a $ref.
Serving files publicly
Every /api/v1/* route, downloads included, requires a bearer token. There is no anonymous read path, and that is deliberate - it is how an unpublished asset stays unpublished.
That leaves two supported ways to get images onto a public website. Which one fits depends on whether your site is generated or served live:
| Bring your own CDN | Pull assets at build time | |
|---|---|---|
| Suits | a live site, or one with many sizes | a statically generated site |
| Token lives in | the CDN's origin-pull config | your build environment |
| At request time | edge serves, origin on a miss | your own hosting serves a file |
| Needs Flatnode up | on a cache miss | only during the build |
| New image appears | immediately | on the next build |
They compose: generate most of the site and put a CDN in front of the few images you cannot know at build time.
Bring your own CDN
Point the CDN at this API as its origin and have its origin-pull configuration inject a fixed Authorization: Bearer <read-only token> header on every origin request. Cloudflare Transform Rules, Bunny Edge Rules and CloudFront custom origin headers all do this natively.
visitor ──► cdn.example.com/file/{uuid}/render?w=800&format=webp
│ (edge cache hit: never reaches you)
▼
https://admin.flatnode.net/api/v1/file/{uuid}/render?w=800&format=webp
+ Authorization: Bearer <read-only token>The public URL never carries the token, and the token-bearing origin request only happens on a cache miss. Issue that token with file.read alone (see Token Abilities) so a leaked CDN config cannot write anything.
Render is designed for exactly this shape: its responses are immutable with a one-year max-age, and the origin computes each distinct size only once even if the edge evicts it.
Do not build a per-application proxy route to work around the token gate. If you need a stand-in during local development, make it the same shape as an origin-pull rule - inject the static header, relay the bytes, keep the cache headers, no app-specific logic - so swapping in a real CDN later is a DNS change rather than a code change.
Pull assets at build time
If your site is statically generated, you do not need a CDN in front of this API at all. Fetch what you need during the build, write it into the output directory, and let your host serve the files as it serves the rest of the site.
bash
# in a build step, with $TOKEN from the build environment
curl -fsS "https://admin.flatnode.net/api/v1/file/770e8400-.../render?w=1600&format=webp" \
-H "Authorization: Bearer $TOKEN" \
-o public/images/hero-1600.webpThe token lives in your CI or build environment and never reaches a browser, because nothing fetches from Flatnode at request time. Ask render for each size your layout uses - with the field's variant_id as ?variant=, when it has one, so the editor's crop survives into every size - and write them out as a srcset, or take the original and let your framework's image pipeline resize it.
-f matters: without it curl writes the error body to the output file and exits 0, so a 401 becomes a "successful" build with a JSON error where an image should be.
The trade is freshness. Assets are frozen at the moment of the build, so replacing a file in the CMS changes nothing until the site is rebuilt. Subscribe a build hook to webhooks - file.updated and the content.* events - so a change in the CMS triggers a rebuild rather than waiting for someone to notice.
Two details make this path cheaper than it looks. A render URL's cache key includes the file's bytes, so a replaced file produces a different URL and your build cache invalidates on exactly the assets that changed. And because the build is the only reader, a file.read token is all it ever needs - see Token Abilities.