Prerequisites
ACCOUNTADMIN(or equivalent) to create the role, the service user, and the token.- A network policy you can attach to that user. Snowflake refuses token authentication until one exists.
- A warehouse the role can use. Metadata queries need no compute, so the connection test can pass while real analysis still fails without one.
Setup
1
Create a read-only role
Run as
ACCOUNTADMIN. USAGE_VIEWER covers metering and storage, OBJECT_VIEWER covers object inventory, and GOVERNANCE_VIEWER is what makes QUERY_HISTORY readable:2
Create a service user
A
SERVICE user has no password, no MFA, and no SSO, so it authenticates only with the token:3
Attach a network policy
Narrow Skipping this step is the most common setup failure, and the resulting error (
ALLOWED_IP_LIST to your egress ranges for anything beyond a test account:390403) does not name the policy.4
Mint a programmatic access token
DAYS_TO_EXPIRY is a hard expiry: on that day the connection starts failing with 390318 and you mint a new token.5
Add the connection in CloudThinker
Go to Connections → Snowflake and enter:
- Account identifier:
MYORG-MYACCOUNT, found under Snowsight → Account details. Not the full URL. - Programmatic access token: the token from the previous step. Not an account password.
- Role: optional; leave blank to use the user’s default role.
- Warehouse: optional; leave blank to use the user’s default warehouse.
Connection details
Required permissions
Read-only (default)
GOVERNANCE_VIEWER is easy to miss. Without it, spend and storage answers keep working while every slow-query and error answer fails on QUERY_HISTORY.
Write access (only if you enable it)
OPERATE on the warehouses the agent may act on, never on a shared production warehouse. A dedicated agent warehouse with a resource monitor gives its compute a ceiling no prompt can raise.
Agent capabilities
Once connected, Tony can:Verify the connection
Example prompts
Write access
The connection ships read-only, and write is a per-connection decision because access follows the credential. One workspace can hold a read-only token and a write-capable token at the same time.
Turn it on under Connections → Snowflake → Tool permissions. Two things to weigh first:
- Write means exactly two actions, not arbitrary SQL. Raising a resource monitor, lowering
DATA_RETENTION_TIME_IN_DAYS, or resizing a warehouse is still reported to you as a statement to run in Snowsight. - The grant is the stronger control. The tool permission decides whether CloudThinker asks for a write; the token’s
ROLE_RESTRICTIONand the role’s grants decide whether Snowflake allows one.
Troubleshooting
Authentication fails immediately (390403)
Authentication fails immediately (390403)
The user has no network policy. Snowflake refuses token authentication until one is attached:
ALTER USER SVC_CLOUDTHINKER SET NETWORK_POLICY = CT_POLICY;It worked yesterday and now fails (390318)
It worked yesterday and now fails (390318)
The token expired or was revoked.
DAYS_TO_EXPIRY is a hard expiry. Mint a new token and update the connection.Connected, but every query fails (090073)
Connected, but every query fails (090073)
A resource monitor is over quota, or the warehouse is suspended and cannot resume. This is account capacity, not permission, so no
GRANT fixes it. An account admin raises or resets the resource monitor.The connection stays Connected because the credential is valid and the test probe needs no compute.No active warehouse selected (000606)
No active warehouse selected (000606)
The service user has no
DEFAULT_WAREHOUSE and none was configured. Set Warehouse on the connection, or give the user a default.A section comes back empty
A section comes back empty
Not an error.
ACCOUNT_USAGE lags by up to a few hours and keeps one year of history, so a narrow window over a quiet account returns no rows.Security
- Least privilege — grant only the permissions the agents need for your use case; start read-only and widen later.
- Read-only by default — use read-only credentials unless you want agents to make changes through this connection.
- Rotate credentials — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
- Revoke on offboarding — remove the credential at the provider when you delete a connection or a teammate leaves.
- Dedicated service user — a
TYPE = SERVICEuser has no password, no MFA, and no SSO, so the token is the only way in and the audit trail stays readable. - Restrict and expire the token —
ROLE_RESTRICTIONbounds everything the connection can reach, andDAYS_TO_EXPIRYforces a rotation you would otherwise forget.
Related
Tony Agent
Database-focused optimization agent
ClickHouse Connection
Similar setup for ClickHouse clusters