Skip to content

# Supabase RPC

Use Supabase RPC to start pgflow workflows with simple function calls when you don’t need real-time progress updates.

Tip

This approach is best for fire-and-forget workflows where you don’t need to monitor progress or wait for results.

For real-time progress streaming, status monitoring, or waiting for completion, use the TypeScript Client instead.

Security Setup Required

pgflow ships with ZERO database permissions for client roles. Before using this method from client applications, you must:

- Expose the `pgflow` schema in your PostgREST configuration
- Configure database permissions for `anon` or `authenticated` roles

See the Permissions reference for complete setup instructions.

Note: Edge worker uses service role by default and does not require this setup.

## Basic Usage

Section titled “Basic Usage”

Start a workflow by calling the `pgflow.start_flow` function via RPC:

    import { createClient } from '@supabase/supabase-js';
    const supabase = createClient(  'https://your-project.supabase.co',  'your-anon-key');
    // Start a workflowconst { data, error } = await supabase  .schema('pgflow')  .rpc('start_flow', {    flow_slug: 'send_welcome_email',    input: {      email: 'user@example.com',      name: 'John Doe'    }  });
    if (error) {  console.error('Failed to start workflow:', error);} else {  console.log('Workflow started with run_id:', data);}

Calling Functions in Custom Schemas

pgflow functions are in the `pgflow` schema, not the default `public` schema. To call RPC functions in custom schemas, use `.schema('schema_name').rpc('function_name')`. See the Supabase team’s guidance on GitHub for details.

## With Custom Run ID

Section titled “With Custom Run ID”

Provide a custom UUID for the workflow run:

    import { randomUUID } from 'crypto';
    const run_id = randomUUID();
    const { data, error } = await supabase  .schema('pgflow')  .rpc('start_flow', {    flow_slug: 'process_upload',    input: {      file_url: 'https://example.com/file.pdf'    },    run_id: run_id  });
    console.log('Started workflow:', run_id);

Tip

For monitoring workflow progress, checking status, or waiting for completion, use the TypeScript Client instead. It provides real-time progress updates and robust status monitoring without polling.

## Learn More

Section titled “Learn More”
TypeScript Client Use the full client library for real-time progress streaming