Skip to content

Reference

Snowflake

Run SQL over the Snowflake SQL API through Alter Vault

Store a Snowflake programmatic access token (PAT) in Alter Vault and let agents run SQL over the Snowflake SQL API — without the token ever reaching agent code.

PropertyValue
Provider IDsnowflake
CategoryDatabase
Credential TypeProgrammatic Access Token

Sign in to Snowsight

Sign in to Snowsight.

Check the network-policy requirement

A human user can generate a token without a network policy but cannot authenticate with it until governed by one; a service user needs a network policy to generate or use the token (service-agent users are exempt, and an authentication policy’s NETWORK_POLICY_EVALUATION setting can relax the rule).

Generate a programmatic access token

Follow Snowflake’s programmatic access-token guide. In Snowsight, go to Governance & securityUsers & roles, select the user, open Programmatic access tokens, and click Generate new token — or in a worksheet, run:

ALTER USER my_user ADD PROGRAMMATIC ACCESS TOKEN agent_token
ROLE_RESTRICTION = 'MY_ROLE'
DAYS_TO_EXPIRY = 90;

Scope the token with ROLE_RESTRICTION so it carries only the privileges the integration needs. For service users (TYPE=SERVICE, SERVICE_AGENT, or LEGACY_SERVICE) Snowflake requires ROLE_RESTRICTION unless an authentication policy sets REQUIRE_ROLE_RESTRICTION_FOR_SERVICE_USERS to FALSE.

Copy the token secret

Copy the token secret (the token_secret column in the command output, or the value Snowsight displays) — it is shown only once.

Open the Developer Portal

Go to portal.alterauth.com and navigate to the application.

Add Snowflake

Go to Managed Secrets > Add Provider > Snowflake.

Enter credentials

Paste the programmatic access token into the credential field.

Save

Click Save. You’ll receive a grant_id to use with the SDK.

Submit SQL to the account’s SQL API endpoint. The token is injected via the Authorization: Bearer header automatically.

response = await alter_app.request(
HttpMethod.POST,
"https://YOUR_ACCOUNT.snowflakecomputing.com/api/v2/statements",
grant_id="YOUR_GRANT_ID",
json={
"statement": "SELECT id, name FROM customers WHERE region = ?",
"bindings": {"1": {"type": "TEXT", "value": "EMEA"}},
"warehouse": "MY_WH",
"database": "MY_DB",
"schema": "PUBLIC",
"timeout": 60,
},
)
  • YOUR_ACCOUNT is the account identifier in the host (<account_identifier>.snowflakecomputing.com); the SQL API path is /api/v2/statements.
  • The SQL API runs one statement per request (set MULTI_STATEMENT_COUNT for batches); interactive sessions require a driver and are not available over the REST API.
  • Programmatic access tokens expire after DAYS_TO_EXPIRY (15 days by default) — rotate the stored credential before then. Authenticating with a token requires the user to be subject to a network policy (service-agent users are exempt) unless an authentication policy relaxes it.

Alter policy rules can target these attested operations and families for operation-level and parameter-aware controls.

Operation IDFamiliesMethodProvider path
SubmitStatementadmin, delete, read, writePOST/api/v2/statements
GetStatementStatusreadGET/api/v2/statements/{statementHandle}
CancelStatementwritePOST/api/v2/statements/{statementHandle}/cancel
createDatabasewritePOST/api/v2/databases
deleteDatabasedeleteDELETE/api/v2/databases/{name}
fetchDatabasereadGET/api/v2/databases/{name}
listDatabasesreadGET/api/v2/databases
createSchemawritePOST/api/v2/databases/{database}/schemas
listSchemasreadGET/api/v2/databases/{database}/schemas
createTablewritePOST/api/v2/databases/{database}/schemas/{schema}/tables
listTablesreadGET/api/v2/databases/{database}/schemas/{schema}/tables
createWarehousewritePOST/api/v2/warehouses
deleteWarehousedeleteDELETE/api/v2/warehouses/{name}
fetchWarehousereadGET/api/v2/warehouses/{name}
listWarehousesreadGET/api/v2/warehouses
createUseradminPOST/api/v2/users
fetchUserreadGET/api/v2/users/{name}
listUsersreadGET/api/v2/users
createRoleadminPOST/api/v2/roles
deleteRoleadmin, deleteDELETE/api/v2/roles/{name}
listRolesreadGET/api/v2/roles
listRoleGrantsreadGET/api/v2/roles/{name}/grants
grantPrivilegeadminPOST/api/v2/grants/{granteeType}/{granteeName}/{securableType}/{securableName}/privileges

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.