> ## Documentation Index
> Fetch the complete documentation index at: https://synthbrew.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Supabase integration

> Import Supabase schemas and generate synthetic data into a dedicated Supabase schema.

Use the Supabase runtime target when you want Synthbrew to read schema metadata from a Supabase Postgres database and write generated data back into that same Supabase project.

## What is supported

* Import tables from Supabase into a Synthbrew schema draft
* Create Supabase-targeted sources (`runtimeTarget.provider = "supabase"`)
* Populate and regenerate directly into a selected Supabase schema
* Run runtime CRUD through Synthbrew API routes on Supabase-backed sources

## Required permissions

Use a dedicated Postgres user for Synthbrew and grant only what it needs.

For schema import:

* `CONNECT` on the database
* `USAGE` on schemas you want to introspect
* `SELECT` on selected tables and metadata views (`information_schema`, `pg_catalog`)

For generation/runtime into the synthetic schema:

* `USAGE` and `CREATE` on the target synthetic schema
* `SELECT`, `INSERT`, `UPDATE`, `DELETE`, `TRUNCATE`, `REFERENCES`, `TRIGGER` on objects in that schema

## Setup flow

1. In Synthbrew, open **Schemas** and choose **Import from Supabase**.
2. Paste a Supabase/Postgres connection string and run a preview.
3. Select schemas/tables, review warnings, and create the schema.
4. In **Sources**, create a source with runtime target `supabase`, set `schema`, and provide the connection string.
5. Run populate/regenerate. Synthbrew writes only to the configured synthetic schema.

Connection strings are encrypted server-side before storage. Synthbrew stores a secret reference in source config, not plaintext credentials.

## Create a Supabase source via API

You can create Supabase-targeted sources through the Public API endpoint:

* `POST /api/public/v1/projects/{projectId}/sources`

Include `config.runtimeTarget` with provider and target details:

```bash theme={null}
curl --request POST \
  --url http://localhost:3311/api/public/v1/projects/{projectId}/sources \
  --header "x-api-key: sb_api_your_team_key" \
  --header "content-type: application/json" \
  --data '{
    "name": "Supabase source",
    "schemaVersionId": "11111111-1111-1111-1111-111111111111",
    "kind": "postgres",
    "populate": false,
    "config": {
      "runtimeTarget": {
        "provider": "supabase",
        "schema": "sb_synth_data",
        "connectionString": "postgresql://postgres:[password]@db.abcd1234.supabase.co:5432/postgres",
        "projectRef": "abcd1234"
      }
    }
  }'
```

Synthbrew encrypts the provided connection string and stores only `runtimeTarget.connectionSecretId` in the returned source config.

## Rate limits

Supabase import and generation endpoints are rate-limited per team and provider. This keeps one provider workload from starving others in multi-project teams.

## Troubleshooting

### `permission denied for schema ...`

The Supabase database user is missing schema/table grants. Re-check grants for both introspection and write operations.

### Generation succeeded but expected tables are missing

Verify the configured runtime target schema on the source settings page. Data is written to that schema, not necessarily `public`.

### Read-only DB access section is missing for a source

This is expected for Supabase targets. Managed read-only role provisioning is only available for `managed` runtime targets.
