Skip to content

Server files API

eaxScadaReferenceStarterProEnterpriseView as Markdown

Migrated page, not yet verified against the current code. Treat values, paths and examples as indicative until this notice is removed.

A browser cannot read or write a folder of the server or a network share. When a screen needs one, for example to read a recipe CSV from a drop folder or to save a report to a share, the server does the file work through a root. A root is a folder that an administrator names and configures.

The server only reaches files inside the roots. The client sends a root name and a path relative to that root. The server never takes a server path from a client, never runs a file and never changes file permissions.

Edition Roots
Free none: every call answers 403 with status edition_required
Starter one root (the first in the roots file); others answer edition_required
Pro, Enterprise no limit

The roots are kept in data/serverfiles/roots.json. Only an administrator changes them, in Security > Server files or through /api/server-files/admin/roots. Every change is recorded in the audit trail with the root definition before and after it, and the file’s version goes up by one.

On an HA cluster the roots file is replicated with the rest of the engineering configuration, but the files inside the roots are not. Each node’s root points at that node’s own disk, and a standby node refuses changes.

{
"version": 3,
"roots": [
{
"name": "recipes-import",
"path": "D:\\eax\\recipes",
"description": "CSV recipe drop folder",
"list": true, "read": true, "write": true, "delete": false,
"read_roles": ["Process_Supervisor", "Lead_Engineer"],
"write_roles": ["Lead_Engineer"],
"delete_roles": [],
"allowed_ext": [".csv", ".json"],
"max_file_mb": 10,
"quota_mb": 500
}
]
}
Field Meaning
name The root’s name in the API: 1 to 48 characters, lower-case letters, digits, - and _.
path The folder on this server, as an absolute path (a UNC share folder is accepted). It must exist. It cannot be a whole drive. It cannot be inside or around the server’s data folder, config folder or program folder, or overlap another root. Only the administrator sees this field.
list, read, write, delete The operations the root allows at all. write also covers creating folders. delete is off unless you switch it on.
read_roles The roles that may list folders, look at entries and read files.
write_roles The roles that may write files and create folders.
delete_roles The roles that may delete files and empty folders.
allowed_ext The file types that may be read, written and deleted. This field is required: there is no “any” value. Program and page types such as .exe, .bat, .ps1, .js, .html and .svg are never accepted.
max_file_mb The largest file that may be read or written, from 1 to 1024 MB.
quota_mb The most that all the files in the root together may hold, counted when a file is written. It cannot be smaller than max_file_mb.

A role that is not in an operation’s list is refused that operation. This includes the Administrator. To let the Administrator use a root, add Administrator to its role lists.

The server makes these checks in order, and refuses the call at the first one that fails:

  1. Rate limit. Each user may make 20 calls a second, with bursts of up to 60. Above that the server answers 429.
  2. The AI assistant and the AI gateway. These are always refused. No AI tool calls these routes. The server also refuses a call made through the assistant, or by the AI co-pilot account.
  3. The edition. See the table above.
  4. The operation’s permission. The permissions are server_files.list, server_files.stat, server_files.read, server_files.write, server_files.delete and server_files.mkdir. Each one is a permission rule with target type feature and the permission’s name as its pattern (/api/auth/permissions).
    • A matching deny rule always wins, for everyone, the Administrator included. It matches when it names the operation, server_files.*, the catch-all * (feature:*) or a prefix ending in * (server*). Before 16 November a deny * or prefix did not cover the server files.
    • An explicit allow rule grants the permission when it names the operation or server_files.*. The catch-all allow * grants none of them.
    • Without a rule, the role level decides. Shift_Operator and above hold list, stat, read, write and mkdir. Process_Supervisor and above hold delete.
    • When the permission rules cannot be read, every operation is refused, the Administrator included.
  5. The root. The root must exist and allow the operation, and the user must hold a role that the root lists for that operation.
  6. The path. See Paths below. For files, the file type must be in the root’s allowed_ext.
  7. HA. On a standby node, writing, deleting and creating folders answer 503.

A path is relative to the root and uses / as the separator (\ is accepted too). An empty path means the root itself.

