Skip to main content

HTTP API

Ward is served behind handle_path /ward-api/*, which strips the prefix. So a route written /login in the source is POST /ward-api/login to a caller, and Ward itself never sees the prefix. Every path below is given as the caller sees it.

Conventions that hold everywhere​

  • A refusal names the request, never the server. Any unhandled throw becomes {"error":"internal"}. The default Fastify behaviour puts err.message in the body, and the reproduction was as bad as it sounds: a missing signing key plus correct credentials answered 500 with the absolute on-disk path of the estate's signing key, from the one route the whole internet can reach unauthenticated.
  • Per-session answers are no-store. Nothing between Ward and a caller may hold one.
  • Ambiguous failures are one answer. Login, /session-status and the client assertion check each collapse their failure modes deliberately; see the relevant page.
  • Query strings are logged. Fastify's request log line includes the URL, so nothing secret may travel in one — with the single audited exception of GET /verify?token=, which has its own log serializer to redact it.

Public — no credential​

MethodPathWhat it does
GET/healthLiveness. Static answer.
GET/.well-known/jwks.jsonThe public half of the signing key. The OpenID Connect provider publishes the same key at /oidc/jwks.
GET/appsApps open to public registration, for the register page's app picker.
POST/registerCreate an account at an app whose public_registration flag is on.
GET/verify?token=Consume an emailed verification token. The one route allowed a secret in the query string, because an email client must be able to link to it.

Session — Ward's own cookies​

The access cookie (ward_session) is scoped to Path=/ward-api and the refresh cookie (ward_refresh) to Path=/ward-api/refresh, so only Ward's own pages send them. No app receives either.

MethodPathWhat it does
POST/loginIdentifier + password. Sets the access and refresh cookies.
POST/refreshSpends the refresh cookie, rotates the family, reissues both.
POST/logoutRevokes the family. Rows are marked, not deleted.
POST/refresh/logoutThe same, for a caller that holds only the refresh cookie.
GET/sessionWhether this browser has a live Ward session, for Ward's own UI. Always 200.
GET/accountThis account's own identity and grants.
POST/account/passwordChange own password.
POST/account/sessions/revoke-othersSign out every other session, keeping this one.

POST /login collapses every failure into one answer, and unknown identifiers still spend a dummy hash so timing does not leak account existence. The lockout is deliberately not keyed on request.ip — see decisions-implementation.

Service — the client assertion​

An app authenticates as its OpenID Connect client: a fresh private_key_jwt assertion (client_assertion_type + client_assertion, aud = the issuer) in the JSON body. A missing or bad assertion is 401 {"error":"invalid_client"}.

MethodPathWhat it does
POST/session-statusIs this Ward session, signed in through OpenID Connect, still live and the grant still held? Apps cache the answer for 30 seconds. Only mounted when WARD_OIDC_ISSUER is set.
POST/notifyMail one of the calling app's users. Ward holds the address; the app never sees it.

Both are described in Sign in with Ward.

Retired 2026-10-13

POST /introspect, the x-ward-app-key header and the console's app-key routes are gone; a request to /introspect is now 404. The history is in decisions — app keys.

OpenID Connect​

When WARD_OIDC_ISSUER is set, Ward also serves the provider under /oidc/* (discovery, JWKS, authorization, token, end session) and its login step at /refresh/oidc/:uid. The full table is on Sign in with Ward.

Every path below sits under /console/ and that is functional, not cosmetic: the ward_console cookie is scoped to Path=/ward-api/console, so a route mounted anywhere else would simply never receive it.

MethodPathWhat it does
POST/console/loginSuperuser sign-in. Separate credential, separate cookie.
POST/console/logoutEnd the console session.
GET/console/sessionWhether the console session is live.
GET/console/appsList apps.
POST/console/appsCreate an app.
GET/console/apps/:slugOne app.
PATCH/console/apps/:slugChange name, registration flag, baseline role.
DELETE/console/apps/:slugDelete an app — cascades to every grant into it.
PUT/console/apps/:slug/oidcSet the app's OpenID Connect client: redirect URIs, sign-out return URIs, public key.
GET/console/accountsList accounts.
POST/console/accountsCreate an account.
GET/console/accounts/:subjectOne account.
POST/console/accounts/:subject/enableRe-enable a disabled account.
POST/console/accounts/:subject/disableDisable. Existing sessions stop answering as active.
POST/console/accounts/:subject/passwordSet a password on behalf of an account.
POST/console/accounts/:subject/usernameRename. The subject, grants and sessions stay.
DELETE/console/accounts/:subjectDelete outright: grants and sessions go with it, the subject is retired.
GET/console/accounts/:subject/sessionsLive refresh families for an account.
POST/console/accounts/:subject/sessions/revokeRevoke all of them.
DELETE/console/accounts/:subject/sessions/:familyIdRevoke one.
GET/console/grantsGrants, filterable.
POST/console/grantsGrant a role.
DELETE/console/grantsRemove a grant.
GET/console/auditThe audit log, newest first.

The five admin plugins each attach the console guard as a plugin-scope preHandler, so registering them opens nothing — they gate themselves.

A Fastify detail worth knowing before you add a route

Several console plugins mount paths under /console/accounts/:subject and /console/apps/:slug. Fastify merges those into one radix tree only while every plugin spells the parameter the same way. Rename :subject to :sub in one place and Fastify refuses to boot with a parametric-conflict error — which is the good outcome, but it is a boot failure, not a test failure.