Prepare for the PgBouncer and IPv4 deprecations on 26th January 2024

Learn more
Back
Sequin

Sequin

Sequin
Sequin
Sequin
Sequin

Overview

Sequin syncs data between APIs and Postgres. No more polling, webhooks, query parameters, or HTTP errors.

Sequin lets you integrate without using bespoke, limited HTTP APIs. Instead, integrate with third-party platforms like Salesforce or Stripe using your Postgres database.

Select the objects and fields you want to work with, like Salesforce Contacts or Stripe Subscriptions. Then specify how you want these objects and fields to translate into tables and columns in your Postgres database.

Sequin will setup a real-time, persistent sync to keep the data between Postgres and the API up-to-date. When changes are made in the API, they're synced to Postgres. When changes are made in Postgres, they're synced to the API.

Documentation

This guide explains how to quickly setup a sync between Sequin and a Supabase Postgres database.

Sequin allows you to sync platforms like Stripe and Salesforce with Supabase in real-time. You'll be able to read and write to your Stripe customers or Salesforce accounts right from the Supabase client using SQL. Here's how to get setup.

Step 1: Connect Sequin to Supabase

To connect Supabase to Sequin, you'll first need to retrieve the credentials for your Supabase Postgres database:

  1. In the Supabase dashboard, go to the settings page and open up your Database settings. In the Connection info section, you'll find the credentials you need - like host and user:

    Database connection parameters for Sequin

  2. In the Sequin console, go to your sync's configuration and open the Destination section. Select Launch or Connect and then click Connect to configure the connection to your Supabase Postgres:

    TBD

  3. In the connection modal that appears, enter the Host and Port for your Supabase database and click Continue.

    TBD

  4. Now, enter the Database name and set the schema name for your sync. For instance, if your syncing Stripe, you'll likely want to name your synced schema something like stripe. Finally, enter the user and password for your Supabase database and then click Continue. Sequin will verify it can properly connect to your database with the correct permissions.

    TBD

  5. Sequin is now connected to your Supabase Postgres database and will ask you to confirm which database users should be able to access your synced schema. Select all of the users and click Continue:

    TBD

  6. That's it. Sequin will now create a new schema and permissions group in your Supabase database. Name the database connection in Sequin something like Supabase and your done!

In the Supabase dashboard, you can go to the Table Editor and you'll see a new schema full of your synced platform data.

TBD

Step 2: Grant Permissions

To ensure the right users can access the synced schema Sequin manages, you'll need to run a couple permission grants.

  1. In the Sequin console, click the Connect button next to your sync and copy down your Schema and unique Read Group.

    TBD

  2. Now, in the Supabase dashboard, go to the SQL Editor and run the following permission grants:


    _10
    GRANT sequin_read_▒▒▒▒ TO postgres, anon, authenticated, service_role;
    _10
    _10
    GRANT USAGE ON SCHEMA {{your_schema_name}} TO anon, authenticated, service_role;
    _10
    _10
    GRANT ALL ON ALL TABLES IN SCHEMA {{your_schema_name}} TO anon, authenticated, service_role;
    _10
    _10
    ALTER DEFAULT PRIVILEGES FOR ROLE postgres, supabase_admin IN SCHEMA {{your_schema_name}} GRANT ALL ON TABLES TO anon, authenticated, service_role;

    These permission grants ensure that the various Supabase database users can access and read all the tables in your synced schema.

Step 3: Configure the Supabase Client

Finally, you'll need to define a new Supabase client in your application to access your synced schema. In the file where you initialized your Supabase client, define a new client with a schema parameter:


_10
export const supabase_schema = createClient(
_10
'https://xyzcompany.supabase.co',
_10
'public-anon-key',
_10
{
_10
schema: {{your_schema_name}},
_10
}
_10
);

You'll use this client to query for data in your synced schema.

Resources

Details

DeveloperSequin
CategoryAPI