The server refuses a path, and never tries to repair it, when it:

  • starts with / or \, including UNC paths such as \\server\share;
  • contains : anywhere, which covers drive letters and alternate data streams such as file.csv:stream;
  • contains a NUL or another control character, or any of < > " | ? *;
  • has an empty component, or a . or .. component;
  • has a component that starts with a dot (hidden files) or a space, or ends with a dot or a space;
  • uses a Windows device name (CON, PRN, AUX, NUL, COM0 to COM9, LPT0 to LPT9, CONIN$, CONOUT$, CLOCK$), with or without an extension, on every operating system;
  • is longer than 1024 characters, deeper than 32 folders, or has a name longer than 255 characters.

On disk, the server checks every existing part of the path. It refuses the path at the first symbolic link, junction or other reparse point: links inside a root are not followed, and the server reports a link that leads outside the root as such. The file operations then run through a handle opened on the root folder, which refuses any link that leaves the root, so a folder swapped for a link after the check cannot escape either. Names that a path could not reach, such as hidden files and links, are left out of listings.

On Windows, names are compared without regard to case.

Each route needs a signed-in session. Errors are JSON in the form {"error": "...", "status": "<code>"}. An error message names the root and the relative path, never a folder of the server.

Route Answer
GET /api/server-files/roots {"roots": [{name, description, can_list, can_read, can_write, can_delete, allowed_ext, max_file_mb, quota_mb}]}: the roots the user may use, without their folders.
GET /api/server-files/list?root=&path=&offset=&limit= One page of a folder: {root, path, entries, total, offset, limit}. Folders come first, then files, by name. limit is 200 by default and at most 1000. Each entry is {name, path, type: "file"|"folder", size, modified, allowed}.
GET /api/server-files/stat?root=&path= One entry.
GET /api/server-files/file?root=&path= The file’s bytes, as a download (Content-Disposition: attachment, application/octet-stream, nosniff). The file is streamed up to the root’s size limit.
PUT /api/server-files/file?root=&path=[&overwrite=true] Writes the request body to the file. The server writes a temporary file in the same folder and then renames it over the target, so the change is atomic. An existing file is replaced only with overwrite=true. The parent folder must exist. The answer is the entry with its sha256.
DELETE /api/server-files/file?root=&path= Deletes a file of an allowed type, or an empty folder. The root itself cannot be deleted.
POST /api/server-files/mkdir Body {"root": "...", "path": "..."}, sent as JSON. Creates one folder; its parent must exist. Answers 201 with the entry.
GET /api/server-files/admin/roots Administrator only. The roots file, the edition’s root limit (0 none, 1, -1 no limit), whether each root’s folder exists on this node, and any error reading the file.
PUT /api/server-files/admin/roots Administrator only. Creates a root, or replaces the root with the same name.
DELETE /api/server-files/admin/roots?name= Administrator only. Removes a root. Its folder and files stay on the server. You can remove roots in every edition.
Status Code When
400 path_refused the path is not acceptable (see Paths)
400 bad_request, invalid_config the request or the root definition is not valid
401 unauthorized no session
403 edition_required the edition has no server files, or does not include this root
403 forbidden a missing permission or role, an operation the root switches off, or the AI assistant
403 extension_refused the root does not allow this file type
404 not_found no such root, file or folder
409 exists, conflict the file already exists, a folder is in the way, or the folder is not empty
413 too_large the file is over the root’s size limit
429 rate_limited too many calls; retry after the Retry-After delay
503 unavailable an HA standby node, or the root’s folder is missing on this node
507 quota_exceeded the write would take the root over its quota

Every call writes one record to the audit trail, in category SERVER_FILES, with the operation in upper case as its action (READ, WRITE, LIST, ROOT_SAVE…). The record is the entry’s reason, which the ledger’s hash chain covers:

{"time": "2026-10-09T12:00:00Z", "user": "supervisor", "user_id": "usr_...", "role": "Process_Supervisor",
"client_ip": "10.0.0.12", "root": "recipes-import", "path": "batch-42.csv", "op": "read",
"size": 1834, "sha256": "9f2c...", "result": "ok"}
  • The user always comes from the signed-in session. No request header or body field can change it.
  • sha256 is the hash of the bytes read or written.
  • result is one of:
    • ok;
    • refused, with the error code and detail;
    • error: the server failed, and the cause is in the server log.
  • Calls refused by the rate limit are the one exception to “one record per call”. The server writes one record per user every 10 seconds, and its suppressed field gives the number of refusals since the last such record.