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

# How-to guides: Manage S3 ingestion

> This document shows how to prepare an S3 bucket in AWS, connect it to Zenskar, change or disconnect the bucket connection, and check that S3 ingestion reads its files.

## Prepare the bucket in AWS

The bucket gets a bucket policy for the [processor role](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#processor-role), and an event notification to the [Zenskar SQS queue](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#zenskar-sqs-queue).

### Prerequisites

* You need a role with the **Can Read Organisation Config** permission.
* You need permission in AWS to create buckets, edit bucket policies, and create event notifications.

### Steps

1. Go to **Settings** > **S3 Ingestion**. If the [bucket connection](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#bucket-connection) already exists, click **Edit**.

2. Under **Step 1 Configure your S3 bucket**, copy **Processor Role ARN**. Keep it for the bucket policy.

3. Copy **SQS Queue ARN**. Keep it for the event notification.

4. In AWS, create a bucket in the region `us-east-1`, or choose an existing bucket in that region. See [Creating a bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html).

5. Add the following statement to the bucket policy. If the bucket already has a policy, add the statement to its `Statement` list. See [Adding a bucket policy by using the Amazon S3 console](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html).

   ```json theme={null}
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Sid": "ZenskarReadUsageFiles",
         "Effect": "Allow",
         "Principal": { "AWS": "<processor-role-arn>" },
         "Action": "s3:GetObject",
         "Resource": "arn:aws:s3:::<bucket-name>/*"
       }
     ]
   }
   ```

6. Replace `<processor-role-arn>` with the value of **Processor Role ARN**. Replace `<bucket-name>` with the name of the bucket.

7. Save the bucket policy.

8. Create an event notification on the bucket with the following settings. See [Enabling and configuring event notifications using the Amazon S3 console](https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-event-notifications.html).

   | Setting | Value |
   | - | - |
   | Event types | All object create events (`s3:ObjectCreated:*`) |
   | Prefix | The prefix is optional. If you set one, every folder of a [usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event-collection) must start with it. |
   | Suffix | The suffix is optional. Zenskar reads only files whose names end in `.csv`. |
   | Destination | SQS queue, with the value of **SQS Queue ARN** |

   > [!WARNING]
   >
   > Zenskar reads only the notifications that the bucket sends directly to the Zenskar SQS queue. A notification that passes through Amazon SNS or Amazon EventBridge never reaches Zenskar, and the files are not read. Send the notification directly to the Zenskar SQS queue.

9. Save the event notification.

Next, connect the bucket in Zenskar. See [Connect the bucket in Zenskar](#connect-the-bucket-in-zenskar).

See [Step 1 Configure your S3 bucket](https://zenskar.com/docs/20260301/zenskar-modules/usage/reference/s3-ingestion.md#step-1-configure-your-s3-bucket).

## Prepare an ingestion-error bucket

This task is optional. With an [ingestion-error bucket](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#ingestion-error-bucket), Zenskar writes an [error file](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#error-file) for each file that it rejects.

### Prerequisites

* You need the value of **Processor Role ARN** from **Settings** > **S3 Ingestion**. See [Prepare the bucket in AWS](#prepare-the-bucket-in-aws).
* You need permission in AWS to create buckets and edit bucket policies.

### Steps

1. In AWS, create a bucket, or choose an existing bucket. It can be the bucket that holds the files of [usage events](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event). See [Creating a bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html).

2. Add the following statement to the bucket policy. If the bucket already has a policy, add the statement to its `Statement` list. See [Adding a bucket policy by using the Amazon S3 console](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html).

   ```json theme={null}
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Sid": "ZenskarWriteErrorFiles",
         "Effect": "Allow",
         "Principal": { "AWS": "<processor-role-arn>" },
         "Action": "s3:PutObject",
         "Resource": "arn:aws:s3:::<error-bucket-name>/*"
       }
     ]
   }
   ```

3. Replace `<processor-role-arn>` with the value of **Processor Role ARN**. Replace `<error-bucket-name>` with the name of the bucket.

4. Save the bucket policy.

Next, enter the bucket in **Ingestion Error Bucket (Optional)** when you connect the bucket in Zenskar. See [Connect the bucket in Zenskar](#connect-the-bucket-in-zenskar).

## Connect the bucket in Zenskar

### Prerequisites

* You need a role with the **Can Read Organisation Config** and **Can Update Organisation Config** permissions.
* The bucket must have its bucket policy and event notification. See [Prepare the bucket in AWS](#prepare-the-bucket-in-aws).
* If you add an [ingestion-error bucket](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#ingestion-error-bucket), it must have its bucket policy. See [Prepare an ingestion-error bucket](#prepare-an-ingestion-error-bucket).

### Steps

> [!WARNING]
>
> Zenskar does not test the bucket when you save. A wrong bucket name, bucket policy, or event notification gives no error here, and no [usage events](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event) arrive. Check the AWS settings before you save, and check the first file afterward. See [Check that S3 ingestion works](#check-that-s3-ingestion-works).

> [!WARNING]
>
> Without an ingestion-error bucket, Zenskar keeps no record of the files that it rejects. To keep a record, enter an ingestion-error bucket before you save.

1. Go to **Settings** > **S3 Ingestion**. The screen shows **Not Connected**.
2. Under **Step 2 Enter your bucket details**, in **S3 Bucket Name**, enter the name of the bucket, without the `s3://` prefix.
3. Optional: In **Ingestion Error Bucket (Optional)**, enter the name of the ingestion-error bucket, without the `s3://` prefix.
4. Click **Save Config**.

The dashboard confirms the change. Zenskar creates the [bucket connection](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#bucket-connection) of your [organization](https://zenskar.com/docs/20260301/zenskar-modules/settings/glossary.md#organization). The screen shows **Connected**. **Your S3 bucket** shows the bucket names.

Next, turn on S3 ingestion for each [usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event-collection) whose files are in the bucket. See [Set up S3 ingestion for a usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/usage-events.md#set-up-s3-ingestion-for-a-usage-event-collection).

See [Step 2 Enter your bucket details](https://zenskar.com/docs/20260301/zenskar-modules/usage/reference/s3-ingestion.md#step-2-enter-your-bucket-details).

## Change the bucket connection

### Prerequisites

* You need a role with the **Can Read Organisation Config** and **Can Update Organisation Config** permissions.
* To move the usage-event collections to the new buckets, you also need the **Can Read Usage Event** and **Can Update Usage Event** permissions.
* A new bucket must have its bucket policy and event notification. See [Prepare the bucket in AWS](#prepare-the-bucket-in-aws).
* A new [ingestion-error bucket](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#ingestion-error-bucket) must have its bucket policy. See [Prepare an ingestion-error bucket](#prepare-an-ingestion-error-bucket).

### Steps

> [!WARNING]
>
> Each [usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event-collection) keeps the buckets that were connected when its S3 ingestion was last saved. After you change a bucket, S3 ingestion still reads the old bucket for each usage-event collection, and [error files](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#error-file) still go to the old ingestion-error bucket. To move a usage-event collection to the new buckets, save its S3 ingestion again, as in steps 4 to 8.

1. Go to **Settings** > **S3 Ingestion**, and click **Edit**. The fields show the current bucket names.

2. Change **S3 Bucket Name**, **Ingestion Error Bucket (Optional)**, or both. To remove the ingestion-error bucket, clear its field.

3. Click **Save Config**. To discard the change, click **Cancel**.

   The dashboard confirms the change.

4. Go to **Usage** > **Usage Events**. The **S3 Ingestion** column shows the usage-event collections with S3 ingestion.

5. Click a usage-event collection with S3 ingestion.

6. Under **S3 Ingestion**, click **Edit**.

7. Click **SAVE**. You do not need to change the folders.

8. Repeat steps 5 to 7 for each usage-event collection with S3 ingestion.

The dashboard confirms each change. S3 ingestion now reads the new bucket for each usage-event collection, and error files go to the new ingestion-error bucket.

See [Step 2 Enter your bucket details](https://zenskar.com/docs/20260301/zenskar-modules/usage/reference/s3-ingestion.md#step-2-enter-your-bucket-details).

## Disconnect the bucket

### Prerequisites

* You need a role with the **Can Read Organisation Config** and **Can Update Organisation Config** permissions.

### Steps

> [!CAUTION]
>
> Disconnecting turns off S3 ingestion on every [usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event-collection). It also clears the folder and the [error folder](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#error-folder) of each usage-event collection. Connecting a bucket again does not restore them. Before you disconnect, note the folders of each usage-event collection.

1. Go to **Settings** > **S3 Ingestion**.
2. Click **Disconnect**. The dashboard asks you to confirm.
3. Click **Disconnect**.

The dashboard confirms the change, and shows **Not Connected**. Zenskar no longer reads the files that arrive in the bucket. The bucket policy and the event notification stay in AWS until you remove them there.

To use S3 ingestion again, connect a bucket, and then turn on S3 ingestion for each usage-event collection. See [Connect the bucket in Zenskar](#connect-the-bucket-in-zenskar) and [Set up S3 ingestion for a usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/usage-events.md#set-up-s3-ingestion-for-a-usage-event-collection).

See [Disconnect S3 Bucket dialog](https://zenskar.com/docs/20260301/zenskar-modules/usage/reference/s3-ingestion.md#disconnect-s3-bucket-dialog).

## Check that S3 ingestion works

### Prerequisites

* You need a role with the **Can Read Usage Event** permission.
* The [usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event-collection) must have S3 ingestion turned on. See [Set up S3 ingestion for a usage-event collection](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/usage-events.md#set-up-s3-ingestion-for-a-usage-event-collection).
* You need permission in AWS to upload files to the bucket.

### Steps

> [!WARNING]
>
> Zenskar reads a file only when its folder is exactly the folder of the usage-event collection. A file in a subfolder, or at the top level of the bucket, is not read, and gets no [error file](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#error-file). Upload the file directly into the folder of the usage-event collection.

> [!WARNING]
>
> A file with the same content as a file that Zenskar already stored adds no [usage events](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage-event). To test again with the same rows, change one value in the file.

1. Create a CSV file whose header row names every field of the [data schema](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#data-schema) of the usage-event collection, including `customer_id` and `timestamp`.

   To start from the right columns, download the sample file of the usage-event collection. See [Upload usage events from a CSV file](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/usage-events.md#upload-usage-events-from-a-csv-file).

2. Upload the file to the folder of the usage-event collection, such as `api_calls/test-2026-10-28.csv`. See [Uploading objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html).

   Keep the file in the bucket until its usage events appear. If the processing fails, Zenskar can download the file again to retry it.

3. In Zenskar, go to **Usage** > **Usage Events**, and click the usage-event collection.

4. Click **REFRESH TABLE**.

The **Events Table** shows the usage events of the file. When no usage events appear, open the error file of the test file in the [error folder](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#error-folder). Webhook alerts can also report the result of each file. See [Webhook alerts](https://zenskar.com/docs/20260301/zenskar-modules/settings/webhook-alerts.md).

See [Troubleshooting](https://zenskar.com/docs/20260301/zenskar-modules/usage/reference/s3-ingestion.md#troubleshooting).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.