ControlPlane API
The ControlPlane edge function exposes HTTP endpoints for compiling TypeScript flows to SQL. The pgflow compile CLI uses these endpoints internally.
Base URL
Section titled “Base URL”Local development:
http://127.0.0.1:54321/functions/v1/pgflowProduction (Supabase.com):
https://<project-ref>.supabase.co/functions/v1/pgflowEndpoints
Section titled “Endpoints”GET /flows/:slug
Section titled “GET /flows/:slug”Compiles a flow definition to SQL statements.
Request:
GET /functions/v1/pgflow/flows/greetUserAuthorization: Bearer <anon_key>Success Response (200):
{ "flowSlug": "greetUser", "sql": [ "SELECT pgflow.create_flow('greetUser');", "SELECT pgflow.add_step('greetUser', 'fullName', 'single', 0, NULL);", "SELECT pgflow.add_step('greetUser', 'greeting', 'single', 0, ARRAY['fullName']);" ]}Flow Not Found (404):
{ "error": "Flow Not Found", "message": "Flow 'unknown' not found. Did you add it to supabase/functions/pgflow/index.ts?"}Compilation Error (500):
{ "error": "Compilation Error", "message": "Detailed error message from compileFlow()"}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
flowSlug | string | The slug identifier of the compiled flow |
sql | string[] | Array of SQL statements to execute in order |
error | string | Error type (only present on error responses) |
message | string | Human-readable error description (only present on error responses) |
Authentication
Section titled “Authentication”The ControlPlane requires a valid Supabase anon key in the Authorization header. For local development, this is your project’s local anon key from supabase status.
Usage with CLI
Section titled “Usage with CLI”The pgflow compile command handles authentication and request formatting automatically:
npx pgflow@latest compile greetUserFor custom tooling or debugging, you can call the endpoint directly:
curl -H "Authorization: Bearer $SUPABASE_ANON_KEY" \ http://127.0.0.1:54321/functions/v1/pgflow/flows/greetUser