API Reference โ Lantern โ
Lantern is composed of independent Cloud Run services, each exposing a versioned HTTP API. Every service ships its own OpenAPI 3.0 spec at /openapi.json; the admin portal renders all of them in-house under API Reference.
This document is a map: where to find the live docs, how to use the renderer, what service to look at for which feature, and the cross-cutting conventions every service follows.
Looking for actual endpoint definitions, request/response schemas, or example payloads? Don't read this file โ open the admin portal and pick a service. The OpenAPI specs are the source of truth; this page exists only for orientation.
Where to view the live API docs โ
| Where | URL | Audience |
|---|---|---|
| Admin portal (dev) | https://admin.dev.ourlantern.app โ API Reference | Internal โ auto-fills your Firebase token |
| Admin portal (local) | http://localhost:3001 โ API Reference | Engineers running the admin app locally |
| Raw spec per service | https://<service>-โฆrun.app/openapi.json | Tooling: Postman, Insomnia, codegen |
| Source of spec | services/api/<service>/openapi.json | Editing โ checked into the repo |
The renderer is the @lantern/api-docs-renderer workspace package. It is the only sanctioned way to render Lantern API docs โ there is no Scalar, Swagger UI, Redoc, or hosted alternative anywhere in the codebase.
How to use the API Reference page โ
Every service page in the admin portal gives you the same controls:
- Server picker (top of the page) โ choose the environment you want examples to target. Auto-defaults to the running service URL when present, otherwise the dev Cloud Run URL.
- Sidebar โ endpoints grouped by tag, plus a Schemas section listing every component definition from the spec. Click any schema to jump to its full type breakdown (nested objects, enums, required fields, examples).
- Operation view โ for each endpoint:
- Summary, description, security (which auth method), parameters, request body, every response shape
- Code Samples tab โ copy-paste ready
curl,fetch, and Node snippets generated from the spec - Try It tab โ fire the request directly from the browser. Auth tokens are pre-filled from your admin session; request bodies auto-fill from the schema's
examplevalues so you can edit and send in two clicks
- Schemas section (sidebar) โ the canonical place to see component definitions (
#/components/schemas/...). Use this when you're building a client and want to know the exact shape of aLantern,Wave,Offer, etc.
Bug or missing detail in a doc? โ
Edit the spec in services/api/<service>/openapi.json, open a PR. The renderer picks up changes automatically โ no separate doc build.
Service inventory โ
Source of truth: packages/shared/services/index.js (API_SERVICES).
| Service | Slug | Purpose | Local port |
|---|---|---|---|
| Analytics API | analytics-api | Server-side analytics, merchant dashboards, platform metrics | 8082 |
| Assistant API | assistant-api | AI chat assistant for the admin portal | 8086 |
| Auth API | auth-api | Phone+PIN tokens, admin auth, roles, moderation | 8084 |
| Docs API | docs-api | Markdown document management + GitHub integration | 8081 |
| Lanterns API | lanterns-api | Lantern presence lifecycle (light, extinguish, schedule, bonfire) | 8083 |
| Merchants API | merchants-api | Merchant offer CRUD, campaigns, merchant-scoped resources | 8085 |
| Venue API | venue-api | OSM import, enrichment, venue management | 8080 |
Adding a new service? See CLAUDE.md rule #8 โ register it here, ship openapi.json, no doc UI.
Cross-cutting conventions โ
These rules apply to every service. Per-endpoint detail lives in the OpenAPI specs.
Authentication โ
- User & merchant requests:
Authorization: Bearer <Firebase ID token>โ verified byverifyFirebaseTokenmiddleware - Admin endpoints: Firebase ID token +
admincustom claim (or stronger viarequireAdmin) - Public endpoints: marked
security: []in the spec (e.g./health,/openapi.json)
Errors โ
All services emit a uniform shape via the shared errorHandler middleware:
{ "error": { "code": "VALIDATION_FAILED", "message": "โฆ", "details": { โฆ } } }Standard HTTP status meanings: 400 invalid payload ยท 401 missing/expired token ยท 403 insufficient role ยท 404 not found ยท 409 conflict ยท 429 rate-limited ยท 5xx server error.
Rate limits โ
Defaults are defined per service via userRateLimit middleware. Sensitive endpoints (writes, costly aggregations, AI calls) are individually tightened. The OpenAPI description of each endpoint notes any non-default limit.
CORS โ
All services share ALLOWED_ORIGINS from packages/shared/services/index.js. Admin-only services use the ADMIN_ORIGINS subset.
Related docs โ
packages/api-docs-rendererโ the renderer package itselfdocs/engineering/architecture/api/VENUES.mdโ Venue API deep-dive (auth, OSM pipeline, geo-fencing)docs/engineering/analytics/analytics-infrastructure.mdโ Analytics API consumers and event taxonomy