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

# Run Snowflake SQL From an Agent, Token Hidden

> Let agents run SQL and browse Snowflake databases and warehouses with a programmatic access token that the gateway injects and the agent never sees.

## Overview

Buckle connects AI agents to [Snowflake](https://www.snowflake.com) through its SQL API, using a programmatic access token (PAT). Agents can run queries and browse your databases and warehouses. The gateway injects the token into every request, so your agent never sees it.

Connecting takes a few minutes.

## What you will set up

* A Snowflake programmatic access token tied to a limited role
* Automatic token injection on Snowflake SQL API requests
* Per-agent, per-tool access

## Connect Snowflake

**1. Create a programmatic access token in Snowflake**

In Snowsight, open your user menu, then **Settings** > **Authentication** > **Programmatic access tokens**, and click **Generate new token**. Name it `Buckle`, pick the role agents should use, and copy the token right away.

> [!WARNING]
>
> Snowflake only accepts a PAT from a user that's subject to a **network policy**, or to an authentication policy that lifts that requirement. If the token is rejected, ask your Snowflake admin. See [Snowflake's PAT prerequisites](https://docs.snowflake.com/en/user-guide/programmatic-access-tokens#prerequisites).

**2. Paste it in Buckle**

In the Buckle dashboard, open **Settings** > **Apps** > **Snowflake** and fill in:

* **Programmatic Access Token:** the token you copied.
* **Account Host:** your account's host from Snowsight, for example `myorg-myaccount.snowflakecomputing.com`.

Click **Connect Snowflake**.

![Buckle connect window for Snowflake, showing the setup guide link, the Programmatic Access Token and Account Host fields, and the Connect Snowflake button.](https://mintcdn.com/onecli-17d3f772/h1DTAVlDkLshz4JZ/images/integrations/snowflake/buckle-connect-snowflake.png?fit=max\&auto=format\&n=h1DTAVlDkLshz4JZ\&q=85\&s=6e2a6db8cf29a9ccf6f3c74f1c236b10)

The Snowflake connect window in Buckle.

> [!NOTE]
>
> The token runs as the role you picked. Use a role with only the access agents need, ideally read-only.

## What agents can do

| Area | What agents can do |
| - | - |
| **Query** | Run SQL statements, check a statement's status, cancel a running statement |
| **Browse** | List databases, warehouses, and the objects inside a database |

## Controlling access

[Grant](/docs/guides/agent-access.md) the connection to each agent that needs it, and choose per tool what runs freely, what needs approval, and what's blocked. **Execute SQL** can change data, so put it behind approval unless the Snowflake role is read-only. Organization [rules](/docs/guides/rules.md) add guardrails on top. A blocked request never reaches Snowflake.

To disconnect, remove the connection in **Settings** > **Apps** > **Snowflake**, then revoke the token in Snowsight under **Programmatic access tokens**.

## FAQ

> [accordion] How do I rotate my Snowflake token?
>
> Generate a new programmatic access token in Snowsight, then update it in **Settings** > **Apps** > **Snowflake**. Agents pick it up automatically. Then revoke the old token.

> [accordion] How do I keep the token out of the agent's context?
>
> Store it in Buckle. The gateway injects it at the proxy, so the agent never holds the token. See [How it works](/docs/how-it-works.md).

> [accordion] How do I keep an agent read-only?
>
> Pick a read-only role when you create the token. The token runs as that role.

> [accordion] Why is my token rejected?
>
> Snowflake only accepts a PAT from a user subject to a network policy, or an authentication policy that lifts that requirement. Ask your Snowflake admin.


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