Skip to content

Files are the one part of the data plane that does not speak the platform’s usual dialect. They are owned by storage-service, a plain Express application — no LoopBack conventions, no generated OpenAPI document, and a response envelope that differs from the rest of the API in ways your error handling must know about. This page covers what an external client actually does with files: upload them, attach them to entries, download them, and understand their lifecycle.

The service’s internals — storage providers, upload validation, the metadata model, temp-file routing — are owned by File Storage & Attachments. This page stays on the client’s side of the wire and links there for depth.

Two operations are what a client builds on. The router deliberately disables everything else of the classic file API — the list, get-by-id, delete and update routes are commented out because they were unused and carried no authorization:

MethodPathPurpose
POST/api/storage/v2/filesUpload one or more files
GET/api/storage/v2/files/download/{id}Download a file’s bytes by id

Both go through the gateway with your normal credential — the same x-app-token or bearer token as any other call. You never handle the service’s internal identity headers: the gateway strips any x-shared-key a client sends and injects its own (request-transformer in api-gateway/config/kong.yml), and requests relayed by the gateway are classified as external, so the full upload validation applies to you.

The service has other routes, and none of them is client surface. The signed-link routes (below) serve browsers. GET /api/storage/v2/exports/{id}/content Since 1.10 downloads a tenant export only through a single-use link the platform mints — you never construct one. The /internal/v1/... routes (file references, tenant blobs and exports) sit outside /api/storage, are not routed by the gateway, and admit only named platform services. Details in File Storage & Attachments.

Because there is no OpenAPI document for this service, no generated client covers it (see Generating a client). Integrate these two endpoints by hand; the surface is small enough that this costs a few lines.

Send a multipart request whose form field is named file. The route accepts multiple parts under that one name (multer.array('file')), so one request can carry several files:

Terminal window
curl -s -X POST "$BASE/api/storage/v2/files" \
-H "x-app-token: $TOKEN" \
-F "file=@invoice.pdf"

A success is 201 with the envelope, and result is always an array — one descriptor per uploaded part, even when you sent a single file:

{
"success": true,
"result": [
{ "id": "5f0e9b2a-…-uuid", "name": "invoice.pdf", "mimeType": "application/pdf", "size": 20481 }
]
}

The id is the only handle you will ever get. Store it: it is what an entry field references and what the download endpoint takes. Storage internals (where the bytes physically live) are never exposed.

Two query parameters matter to a client:

  • temp=true stores the file as temporary — it is auto-deleted after one day (a TTL index on createdAt) unless a save promotes it first. Since 1.10 this is the recommended way to upload a file you are about to attach to an entry (see Temp upload, then save); it is also right for staging artifacts such as a package ZIP you are about to import.
  • ownerType and ownerId, supplied together, record which platform object the file belongs to and nest the stored object under that owner. Use them when the file is destined for an entry attachment.

Uploads from outside are validated: an extension allowlist, magic-byte content verification for binary types, and a PDF embedded-JavaScript scan. A rejection is a 400 with error.code of INVALID_FILE_TYPE, INVALID_FILE_CONTENT or PDF_JAVASCRIPT_NOT_ALLOWED. The full rule set, including which extensions are checked and which rely on the allowlist alone, lives in File Storage & Attachments. Note that the service configures no maximum size per file of its own; any per-request cap comes from proxies in front of the deployment. What it does enforce, Since 1.10, is the tenant’s storage limit: an upload that would take the tenant past it is refused with 403 STORAGE_CAP_EXCEEDED (see Errors when saving files).

An attachment field on an entity is a field whose data type is blob (isBlobField). Its value is not bytes — it is the descriptor the upload returned. The canonical shape is the shared FileModel:

{
"id": "5f0e9b2a-…", // required — the storage handle
"name": "invoice.pdf",
"mimeType": "application/pdf",
"size": 20481,
"thumbnail": { /* optional, same shape */ }
}

So the flow from an external client is: upload first, then write. Upload the file (with ownerType/ownerId pointing at the owning object when you know it), take result[0] from the response, and set it — or an array of such descriptors, for multi-file fields — as the field’s value in an ordinary entry create or update. The write mechanics are owned by Writing data.

On the read side, the entry-details response can include an attachments block: the server walks every blob field of the entity, collects the descriptors from the entry’s values (including inside repeatable blocks), and groups them by field (getEntryAttachments). Whether the block is present depends on the view’s show information configuration, so do not treat its absence as “no files” — the field values themselves are the source of truth.

Since 1.10 storage keeps a ledger of which saved record references which file. When an entry save names a file id, data-service registers it before writing — and if the id belongs to a temp upload, storage promotes it to permanent storage under the same id. So the robust pattern for a client is the one the web portal now uses:

  1. Upload with ?temp=true.
  2. Save the entry with the returned descriptor within the day.
  3. The save promotes the file; from then on it is permanent and referenced by that entry.

What this changes for an API client:

  • Every new file id on a save must exist. Descriptors in blob fields are checked — objects with an id, name, mimeType and numeric size. A descriptor whose id storage cannot find — a temp upload older than a day, or an id that never existed — fails the save with 400 FILE_EXPIRED, naming the field. Ids the stored entry already held are not re-checked, so re-saving an old record never fails on them.
  • A save can wait on storage. If storage cannot be reached while a save adds a new file, the save fails with a retryable 503 STORAGE_SERVICE_UNAVAILABLE instead of writing a reference nothing tracks.
  • Permanent uploads still work exactly as before. They are simply not tracked by the ledger, so they are never cleaned up automatically.

