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

# Set up a Snowflake destination

> Create a Snowflake role, service user, and access token so Cometly can load export data directly into your warehouse.

## Overview

A **Snowflake destination** is a reusable connection to a database and schema you own. Unlike an S3 or GCS destination — where Cometly writes Parquet files and you load them yourself — a Snowflake destination has Cometly **load the data directly into a table in your warehouse** on each run. Your warehouse's own compute does the load.

You give Cometly a role that can create and append to a table in one schema, and a token to authenticate with. Cometly handles the rest.

## Prerequisites

* A Snowflake account, and a role that can create warehouses, databases, roles, users, and network policies (typically `ACCOUNTADMIN`).
* A space administrator role in Cometly.

## Connect Cometly to Snowflake

**1. Create the Snowflake objects**

In Snowflake (as a role such as `ACCOUNTADMIN`), set up:

* A **warehouse** for Cometly to run the load on.
* A **database and schema** to hold the exported tables.
* A **role** that can `CREATE TABLE` in that schema (grant it `USAGE` on the warehouse, database, and schema, plus `CREATE TABLE` on the schema).
* A **network policy** — required for a service user's token to work. Restrict its allowed IPs for production use.
* A **service user** (type `SERVICE`), granted the role above and governed by that network policy.
* A **programmatic access token** on that service user, restricted to the role. Copy the token secret — it is shown only once.

**2. Find your account identifier**

```sql theme={null}
SELECT CURRENT_ORGANIZATION_NAME() AS org, CURRENT_ACCOUNT_NAME() AS account;
```

Your account identifier is `org-account` (with a hyphen) — for example, `myorg-ab12345`. Use that,
**not** the full `https://…snowflakecomputing.com` URL.

**3. Add the destination in Cometly**

In the dashboard, go to **Integrations → Snowflake → Add destination** and enter:

**Name** `string` *required*

A label for this destination, for example "Production warehouse".

**Account identifier** `string` *required*

Your `org-account` identifier from the query above.

**Warehouse** `string` *required*

The warehouse Cometly runs the load on, for example `cometly_wh`.

**Database** `string` *required*

The database that holds the target schema, for example `cometly_db`.

**Schema** `string` *required*

The schema Cometly creates the table in, for example `exports`.

**Role** `string` *required*

The role Cometly uses — it must be able to `CREATE TABLE` in the schema, for example `cometly_role`.

**Access token** `string` *required*

The programmatic access token secret from the setup script.

Cometly runs a quick connection check on save. If it succeeds, the destination is connected.

> [!NOTE]
>
> The access token is encrypted at rest and never shown again. Programmatic access tokens **expire**
> (`DAYS_TO_EXPIRY`) — rotate the token in Snowflake and update the destination before then, or the
> export will start failing.

> [!WARNING]
>
> A service user's token only works when the user is governed by a **network policy** (created in the
> setup script above). Without one, Snowflake rejects the token. Restrict the policy's `ALLOWED_IP_LIST`
> for production use.

> [!NOTE]
>
> Cometly creates each export's table **as the role above**, so that role owns it. To let your own
> reporting roles read the exported tables, grant them access — a one-time **future grant** covers
> every table Cometly creates:
>
> ```sql theme={null}
> GRANT SELECT ON FUTURE TABLES IN SCHEMA cometly_db.exports TO ROLE <your_reporting_role>;
> ```

## Next step

> [card] [Create an export](https://docs.cometly.com/data-warehouse/create-export.md)
>
> Choose this destination, a dataset, a target table name, and a date range.


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