Audience: new users who want a runnable production-oriented API skeleton with the standard service wiring already in place.
- Go 1.25.x.
- Make.
- curl for the local HTTP checks.
- Docker only for generated Docker Compose, integration, or database-backed checks; the first-run path below stays local.
go run github.com/aatuh/api-toolkit/contrib/v3/cmd/api-toolkit@latest new service \
--module example.com/my-api \
--profile saas-api \
--dir my-api
cd my-api
cp .env.example .env
go mod tidyExpected result: my-api contains a Go module, chi-based API service,
OpenAPI golden, Makefile, Dockerfile, Compose file, pinned GitHub Actions CI,
tests, and a local .env file.
make finalize
make openapi-check
make contracts-lint
make contracts-diffExpected result: tests pass, the binary builds, the generated OpenAPI golden is current, and route contract linting accepts the default production policies.
go run .Try the public health and OpenAPI routes from another shell:
curl -s http://localhost:8080/readyz
curl -s http://localhost:8080/docs/openapi.jsonTry the default protected write route:
curl -s -X POST http://localhost:8080/widgets \
-H 'Content-Type: application/json' \
-H 'X-API-Key: local-dev-key' \
-H 'X-Tenant-ID: tenant_1' \
-H 'Idempotency-Key: demo-1' \
-d '{"name":"starter"}'Expected result: GET /readyz returns ready health, GET /docs/openapi.json
returns the generated OpenAPI document, and POST /widgets returns a created
widget. Repeating the same write with the same Idempotency-Key replays the
stored response.
curl -s -H 'X-Admin-Key: local-admin-key' http://localhost:8080/health/detailed
curl -s -H 'X-Admin-Key: local-admin-key' http://localhost:8080/metrics
curl -s -H 'X-Admin-Key: local-admin-key' http://localhost:8080/debug/pprof/The scaffold keeps detailed health, metrics, and pprof behind the generated admin middleware. The public routes remain limited to readiness, liveness, version, and OpenAPI/docs.
The default saas-api profile starts with API-key auth for local development.
For production, set explicit non-default API_KEY, ADMIN_KEY,
IDEMPOTENCY_STORE=redis, and RATE_LIMIT_STORE=redis. JWT and Clerk modes are
available from the generator:
api-toolkit new service --module example.com/my-api --profile saas-api --auth jwt
api-toolkit new service --module example.com/my-api --profile saas-api --auth clerkFor the heavier production foundation, use the saas-api-full profile:
api-toolkit new service \
--module example.com/my-api \
--profile saas-api-full \
--auth api-keyIt keeps this quick-start profile small and starts a Postgres + Redis oriented tenant foundation with migrations, hexagonal package boundaries, OpenAPI contracts, generated smoke tests, durable async/outbox workers, audit logs, outbound webhook delivery, object storage hooks, OpenAPI 3.1, a checked-in typed Go client, opt-in Docker integration checks, Docker Compose, and base Kubernetes assets.
Useful full-profile follow-up commands:
make client-check
make client-ts-check
make resource-check
make migrate-plan
make migrate-checkAdd app-specific tenant resources from inside a generated full-profile project:
api-toolkit generate resource \
--name project \
--plural projects \
--field name:string:required \
--field status:string:required:enum=active\|archived \
--filter status \
--sort name \
--relationship owner:organizations \
--object-field attachment_key \
--tenant-scoped \
--crud \
--postgres \
--soft-delete \
--etag \
--audit \
--webhooksProvider starters stay opt-in:
api-toolkit new service \
--module example.com/my-api \
--profile saas-api-full \
--client typescript \
--with stripe-billing \
--with resend-email \
--with clerk-webhooks \
--with entitlementsGenerate deployment and observability starters when you need them:
api-toolkit ops observability --profile saas-api-full --out observability
api-toolkit deploy helm --dir . --out deploy/helm
api-toolkit deploy terraform --cloud aws --dir . --out deploy/terraform/aws
make observability-check deploy-checkFor browser/session services, use the separate web profile instead of mixing cookie sessions into API-first scaffolds:
api-toolkit new service \
--module example.com/my-web \
--profile saas-web \
--auth oidc-sessionThe web profile generates secure cookies, CSRF middleware, memory and Redis-backed session-store boundaries, OIDC callback state validation, guarded production startup validation, and browser-safe CORS without changing the API-first profiles.
See full-service-scaffold.md for the full runtime, migration, deployment, provider, and resource-generation contract.
Next: use cookbook.md for focused patterns and ../contrib/examples/README.md for runnable example applications.