Downloads are the canonical example of a response that bypasses the envelope structurally: the handler writes to the HTTP response itself — content type, disposition, then the bytes — so there is no {success, result} wrapper and nothing to JSON-parse. A client that pipes every response through a JSON parser will fail exactly here.

Terminal window
curl -s "$BASE/api/storage/v2/files/download/5f0e9b2a-…" \
-H "x-app-token: $TOKEN" \
-o invoice.pdf

What comes back (downloadFile):

  • Content-Type is derived from the stored file name’s extension (a mime-types lookup, falling back to application/octet-stream) — not from the mimeType recorded at upload.
  • Content-Disposition: attachment with the original file name is always set. Nothing is ever served as inline, executable content.
  • The body is the raw bytes.

The same endpoint serves temporary files — the handler checks the permanent collection first, then the temp one — so a temp=true upload is downloaded by plain id like any other. A missing id is a 404 — and so, Since 1.6, is an id whose metadata exists but whose stored bytes are gone (it used to be an unhandled 500).

Signed links for browsers Since 1.6. If a browser needs to show a file with a plain <img src> (no bearer token), ask storage for a short-lived signed URL with POST /api/storage/v2/files/links and use the returned url. The link is a bearer capability: signing checks only that the file exists in the tenant, not that the caller may read it, so anyone holding the link can fetch the file until it expires (one to two hours by default). Keep such links out of logs and shareable URLs. Details: Signed, cacheable content links.

One asymmetry to internalize: only the success path is binary. A failed download — unknown id, backend trouble — is still a JSON error body with the appropriate status. Branch on the status code (or Content-Type) before deciding how to read the body.

The public API creates and reads files, and never destroys them. Clean-up, where it happens at all, is the platform’s job:

  • Permanent uploads persist indefinitely. There is no delete endpoint on the public surface, so a file uploaded straight to permanent storage outlives any entry that referenced it; removing an attachment from an entry edits the entry’s value, not the stored file. lastAccessedAt is updated on each download of a permanent file, giving operators a signal for offline cleanup — but cleanup is an operational task, not an API call.
  • Promoted files can be swept Since 1.10. A file that a save promoted from temp is tracked. If every record that referenced it releases it (for example the record is deleted for good) and a grace period passes, a background sweeper deletes it — but only after each former owner confirms it no longer lists the file. An entry keeps every file it ever held in its history, so its files are not swept while the entry exists. The platform’s chart ships the sweeper switched on but in a log-only dry run, until an operator lets it delete; see Orphan file sweeper.
  • Temporary uploads self-destruct after one day via the TTL index. This is also how the platform treats its own transient artifacts: an exported solution package, for example, is uploaded as a temp file, so the fileId an export job hands you is valid for roughly a day — download it promptly (see Long-running work). A published package version’s ZIP is stored permanently instead, and deleting the version or an export removes its record only: the ZIP stays in storage.
  • createdBy is recorded from your authenticated identity on permanent uploads, and ownerType/ownerId metadata ties a file to its owning object when you supplied them.

Design consequence for a client: treat a file id as a capability handle. Any authenticated caller who knows an id can download the file — the storage layer enforces authentication at the edge but has no per-file permission model of its own — so do not put ids where they can leak, and do not rely on obscurity to protect sensitive content.

Storage errors share the platform’s {success, result, error} outline but not its exact shape. The Express services assemble the envelope by hand, and the divergence is deliberate, preserved for wire compatibility:

// storage-service failure body (middleware.error.ts)
{
"success": false,
"result": {
"code": "NOT_FOUND",
"message": "File is not available!",
"serviceName": "storage",
"traceId": "…",
"details": { "error": "File not found." }
},
"error": {
"code": "NOT_FOUND",
"message": "File is not available!" // a plain string — NOT {en, ar}
}
}

Three differences from the LoopBack error body your handler already knows from Calling the HTTP API:

  1. error.message is a plain single-language string, not a localized {en, ar} object.
  2. error carries no traceId — the trace id lives in result.traceId here.
  3. result is a populated diagnostic object on failure, not null.

Also, a 401 from the service’s own authentication check is emitted before the error middleware runs and is not enveloped at all — the raw error object is sent as is. Write the storage error path as its own small branch: match on HTTP status and error.code, and read the trace id from wherever it is. The retry policy itself is the same as everywhere else — see Errors and retries.

Three codes concern files. Note which service answers, because that decides the body shape (storage’s own, described above, or the platform’s usual one from Errors and retries):

Status / codeRaised byMeaningWhat to do
403 STORAGE_CAP_EXCEEDEDstorage-service, on uploadThe tenant reached its storage limit (its plan’s maxStorageGb). Storage error shape; result.details carries capBytes and usedBytes. An upload that crosses the limit mid-stream is removed and refused the same way.Not retryable — the limit has to be raised for the tenant before uploads succeed again.
400 FILE_EXPIREDdata-service (and reaction-service), on saveA new file id in the saved value cannot be found. Platform error shape with a localized message; result.details lists {fileId, fieldName} (or {fileId, path}) per missing file, each with a localized reason.Upload the file again and re-save with the new descriptor.
503 STORAGE_SERVICE_UNAVAILABLEdata-service (and reaction-service), on saveStorage could not be reached while the save added a new file.Retryable: back off and repeat the same save.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27