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

# Amazon Redshift

> Connect Amazon Redshift to sync contacts, custom objects, and events into Conversion.

## Set Up

### Before You Begin

Make sure you have the following before starting:

* **Admin access in AWS and Redshift:** You'll need to create an IAM user and policy in AWS, and run grants as an administrator in your Redshift database.
* **A Redshift deployment:** A Redshift Serverless workgroup or a provisioned cluster.
* **The data you want to sync identified:** Know which database, and which schemas and tables, Conversion should be able to read from.

***

### Step 1: Set Up Redshift Access

Conversion connects to Redshift through the AWS Redshift Data API using an IAM access key. In this step you'll create a dedicated IAM user with a policy that allows Data API calls, then create an access key for it.

> [!NOTE]
>
> Your cluster can stay private. Conversion uses the AWS Redshift Data API, so you don't need a public endpoint or an IP allowlist.

#### Create an IAM User and Policy

We recommend creating a **dedicated IAM user** for Conversion so its activity is easy to monitor and revoke.

1. In the AWS console, open **IAM → Users → Create user**.
2. Enter a user name such as `conversion_sync` and finish creating the user.
3. Open the user and go to **Permissions → Add permissions → Create inline policy**.
4. Select **JSON** and paste the policy below for your Redshift deployment.
5. Replace the ARN placeholders with your AWS Region, account ID, and workgroup ID or cluster identifier and database name.
6. Review and create the policy with a name such as `ConversionRedshiftSync`.

For Serverless, copy the workgroup ARN from its details in the Amazon Redshift console. The ARN uses the workgroup's ID, not its name. For a provisioned cluster, copy the cluster ARN from its properties. In the separate `dbname` ARN, use the same cluster identifier and the database name you will enter in Conversion.

> [tab] Serverless workgroup
>
> ```json theme={null}
> {
>   "Version": "2012-10-17",
>   "Statement": [
>     {
>       "Effect": "Allow",
>       "Action": [
>         "redshift-data:ExecuteStatement",
>         "redshift-serverless:GetCredentials"
>       ],
>       "Resource": "arn:aws:redshift-serverless:<region>:<account-id>:workgroup/<workgroup-id>"
>     },
>     {
>       "Effect": "Allow",
>       "Action": [
>         "redshift-data:DescribeStatement",
>         "redshift-data:GetStatementResult",
>         "redshift-data:CancelStatement"
>       ],
>       "Resource": "*"
>     }
>   ]
> }
> ```

> [tab] Provisioned cluster
>
> ```json theme={null}
> {
>   "Version": "2012-10-17",
>   "Statement": [
>     {
>       "Effect": "Allow",
>       "Action": "redshift-data:ExecuteStatement",
>       "Resource": "arn:aws:redshift:<region>:<account-id>:cluster:<cluster-identifier>"
>     },
>     {
>       "Effect": "Allow",
>       "Action": "redshift:GetClusterCredentialsWithIAM",
>       "Resource": "arn:aws:redshift:<region>:<account-id>:dbname:<cluster-identifier>/<database>"
>     },
>     {
>       "Effect": "Allow",
>       "Action": [
>         "redshift-data:DescribeStatement",
>         "redshift-data:GetStatementResult",
>         "redshift-data:CancelStatement"
>       ],
>       "Resource": "*"
>     }
>   ]
> }
> ```

