# Import data from Google Cloud Storage

Automate recurring file imports from your Google Cloud Storage bucket to Stripe.

This guide explains how to import files from Google Cloud Storage (GCS) into the Stripe Data Management Platform. You can automate imports to keep the data used by your Stripe products up to date.

## Before you begin

1. A Google Cloud Storage bucket containing the files you want to import, and permission to change the bucket’s IAM policy and settings.
2. Admin account access to the [Stripe Dashboard](https://dashboard.stripe.com/data-management/connectors).

## Prepare your files in Google Cloud Storage

If you don’t have a bucket, follow Google’s instructions to [create a bucket](https://cloud.google.com/storage/docs/creating-buckets).

- Each file must be non-empty and no larger than 1 GiB. Stripe skips empty objects, folder placeholders, and larger files.
- Each filename must end with a supported extension, and the file format must match your data template. Stripe skips files that don’t match the template.

We support the following file formats:

- CSV (`.csv`)
- TSV (`.tsv`)
- JSON (`.json`)
- JSON Lines (`.jsonl`)

To request additional formats, [contact Stripe Support](https://support.stripe.com/).

## Set up the GCS connector

1. Sign in to the Dashboard and go to the [Connectors page](https://dashboard.stripe.com/data-management/connectors).
2. Select **+ Add connector** > **Google Cloud Storage**.
3. Enter a unique connector name, then select **Next**.
4. In **GCS bucket**, enter the bucket name without `gs://` or a path. To import only objects whose names start with a particular prefix, enter it in **Prefix**. For example, `reports/daily/` matches `reports/daily/sales.csv`.
5. Select **Next**. Copy the complete **Stripe access identifier**, which starts with `principalSet://`, and keep the setup panel open.

## Configure bucket settings and grant Stripe read access

Use either the [Google Cloud Console](https://docs.stripe.com/data/import-external-data/connectors/gcs.md#bucket-settings-console) or the [Google Cloud CLI](https://docs.stripe.com/data/import-external-data/connectors/gcs.md#configure-with-cli). Enable public access prevention and uniform bucket-level access before granting Stripe both read-only roles on the bucket.

> #### Use a dedicated bucket
> 
> A prefix limits which files Stripe imports, but the IAM grants apply to the whole bucket. Use a dedicated bucket if it contains other data. Before changing an existing bucket, review Google’s guidance on [public access prevention](https://cloud.google.com/storage/docs/using-public-access-prevention) and [uniform bucket-level access](https://cloud.google.com/storage/docs/using-uniform-bucket-level-access). Changing these settings can affect other applications.

### Use the Google Cloud Console 

1. In the [Google Cloud Console](https://console.cloud.google.com/storage/browser), select the project that contains your bucket. Open the bucket and select **Permissions**.
2. Under **Public access**, select **Prevent public access**, then **Confirm**. Skip this step if public access prevention is already enabled.
3. Under **Access control**, select **Switch to uniform**. In the dialog, select **Uniform**, then **Save**. Skip this step if uniform bucket-level access is already enabled.
4. In **Permissions**, select **Grant access**. In **New principals**, paste the Stripe access identifier.
5. Under **Assign roles**, select **Storage Object Viewer**. Select **Add another role**, choose **Storage Bucket Viewer**, then select **Save**.

### Use the Google Cloud CLI 

Sign in to the [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) with an account that can manage the bucket. Replace `BUCKET_NAME` with your bucket name and `STRIPE_ACCESS_IDENTIFIER` with the complete value you copied from Stripe. Then run these commands in order:



```bash
gcloud storage buckets update 'gs://BUCKET_NAME' \
  --public-access-prevention \
  --uniform-bucket-level-access

gcloud storage buckets add-iam-policy-binding 'gs://BUCKET_NAME' \
  --member='STRIPE_ACCESS_IDENTIFIER' \
  --role='roles/storage.objectViewer' \
  --condition=None

gcloud storage buckets add-iam-policy-binding 'gs://BUCKET_NAME' \
  --member='STRIPE_ACCESS_IDENTIFIER' \
  --role='roles/storage.bucketViewer' \
  --condition=None
```

## Preview files and create the connection

1. Return to the Dashboard and select **Next**. Select a data template that matches your files and complete any fields it requires.
2. Check that the sample contains the files you expect. Previewing doesn’t save the connection or import files, and the sample isn’t a complete listing.
3. Select **Done** to create the connection and start the first import.

The first import looks for eligible files modified in the past 90 days. After that, Stripe checks for files to import daily.

## Maintain your connection 

Use the [Connectors page](https://dashboard.stripe.com/data-management/connectors) to check connection status. Select a connection to manage its settings, restore access, or stop imports.

### Update connection settings 

- Select **Edit name** to rename the connection.
- Select **Edit template** to change the data template.
- Select **Re-authenticate** to change the bucket or prefix, or restore access.
- Select **View IAM policies** to see the Stripe access identifier and required bucket settings.

For file format errors, correct the file or template instead of changing IAM permissions.

Changing the bucket, prefix, or template doesn’t restart the 90-day lookback. To import a different dataset from the beginning, create a new connector.

### Manage file delivery

Automate delivery of new files to your bucket to keep imports up to date.

For faster imports, keep fewer than 50,000 objects under your prefix. The GCS API doesn’t filter objects by timestamp, so Stripe must list them on each import. Use Google’s [Object Lifecycle Management](https://docs.cloud.google.com/storage/docs/lifecycle) to remove old objects.

### Stop imports and revoke access

Delete the connection to stop imports. Deleting a connection doesn’t revoke the access granted to Stripe on the bucket.

To revoke access, remove both IAM role grants for the Stripe access identifier in the Google Cloud Console.
