> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/snowflake.md).

# Snowflake

Connect to Snowflake to run SQL queries, insert rows, modify data, and manage schemas in your data warehouse from your AI workflows.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector          | Authentication                    |
| ------------------ | --------------------------------- |
| Snowflake          | Password or RSA private key (PEM) |
| Snowflake (OAuth2) | OAuth sign-in                     |

#### Snowflake

Connect to Snowflake data warehouse to analyze and manage large volumes of data. Supports SQL queries and data operations across multiple clouds.

**Set up in Snowflake**

1. Choose a Snowflake user and role with access to the required warehouse, database, schema, and tables. Query workflows need warehouse, database, and schema USAGE plus SELECT on the relevant data. Write actions need the corresponding write privileges.
2. For key-pair authentication, generate an RSA key pair and assign its public key to the Snowflake user. Keep the private key for the StackAI connection. Follow the linked Snowflake key-pair instructions.
3. The StackAI field accepts an unencrypted RSA private key in PEM format. Paste the complete private-key file, including its BEGIN and END lines. Leave Password blank when using the key.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Snowflake**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field          | Required                 | What to enter                                                                                                                                                                      |
| ---------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| User                   | Yes                      | Snowflake user with access to the role selected below.                                                                                                                             |
| Password (Optional)    | Optional / as applicable | Snowflake password. Leave blank when using a private key.                                                                                                                          |
| Private Key (Optional) | Optional / as applicable | Unencrypted RSA private key in PEM format. Include the BEGIN and END lines; leave Password blank. [Provider instructions](https://docs.snowflake.com/en/user-guide/key-pair-auth). |
| Account                | Yes                      | Your Snowflake account identifier (e.g., 'myorg-account123' or 'xy12345.us-east-1'). [Provider instructions](https://docs.snowflake.com/en/user-guide/admin-account-identifier).   |
| Warehouse              | Yes                      | The virtual warehouse to use for compute resources.                                                                                                                                |
| Role                   | Yes                      | Role granted to the Snowflake user. Give this role access to the warehouse and objects needed by the workflow.                                                                     |
| Database               | Yes                      | The database to connect to.                                                                                                                                                        |
| Schema                 | Yes                      | The schema to use within the database.                                                                                                                                             |
| TOTP (Optional)        | Optional / as applicable | One-time authentication code for a password connection that uses TOTP.                                                                                                             |

**Connection notes**

* Password takes precedence when both Password and Private Key contain values. Use one authentication method per connection.
* The Role field controls the privileges used by the connection. Do not use ACCOUNTADMIN as a workaround for missing object permissions.

**Provider documentation:** [Setup reference 1](https://docs.snowflake.com/en/user-guide/key-pair-auth), [Setup reference 2](https://docs.snowflake.com/en/user-guide/admin-account-identifier).

#### Snowflake (OAuth2)

Connect to Snowflake data warehouse using OAuth2 authentication. Supports secure, token-based access to your Snowflake data.

**Set up in Snowflake**

1. Have a Snowflake administrator create an enabled Snowflake OAuth security integration for a custom confidential client. Configure the StackAI callback URL as the redirect URI and enable refresh tokens.
2. Retrieve the integration’s client ID and client secret with Snowflake’s SYSTEM$SHOW\_OAUTH\_CLIENT\_SECRETS function.
3. Grant the authorizing user the role and warehouse access needed by the workflow. In StackAI’s OAuth scopes, include refresh\_token and session:role: followed by that role name.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Snowflake (OAuth2)**.
2. Complete the connector configuration below. If you do not have access to these settings, ask your StackAI administrator to configure the connector.
3. Select **Connect**, sign in to the provider account, and review the requested access. Complete authorization to return to StackAI.
4. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connector configuration**

| StackAI field      | Required  | What to enter                                                                                                                                                                                                                                                                                              |
| ------------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OAuth Scopes       | Yes       | OAuth scopes to request. Must include refresh\_token for token refresh. By default, uses the PUBLIC role. To use a different role, replace 'session:role:PUBLIC' with 'session:role:YOUR\_ROLE\_NAME'. Note: ACCOUNTADMIN, SECURITYADMIN, and ORGADMIN roles are blocked from OAuth unless pre-authorized. |
| Client ID          | Yes       | OAuth Client ID from Snowflake security integration. Use SYSTEM$SHOW\_OAUTH\_CLIENT\_SECRETS to retrieve. [Provider instructions](https://docs.snowflake.com/en/user-guide/oauth-custom).                                                                                                                  |
| Client Secret      | Yes       | OAuth Client Secret from Snowflake security integration.                                                                                                                                                                                                                                                   |
| Redirect URI       | Read-only | Use this redirect URI when configuring your OAuth application. This value is shown for reference; it is not an editable credential.                                                                                                                                                                        |
| Account Identifier | Yes       | Your Snowflake account identifier. This is used to construct the OAuth endpoints. Format: 'orgname-accountname' or 'accountlocator.region.cloud'. [Provider instructions](https://docs.snowflake.com/en/user-guide/admin-account-identifier).                                                              |
| Default Warehouse  | Yes       | The default warehouse to use for compute operations.                                                                                                                                                                                                                                                       |

**Connection notes**

* Use the redirect URI shown in the StackAI connector configuration. A different callback URL or credentials from another security integration will prevent authorization.

**Provider documentation:** [Setup reference 1](https://docs.snowflake.com/en/sql-reference/sql/create-security-integration-oauth-snowflake), [Setup reference 2](https://docs.snowflake.com/en/user-guide/oauth-intro).

#### Verify the connection

Check that the connection is healthy, then verify access with a read operation:

1. Add **Query Snowflake** and select the saved connection.
2. Select a table the connection role is permitted to read. In **Query**, enter a read-only query such as `SELECT * FROM <database>.<schema>.<table> LIMIT 1`, replacing the placeholders with that table's identifiers.
3. Run the action. Inspect **Results** and **Row Count**. An empty table can return zero rows successfully. This query reads data and can consume warehouse compute.

A successful connection check confirms authentication. It does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

#### Detailed setup guides

* [Connect Snowflake](https://docs.stackai.com/integrations/catalog/snowflake/connect-snowflake.md)

## Use an action

1. Add the required **Snowflake** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Query Snowflake

Query a Snowflake database with a SQL query

**Inputs**

| Field    | Type                      | Required | Description                                                                              |
| -------- | ------------------------- | -------- | ---------------------------------------------------------------------------------------- |
| Tables   | multiple\_select (string) | Yes      | The tables and views in your Database Schema. Options load from the selected connection. |
| Query    | string                    | Yes      | SQL query to execute against the Snowflake database. Default: .                          |
| Database | string                    | No       | The database to use. If not provided, uses the database from the connection.             |
| Schema   | string                    | No       | The schema to use. If not provided, uses the schema from the connection.                 |

**Outputs**

| Field     | Type        | Description                                                                                                                                                       |
| --------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Query     | string      | The SQL query that was executed.                                                                                                                                  |
| Results   | dict\_array | Inline rows up to 100,000. Above that, this is a single entry with a file\_url pointing to a gzipped .csv.gz you must unzip; download it for the full result set. |
| Truncated | boolean     | True if the result set was truncated by the row cap.                                                                                                              |
| Row Count | integer     | Number of rows returned, whether inline or in the CSV file.                                                                                                       |

#### Insert Row to Snowflake

Insert a new row into a Snowflake table

> **Deprecated:** Use the 'Modify Snowflake Data' action with Operation set to Insert instead. The unified DML action also supports Update and Delete, plus a raw-SQL Advanced mode (MERGE and CTE-ending-in-DML). Existing workflows using this action continue to work.

**Inputs**

| Field      | Type            | Required | Description                                                                                                                                                                                           |
| ---------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Table Name | select (string) | Yes      | The name of the table where data will be inserted. Options load from the selected connection.                                                                                                         |
| Data       | string          | Yes      | The data to insert as a json string where keys are column names and values are the data to insert into the table.Example: {name: 'John Doe', email: '<john@example.com>', age: 30, is\_active: true}. |
| Database   | string          | No       | The database to use. If not provided, uses the database from the connection.                                                                                                                          |
| Schema     | string          | No       | The schema to use. If not provided, uses the schema from the connection.                                                                                                                              |

**Outputs**

| Field         | Type    | Description                                      |
| ------------- | ------- | ------------------------------------------------ |
| SQL Query     | string  | The INSERT SQL query that was executed.          |
| Rows Affected | integer | Number of rows affected by the insert operation. |
| Success       | boolean | Whether the insert operation was successful.     |

#### Manage Snowflake Schema

Manage Snowflake schema objects — tables, views, sequences, and more. General mode provides a guided form; Advanced mode accepts raw DDL SQL.

**Inputs**

| Field           | Type            | Required | Description                                                                                                                              |
| --------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Mode            | select (string) | Yes      | General mode provides a guided form; Advanced mode accepts raw DDL SQL. Available values: General, Advanced. Default: general.           |
| SQL Query       | string          | No       | Raw DDL SQL statement to execute. Only DDL statements are allowed (CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME).                      |
| Operation       | select (string) | No       | The DDL operation to perform. Available values: Create Table, Alter Table, Drop Table.                                                   |
| Table Name      | string          | No       | The target table name.                                                                                                                   |
| Columns         | string          | No       | JSON object mapping column names to their Snowflake types. Example: {"ID": "NUMBER AUTOINCREMENT PRIMARY KEY", "NAME": "TEXT NOT NULL"}. |
| Alter Type      | select (string) | No       | The type of alteration to perform. Available values: Add Column, Drop Column, Rename Column.                                             |
| Column Name     | string          | No       | The column to add, drop, or rename.                                                                                                      |
| Column Type     | string          | No       | The Snowflake type for the new column (used with Add Column).                                                                            |
| New Column Name | string          | No       | The new name for the column (used with Rename Column).                                                                                   |
| Database        | string          | No       | The database to use. If not provided, uses the database from the connection.                                                             |
| Schema          | string          | No       | The schema to use. If not provided, uses the schema from the connection.                                                                 |

**Outputs**

| Field     | Type    | Description                              |
| --------- | ------- | ---------------------------------------- |
| SQL Query | string  | The DDL SQL statement that was executed. |
| Success   | boolean | Whether the operation was successful.    |

#### Modify Snowflake Data

Insert, update, or delete rows in a Snowflake table. General mode provides a guided form; Advanced mode accepts raw DML SQL.

**Inputs**

| Field      | Type            | Required | Description                                                                                                                                                                                                                                                                                          |
| ---------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Mode       | select (string) | Yes      | General mode provides a guided form; Advanced mode accepts raw DML SQL. Available values: General, Advanced. Default: general.                                                                                                                                                                       |
| SQL Query  | string          | No       | Raw DML SQL statement to execute. Only DML statements are allowed (INSERT, UPDATE, DELETE, MERGE). WITH (CTE) expressions are supported. Snowflake CTE + INSERT syntax: 'INSERT INTO \<t> (cols) WITH \<cte> AS (...) SELECT ... FROM \<cte>' — the WITH clause must sit inside the INSERT's SELECT. |
| Operation  | select (string) | No       | The DML operation to perform. Available values: Insert, Update, Delete.                                                                                                                                                                                                                              |
| Table Name | select (string) | No       | The target table. Options load from the selected connection.                                                                                                                                                                                                                                         |
| Data       | string          | No       | JSON data for the operation (keys are column names). Required for Insert and Update. Example: {"NAME": "John"}.                                                                                                                                                                                      |
| Condition  | string          | No       | JSON object for the WHERE clause (keys are column names). All conditions are combined with AND. Example: {"NAME": "John", "STATUS": "active"}.                                                                                                                                                       |
| Database   | string          | No       | The database to use. If not provided, uses the database from the connection.                                                                                                                                                                                                                         |
| Schema     | string          | No       | The schema to use. If not provided, uses the schema from the connection.                                                                                                                                                                                                                             |

**Outputs**

| Field         | Type    | Description                               |
| ------------- | ------- | ----------------------------------------- |
| SQL Query     | string  | The SQL query that was executed.          |
| Rows Affected | integer | Number of rows affected by the operation. |
| Success       | boolean | Whether the operation was successful.     |

### Important behavior

If an operation is denied, check the connection’s granted permissions and the account’s access in the provider. Reauthorize the connection when it needs additional permissions.

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/snowflake.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
