For AI agents: fetch the complete documentation index at /llms.txt, the full documentation corpus at /llms-full.txt, the agent skill at /skill.md, or this page as Markdown at /docs/modules/api.md (or send Accept: text/markdown).
API module
The versioned public contract, key plumbing, and OpenAPI surface.
Before you begin
Open your downloaded supastack project in Visual Studio Code using File → Open Folder, then choose Terminal → New Terminal. The repository root is the folder containing package.json, apps and packages. Run the command below there and leave its terminal open. If a command is not recognized, finish the tool installation guide before continuing.
Read the platform tutorial first. A server is the app process that answers browser or phone requests. Web reads apps/web/.env.local, Expo reads apps/mobile/.env.local, and database migration commands read root .env. The no-database /dashboard demonstration is separate from real /auth accounts, which need migrated Postgres. A phone or desktop-only checkout needs a separately running Web backend.
- Install the tools and get the code
- Learn commands, files and configuration
- Complete the Web first-run tutorial
corepack pnpm --filter @supastack/web devSetup and configuration
packages/api is the source of truth for the public REST surface: zod schemas for requests, responses, and the error envelope, plus the OpenAPI document (openApiDocument) served at /api/v1/openapi. Route handlers compose these schemas instead of redefining shapes.
API keys are issued per workspace with a sk_<env>_ prefix, stored hashed with constant-time comparison, and carry scopes — read by default. api-keys.ts owns creation, lookup, and revocation.
apiV1 = "/api/v1"
schemas: currentWorkspace, entitlement,
modelRequirements, createAiTaskRequest,
aiTask, aiTaskResult, apiError
openApiDocument → GET /api/v1/openapiImplementation workflow
Add endpoints inside the existing version: extend schemas, keep the error envelope, and regenerate the OpenAPI surface so /api/docs stays accurate. Breaking changes get a new version, not a silent shape change.
Resolve the caller's workspace from the presented key, apply the same entitlement and validation rules as the web app, and rate-limit per key.
Verification and troubleshooting
Contract-test every route shape against the package schemas. Verify unknown keys, revoked keys, and underscoped requests all fail with the documented error envelope, and that the OpenAPI document stays valid JSON.