Pardon the mess

You are viewing docs related to an older version of Sequin. We’re in the process of updating our provider-specific guides and will be done in a few weeks (February 2024). Please click here to view the latest version of the docs.

If you’re interested in Stripe and want to learn more about what’s changing, send us a note.

Supported Objects

Collection NameReadWrite
account
application
balance_transaction
bank_account
billing_portal.configuration
billing_portal.session
charge
checkout.session
country_spec
credit_note
customer
customer_balance_transaction
dispute
event
fee_refund
file_link
invoice
invoiceitem
issuing.card
issuing.cardholder
issuing.dispute
issuing.transaction
item
line_item
mandate
order
order_return
payout
person
plan
price
product
promotion_code
radar.early_fraud_warning
radar.value_list_item
refund
reporting.report_run
reporting.report_type
reserve_transaction
scheduled_query_run
setup_intent
sku
source
source_mandate_notification
subscription
tax_deducted_at_source
tax_id
tax_rate
terminal.location
three_d_secure
transfer
upcoming_customer_invoice
upcoming_subscription_invoice
usage_record
usage_record_summary
webhook_endpoint

Stripe API key

To sync your Stripe data to your Sequin database, you just need to provide us with a Stripe API key.

Create a Stripe API key

While you can supply Sequin with a standard key, we recommend you provision us with a restricted key like so:

Step 1: Login to your Stripe dashboard and ensure you are in the correct account.

Step 2: In the Restricted keys section click the + Create restricted key button.

Step 3: In the top left, name the key something like “Sequin.”

Step 4: Under the “Permissions” column, select “Read” for every row except “All webhook resources.” For “All webhook resources,” select “Write.”

Step 5: Click Create.

Listed out, Sequin needs the following permissions:

  • All core resource: Read
  • All checkout resources: Read
  • All bulling resources: Read
  • All connect resources: Read
  • All orders resources: Read
  • All issuing resources: Read
  • All reporting resources: Read
  • All webhook resources: WRITE
  • CLI permissions: None

Test keys

To get familiar with How Sequin works with Stripe, you can always start by using your Stripe test key. Sequin resources that use a Stripe test API key are free to use.

To retrieve your Stripe test key, follow these steps:

Step 1: Login to your Stripe dashboard.

Step 2: Toggle to view your Stripe test data by flipping the View test data switch.

Step 3: Click the Reveal test key button.

Stripe database schema

Your Sequin database will contain all your Stripe data. We’re still working on an entity-relationship diagram (ERD) that you can use as a reference. We have one in progress here, but it’s not for the faint of heart!

The Stripe Sigma documentation is a helpful resource, as naturally a lot of our names and structure are similar.

Upcoming Objects

Stripe has several object types, such as Upcoming Invoices, which are only generated on-demand as previews.

Since these objects are not persistent in Stripe, they don’t have an id. In this case, Sequin uses the customer_id or subscription_id as a proxy for primary key. For example, the upcoming_customer_invoice table uses customer_id as the primary key. The upcoming_subscription_invoice table uses subscription_id as the primary key.

Unlike most objects, Stripe doesn’t create Events for changes to these objects. Instead, Sequin detects other events that are likely to trigger updates on these objects and immediately fetches an updated version from Stripe’s /v1/invoices/upcoming endpoint to keep your synced data up-to-date.

Stripe data types

Amounts

Stripe stores currency amounts in the smallest unit. Your Sequin data does the same.

So as an example, $10.00 USD will be stored as an integer value of 1000 in your Sequin database.

Currency

Currency types are stored as ISO 4217 Currency Codes in lower case.

JSON blobs

Some nested data structures are stored as type JSONB in your Sequin database.

The syncing process

Sequin workers first backfill your database with all your Stripe data by paginating through all Stripe API endpoints.

Then, after the backfill, Sequin workers poll Stripe’s /events endpoint twice per second to ingest any creates, updates, or deletes.

You can read more about how Sequin’s syncing process for Stripe works on our blog.

Writes

The Sequin Postgres Proxy

To create, update, or delete objects in Stripe, you can insert, update, or delete rows in your Postgres database.

When you’re connected to your database through the Sequin Proxy, the Proxy listens for changes. When you make a mutation, the Proxy applies the mutation to Stripe’s API first. If the mutation succeeds, your database is updated as well. If it fails, your database mutation will be rolled back, and you’ll receive a Postgres error.

Data flows from Stripe to your Postgres database. Your code or SQL client then reads from the database. To mutate your data, you update records in your database. Those mutations are applied to Stripe then to your database.

With this architecture, Stripe remains the source of truth and your database never gets out-of-sync.

How updates via the Proxy work

The Postgres Proxy forwards changes to Stripe’s API before applying them to your database.

The order of operations is therefore expressed in the following example, sequentially:

  1. You make an insert to create a new entry in the “Orders” table on Stripe.
  2. The Sequin Proxy forwards the request to Stripe.
  3. Stripe responds with a 200. The body contains the new order.
  4. The Sequin Proxy writes the new order to the orders table in your Sequin database.
  5. Your Postgres client returns successfully.

Was this page helpful?