Skip to content

API Reference

When the API dev server is running (pnpm dev:api), open:

  • Scalar UI: /scalar — interactive API reference
  • OpenAPI JSON: /doc — machine-readable OpenAPI 3.0 spec

Example (local Wrangler default):

http://localhost:8787/scalar
http://localhost:8787/doc
MethodPathDescription
GET/healthHealth check with Zod-validated JSON response
GET/docOpenAPI 3.0 JSON spec
GET/scalarScalar API reference UI
MethodPathAuthDescription
GET/api/meOptionalCurrent user session or null

Better Auth email/password routes are served at /api/auth/* (not part of the OpenAPI spec).

MethodPathDescription
GET/api/quizzesList quizzes for the signed-in user
POST/api/quizzesCreate a draft quiz
GET/api/quizzes/{id}Fetch quiz detail (owner only)
PATCH/api/quizzes/{id}Update a draft quiz
DELETE/api/quizzes/{id}Delete a quiz
POST/api/quizzes/{id}/publishPublish draft → 6-char permalink

Published quizzes cannot be edited (PATCH returns 409).

MethodPathDescription
GET/api/public/quizzes/{permalink}Load published quiz (answers redacted)
POST/api/public/quizzes/{permalink}/submitSubmit answers; returns score

Request and response schemas live in @quiz-builder/types with .openapi() metadata. The API registers routes via createRoute and OpenAPIHono.openapi() from @hono/zod-openapi.

Example schema (simplified):

import { z } from "@hono/zod-openapi";
export const HealthResponseSchema = z.object({ status: z.literal("ok") }).openapi("HealthResponse");

New endpoints should follow the same pattern: define the schema in packages/types, create a route in apps/api, and Scalar will pick it up automatically from /doc.

Set deployed API base URLs in CI/CD variables and link them here once Cloudflare Workers deploy jobs are configured.