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:

  1. docs/scripts/sync-openapi-from-backend.mjs scans the api entry point and the core contracts and writes openapi.yaml.
  2. scripts/generate-api-docs.mjs turns that document into one reference page per tag, plus the section index.
  3. scripts/generate-api-markdown.mjs renders the same operations as markdown for /llms-full.txt and the per-page .md export.
  4. next build publishes the site.

The document each build produced is served at /openapi.yaml.

What the route sync scans

  • api/src/index.ts and 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:check

This fails when the committed document no longer matches the routes. Use openapi:write to regenerate it.

On this page