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

# Snowflake Billing Setup

> Connect Snowflake account usage and billing data to Costory using key-pair authentication and a reusable Snowflake integration.

Snowflake billing ingestion uses a **Snowflake integration** you create once on the **Integrations** page, then attach to a billing datasource. Authentication is **key-pair** (RSA): Costory shows a **public** key for your Snowflake user; the **private** key is stored securely and is never returned after you save.

> [tab] Terraform
>
> To install and authenticate the provider, see [Terraform setup](https://docs.costory.io/setup/terraform.md).
>
> `integration_id` is the ID of an existing Costory Snowflake integration. Create it first on the **Integrations** page (step 1 in **Manual setup**).
>
> ```hcl theme={null}
> terraform {
>   required_providers {
>     costory = {
>       source  = "costory-io/costory"
>       version = ">= 0.1.0"
>     }
>   }
> }
>
> variable "costory_api_token" {
>   type        = string
>   description = "Costory API token."
>   sensitive   = true
> }
>
> provider "costory" {
>   token = var.costory_api_token
> }
>
> resource "costory_billing_datasource_snowflake" "main" {
>   name           = "Snowflake Billing"
>   integration_id = "snowflake-integration-id"
> }
> ```

> [tab] Manual setup
>
> ### 1. Create the Snowflake integration
>
> 1. Open Costory and go to **Integrations**.
> 2. Start the flow to add a **Snowflake** integration.
> 3. When Costory displays **setup SQL** and a generated **public RSA key**, copy them.
> 4. In the Snowflake console (or worksheet), run the setup SQL as a user who can alter the login for the Snowflake user Costory will use. This registers the public key for key-pair authentication.
>
> Set the warehouse to `AUTO_SUSPEND = 30` and `AUTO_RESUME = TRUE` so it suspends shortly after Costory queries.
>
> 5. Enter the Snowflake connection details Costory asks for (for example account identifier, user, role, and warehouse as shown in the stepper).
> 6. Complete validation. Costory checks access through the **Snowflake SQL API** before any sync is enabled.
>
> ### 2. Enable Snowflake billing
>
> 1. Go to **Billing** > **Import new billing datasource** > **Snowflake**.
> 2. Select the **Snowflake integration** you created above.
> 3. Finish the stepper. Costory provisions the billing sync and starts ingesting data.
>
> First sync timing is similar to other SaaS billing sources (on the order of **minutes**). See [Data refresh](https://docs.costory.io/docs/data-refresh.md) for ongoing cadence.

**What Costory includes**

* **Usage-based cost data** from Snowflake account usage (including views such as **USAGE\_IN\_CURRENCY\_DAILY**), with **warehouse** and **query** history where the connector exposes them for allocation and analysis. **Query tags** are included when Snowflake provides them, so query-level costs appear with tag dimensions you can use to filter and group in [Explorer](https://docs.costory.io/features/cost-explorer.md).

**What Costory does not include**

* **Terraform** automation for this datasource (use the UI only until Terraform support ships).

> [!NOTE]
>
> To remove access, delete or rotate credentials from the Costory UI and adjust Snowflake users and keys on your side. You cannot archive a Snowflake integration while an active billing datasource still references it.

## Related

* [Billing Data](https://docs.costory.io/setup/billing): overview of all billing sources
* [Snowflake Metrics](https://docs.costory.io/setup/usage-metrics/snowflake.md): query tables from another database on the same integration
* [Standard Columns](https://docs.costory.io/docs/standard-columns.md): normalized cost fields across providers
* [Explorer](https://docs.costory.io/features/cost-explorer.md): explore ingested costs after sync


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