Skip to main content

HTTP API

Atrium is served behind handle_path /atrium-api/*, which strips the prefix. A route written /library is GET /atrium-api/library to a caller. Every path below is as the server sees it.

One generic prefix for the whole API is deliberate: every current and future route rides under /atrium-api/ with no per-route edit in the estate's shared Caddyfile.

What guards them​

registerWardGuard(app) runs app-wide, before any route is registered, so every non-allowlisted request arrives with an authenticated caller holding an atrium grant.

Atrium's long-standing rule that no route does its own auth survived the move to Ward. If you are adding an endpoint, you do not add an auth check — you add it to the allowlist if, and only if, it must be anonymous.

Allowlisted today: GET /health, and OPTIONS preflights.

?token= is gone, and so is the redaction that protected it

Cover <img> tags used to carry the session token in the query string, because an <img> cannot send an Authorization header — so every request URL was a potential credential and the log serialiser scrubbed it. Ward's cookie is Path=/ on the shared origin and the browser attaches it to an image request unasked, so no token reaches a URL any more. The fallback and its redaction were removed together.

Library — books, music, video​

MethodPathWhat it does
GET/libraryThe collection, filtered by kind and scoped to the active profile.
POST/libraryUpload. 50 MB ceiling; a truncated upload answers 413.
POST/library/importImport from a catalog result rather than a file.
GET/library/:idOne item.
DELETE/library/:idRemove it.
GET/library/:id/fileThe bytes.
GET/library/:id/coverCover art.
POST/library/:id/coverReplace cover art.
PATCH/library/:id/progressReading/listening position. Profile-scoped.
GET/library/:id/versionsLinked versions — the same book in either format.
POST/library/:id/convertStart a Calibre conversion job.
DELETE/library/:id/convertCancel it.

Conversion is asynchronous and cancellable, and produces a linked library row rather than replacing the original — see Conversion.

Catalog​

MethodPathWhat it does
GET/catalog/gutenbergSearch Project Gutenberg via Gutendex, for import.

Notes​

MethodPathWhat it does
GET/notesNotes for the active profile.
POST/notesCreate.
GET/notes/:idOne note.
PATCH/notes/:idUpdate content.
DELETE/notes/:idDelete.
PATCH/notes/:id/folderMove between folders.
GET/notes/:id/export.pdfRender to PDF.
GET/note-foldersThe folder tree.
POST/note-foldersCreate a folder.
PATCH/note-folders/:idRename.
DELETE/note-folders/:idDelete.

Profiles​

MethodPathWhat it does
GET/profilesEvery profile on this account.
POST/profilesCreate one.
PATCH/profiles/:idRename, recolour.
DELETE/profiles/:idDelete — cascades to everything profile-scoped.
POST/profiles/:id/activateSwitch. Free: no password, no PIN.
GET/profiles/:id/preferencesReading preferences.
PATCH/profiles/:id/preferencesUpdate them.

Switching a profile is deliberately frictionless — a profile is an identity inside an account, not a security boundary. The security boundary is the Ward grant. Since the cutover, which profile a device last activated is keyed on the Ward token's sid, so switching on one device does not switch the others.

LaTeX​

MethodPathWhat it does
GET/latexProjects.
POST/latexCreate a project.
GET/latex/:idOne project.
PATCH/latex/:idUpdate metadata.
DELETE/latex/:idDelete.
POST/latex/:id/renameRename.
GET/latex/:id/filesThe project tree.
GET/latex/:id/files/*Read one file.
POST/latex/:id/files/*Write one file.
DELETE/latex/:id/files/*Delete one file.
POST/latex/:id/compileStart a compile.
POST/latex/:id/cancelCancel it.
GET/latex/:id/logCompile diagnostics.
GET/latex/:id/pdfThe output.
POST/latex/:id/publishPublish into the library as a versioned document.

The engine is atrium's own — a TypeScript LaTeX-subset compiler that performs no I/O and is hosted on a worker thread. See the engine.

Conventions​

  • PATCH, PUT and DELETE are enumerated in the CORS config. The default allowlist omits PATCH, and these routes carry JSON bodies so they are preflighted. A method missing there works perfectly under app.inject and fails only in a browser — which is exactly the kind of bug the enumeration exists to prevent.
  • Uploads cap at 50 MB. @fastify/multipart truncates past the limit; the routes inspect file.truncated and answer 413 rather than storing a half-file.
  • Outcomes are tagged unions, not exceptions. A service returns a discriminated result and the controller maps it to a status code. See API layering.
  • Profile scoping happens in SQL, not in a filter after the fact — also API layering.