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

# Stripe Reference

<Warning>
  **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 (May 2024). [Please click here](/docs/) 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](mailto:support@sequin.io).
</Warning>

## Supported Objects[](#supported-objects "Direct link to Supported Objects")

| Collection Name                 | Read | Write |
| ------------------------------- | ---- | ----- |
| 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[](#stripe-api-key "Direct link to Stripe API key")

To sync your Stripe data to your Sequin database, you just need to provide us with a [Stripe API key](https://stripe.com/docs/keys).

### Create a Stripe API key[](#create-a-stripe-api-key "Direct link to 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](https://dashboard.stripe.com/apikeys) 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[](#test-keys "Direct link to 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](https://dashboard.stripe.com/apikeys).

**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[](#stripe-database-schema "Direct link to 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](https://whimsical.com/public-stripe-wip-erd-MYPvj5FmHNt4YBKS94i4eR), but it's not for the faint of heart!

The [Stripe Sigma documentation](https://dashboard.stripe.com/sigma/schema) is a helpful resource, as naturally a lot of our names and structure are similar.

### Upcoming Objects[](#upcoming-objects "Direct link to 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[](#stripe-data-types "Direct link to Stripe data types")

### Amounts[](#amounts "Direct link to Amounts")

Stripe stores currency amounts in [the smallest unit](https://stripe.com/docs/currencies#zero-decimal). 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 "Direct link to Currency")

Currency types are stored as [ISO 4217 Currency Codes](https://www.iso.org/iso-4217-currency-codes.html) in lower case.

### JSON blobs[](#json-blobs "Direct link to JSON blobs")

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

## The syncing process[](#the-syncing-process "Direct link to 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](https://blog.sequin.io/stripe-sync-process).

## Writes[](#writes "Direct link to Writes")

### The Sequin Postgres Proxy[](#the-sequin-postgres-proxy "Direct link to 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[](#how-updates-via-the-proxy-work "Direct link to 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.
