Overview
API source of truth
How endpoint accuracy is enforced between backend route code and the published reference.
The endpoint source of truth is backend route code in tether-relay. The
OpenAPI document is derived from it, and this site is generated from that
document, so the published reference always describes the branch it was built
from.
How a deployment builds its own reference
Every docs image runs the chain end to end, so there is no spec to keep in sync by hand:
docs/scripts/sync-openapi-from-backend.mjsscans the api entry point and the core contracts and writesopenapi.yaml.scripts/generate-api-docs.mjsturns that document into one reference page per tag, plus the section index.scripts/generate-api-markdown.mjsrenders the same operations as markdown for/llms-full.txtand the per-page.mdexport.next buildpublishes the site.
The document each build produced is served at /openapi.yaml.
What the route sync scans
api/src/index.tsand the routers mounted under it.services/sendgrid-inbound/src/index.ts, when that service is included.- The built core contracts in
core/dist/contracts, which carry the request and response schemas.
What it guarantees
- Every documented path and method is derived from a backend route declaration.
- Path params are normalized from Express syntax (
:id) to OpenAPI syntax ({id}). - Auth requirements from global and route-level middleware are reflected in endpoint security metadata.
What it does not guarantee
- Request body and response field shape correctness for routes that have no core contract.
- Business logic correctness inside controllers and services.
- Database and third-party dependency behavior.
Those still need runtime API tests.
Checking for drift locally
pnpm -C docs run openapi:checkThis fails when the committed document no longer matches the routes. Use
openapi:write to regenerate it.