The statement status, result, and cancellation actions require `Resource: "*"` because they do not support resource-level permissions. Query execution is scoped to your workgroup or cluster. Serverless credentials are scoped to your workgroup; provisioned credentials are scoped to the database in your cluster. See the [AWS Data API permissions reference](https://docs.aws.amazon.com/service-authorization/latest/reference/list_redshift-data.html) and [Redshift permissions reference](https://docs.aws.amazon.com/service-authorization/latest/reference/list_redshift.html).

#### Create an Access Key

1. Open the IAM user's **Security credentials** tab.
2. Under **Access keys**, click **Create access key**.
3. Choose **Application running outside AWS** and complete the access key creation flow.
4. Save the **Access key ID** and **Secret access key**. AWS shows the secret only once. You'll enter both in Conversion in Step 2.

> [!NOTE]
>
> To rotate your access key, create a new key for the same IAM user and update the credentials in your Conversion connection before deactivating the old key.

***

### Step 2: Connect Redshift to Conversion

1. In Conversion, go to **Settings → CRM and syncing → Connections**.
2. Click **Add Amazon Redshift connection**.
3. Fill in the connection details using the values from Step 1:
   | Field | What to enter |
   | - | - |
   | **Name** | A label such as `Production Redshift` |
   | **Region** | The AWS Region containing your workgroup or cluster, such as `us-east-1` |
   | **Database** | The database containing the tables you want to sync |
   | **Deployment** | **Serverless** for a workgroup or **Provisioned** for a cluster |
   | **Workgroup name** | For **Serverless**, your workgroup name, not its ARN or ID |
   | **Cluster identifier** | For **Provisioned**, your cluster identifier, not its ARN |
   | **Access key ID** | The IAM user's access key ID |
   | **Secret access key** | The IAM user's secret access key. Conversion stores it encrypted. |
4. Click **Create connection**.

Conversion verifies the connection. The check doesn't read any tables, so it succeeds before you grant database access in Step 3.

***

### Step 3: Grant Read Access to Your Data

Redshift maps your IAM user to a database user named `IAM:<iam-user-name>`. That user appears after the connection check in Step 2.

In the Amazon Redshift query editor, connect to your target database as an administrator. Replace the schema, table, and IAM user name below, then run:

```sql theme={null}
GRANT USAGE ON SCHEMA <schema> TO "IAM:<iam-user-name>";
GRANT SELECT ON <schema>.<table> TO "IAM:<iam-user-name>";
```

To read all existing tables in a schema, use this instead of the per-table grant:

```sql theme={null}
GRANT SELECT ON ALL TABLES IN SCHEMA <schema> TO "IAM:<iam-user-name>";
```

For tables added later, run this as the database user that creates those tables:

```sql theme={null}
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema> GRANT SELECT ON TABLES TO "IAM:<iam-user-name>";
```

Repeat the default-privilege grant for each table creator. See [AWS default privileges](https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_DEFAULT_PRIVILEGES.html).

Repeat the grants for each schema and table you want to sync. The IAM policy permits Data API calls; these database grants permit reading your data.

> [!NOTE]
>
> The table picker lists only tables in schemas where your IAM database user has `USAGE` and tables where it has `SELECT`. If a table is missing, check both grants.

Onboarding with Conversion? Let your Deployment Strategist know when this is done and we'll check it on our end.

***

## Create a Sync

After connecting, open your new Redshift connection and go to the **Syncs** tab to create a sync. Read more about [Setting Up a Sync](https://docs.conversion.ai/product-docs/sync/data-warehouse/overview.md#setting-up-a-sync).

***

## Redshift SQL Reference

### Column Names

Select each destination field as its own column, named with the field key. Redshift lowercases column names. To keep mixed case, quote the alias and enable `enable_case_sensitive_identifier` on your cluster.

Every result column needs a unique name. Duplicate or unnamed columns fail the sync even when preview works. Give expressions explicit aliases and rename duplicate columns from joins.

### Converting Timestamps

Conversion expects Unix timestamps for date/time fields. Use `EXTRACT(EPOCH FROM column)::bigint` to convert Redshift `TIMESTAMP` values to Unix seconds:

```sql theme={null}
SELECT
  email,
  EXTRACT(EPOCH FROM created_at)::bigint AS created_at,
  EXTRACT(EPOCH FROM last_login)::bigint AS last_login
FROM my_schema.users
WHERE updated_at >= TIMESTAMP 'epoch' + {{last_sync_time}} * INTERVAL '1 second'
```

### Using last\_sync\_time

See [Incremental Syncing](https://docs.conversion.ai/product-docs/sync/data-warehouse/overview.md#incremental-syncing) for how `last_sync_time` works. In Redshift, add it to `TIMESTAMP 'epoch'` as seconds to compare against a `TIMESTAMP` column:

```sql theme={null}
WHERE updated_at >= TIMESTAMP 'epoch' + {{last_sync_time}} * INTERVAL '1 second'
```

Or convert your column to Unix seconds and compare integers directly:

```sql theme={null}
WHERE EXTRACT(EPOCH FROM updated_at)::bigint >= {{last_sync_time}}
```

With a [time buffer](https://docs.conversion.ai/product-docs/sync/data-warehouse/overview.md#time-buffered-queries):

```sql theme={null}
WHERE updated_at >= TIMESTAMP 'epoch' + ({{last_sync_time}} - 300) * INTERVAL '1 second'  -- 5 minute buffer
```

### Handling NULLs

Use `COALESCE` or `NVL` to provide default values:

```sql theme={null}
SELECT
  email,
  COALESCE(first_name, '') AS first_name,
  NVL(phone, '') AS phone
FROM my_schema.users
```

### Casting Types

Use `CAST` or `::` to convert between types:

```sql theme={null}
SELECT
  email,
  CAST(account_id AS VARCHAR) AS account_id,
  score::integer AS lead_score
FROM my_schema.users
```

### Events

Select the contact's email, event name, event time as Unix seconds in text, and a unique event ID. Quote the `timestamp` alias, since `timestamp` is a reserved word in Redshift:

```sql theme={null}
SELECT
  u.email,
  'purchase_completed' AS event_name,
  EXTRACT(EPOCH FROM o.created_at)::bigint::varchar AS "timestamp",
  'order:' || o.id::varchar AS event_id,
  o.total_amount,
  o.product_name,
  o.currency
FROM my_schema.orders o
JOIN my_schema.users u ON o.user_id = u.id
WHERE o.created_at > TIMESTAMP 'epoch' + {{last_sync_time}} * INTERVAL '1 second'
```

Use an `event_id` that is unique across your event syncs so retries can deduplicate events. See [Syncing Custom Events from a Warehouse](https://docs.conversion.ai/product-docs/sync/data-warehouse/custom-events.md).

***

## Troubleshooting

### "Missing permission" errors

AWS or Redshift rejected the IAM user. Check that:

* The access key ID and secret access key belong to the same active IAM access key. AWS reports a mismatched or deleted key as an invalid security token.
* For Serverless, the policy grants `redshift-serverless:GetCredentials` on the workgroup ARN. For a provisioned cluster, it grants `redshift:GetClusterCredentialsWithIAM` on the `dbname` ARN for your cluster and database.
* The database user `IAM:<iam-user-name>` has `USAGE` on each schema and `SELECT` on each table from [Step 3](#step-3-grant-read-access-to-your-data), in the database you entered in Conversion.

### "Could not connect" errors

Verify that:

* The **Region** is the one containing your workgroup or cluster
* **Deployment** matches your setup: **Serverless** for a workgroup, **Provisioned** for a cluster
* The workgroup name is its name, not its ARN or ID, and the cluster identifier is not an ARN
* The database name exists in that workgroup or cluster

### "Workgroup or cluster is starting" errors

A paused or resuming workgroup or cluster rejects queries until it's available. Wait for it to become available, then try again.

### Previews work but syncs fail

Sync queries need unique, named columns. See [Column Names](#column-names).

### "The query result is too large. Add a filter or a LIMIT." errors

Add a `{{last_sync_time}}` filter to limit the query to changed rows.

### Sync taking too long

For general tips, see [Sync Taking Too Long](https://docs.conversion.ai/product-docs/sync/data-warehouse/overview.md#sync-taking-too-long).

***

## Frequently Asked Questions

> [accordion] What Redshift permissions does Conversion need?
>
> The IAM user needs the Data API and credentials actions in the [IAM policy](#create-an-iam-user-and-policy). Its database user needs `USAGE` on the schemas and `SELECT` on the tables you want to sync. See [Grant Read Access to Your Data](#step-3-grant-read-access-to-your-data). Conversion only reads your tables. Each sync also creates a temporary table that Redshift drops when the sync ends; Redshift lets every database user create temporary tables by default.

> [accordion] Why doesn't Conversion ask for a database password?
>
> Conversion uses the Data API with IAM authentication. You provide an IAM access key and grant database access to its mapped user.

> [accordion] Does syncing use Redshift compute?
>
> Yes. Each sync runs your query and retrieves the results in pages through the Data API. [Serverless compute](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-billing-on-demand.html) is billed per second with a 60-second minimum charge. See that AWS page for how the minimum applies.

> [accordion] How do I sync from multiple schemas?
>
> Grant `USAGE` and `SELECT` on each schema and use schema-qualified table names in your query:
>
> ```sql theme={null}
> SELECT u.email AS email, o.order_id AS order_id
> FROM crm.users u
> JOIN sales.orders o ON u.id = o.user_id
> ```


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