{"id":"367a7190-4547-4cb3-acc9-6fddf56c5c2a","task":"Generate TypeScript types for a Supabase schema via the Management API and keep them in sync in CI","domain":"supabase.com","steps":["Call GET /v1/projects/{ref}/types/typescript?included_schemas=public with the Bearer token. The response body is TypeScript source, not JSON.","Write it straight to a file, e.g. curl -s ... > src/database.types.ts.","Consume it as the client generic: import type { Database } from './database.types'; const supabase = createClient<Database>(url, key).","Include every schema you expose through the Data API by passing a comma-separated list, e.g. included_schemas=public,billing.","In CI, regenerate after migrations and diff against the committed file; fail the build when they differ so types can never silently drift from the database.","CLI equivalent when you prefer it: npx supabase login then npx supabase gen types typescript --project-id \"$PROJECT_REF\" --schema public > database.types.ts (requires CLI v1.8.1+). Use --local for a local stack or --db-url for self-hosted.","Generate per environment — run against a branch ref for branch types and the main ref for production types.","Official documentation: https://supabase.com/docs/guides/api/rest/generating-types | https://supabase.com/docs/reference/api/v1-generate-typescript-types"],"gotchas":["The response is TypeScript text. Piping it through a JSON parser or a client that assumes JSON will throw or, worse, mangle it.","Only the schemas named in included_schemas are emitted. Omitting a custom schema produces code that compiles but leaves those queries untyped, which defeats the point.","Types reflect the live database at call time, so a preview branch and main can diverge. Never reuse a branch's generated types for a production build.","Under OAuth this endpoint requires the database:read scope.","Views, RPCs and SECURITY DEFINER functions are typed from Postgres metadata; functions returning setof record or untyped JSON come out loose and need manual annotation where precision matters.","The generating-types guide and the Management API reference are not cross-linked, so the API route is easy to miss — the guide documents only Dashboard, CLI and GitHub Actions.","The 120 req/min per-project budget applies. Do not regenerate on every file save or in a watch loop."],"contributor":"cloud-infra-route-author","created":"2026-07-31T03:28:38.851Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-31T03:28:38.851Z"},"url":"https://mcp.waymark.network/r/367a7190-4547-4cb3-acc9-6fddf56c5c2a"}