Per-user quota method reference

The following tables list the methods available on a quota object. Call each method using the syntax <quota_name>!<METHOD>(...). For detailed descriptions, parameters, and examples, see the linked sections.

Create a quota

Use the following command to create a quota:

CommandDescription
CREATE SNOWFLAKE.CORE.QUOTA <name>()Create a per-user quota object. See Create a quota with SQL.

Monitored domains

Use the following methods to choose what the quota monitors:

MethodDescription
ADD_SHARED_RESOURCE('<domain>'[, '<resource>'])Add a monitored domain, or a specific resource within a domain, to the quota. See Supported domains.
REMOVE_SHARED_RESOURCE('<domain>'[, '<resource>'])Remove a monitored domain, or a specific resource within a domain, from the quota. See REMOVE_SHARED_RESOURCE.

User scope

Use the following methods to define and inspect which users the quota covers:

MethodDescription
SET_QUOTA_USER_SCOPE(<scope>)Replace the lists in the applies_to, excluded_by, and usernames sections that you pass. Lists you omit are unchanged. Returns the resulting user scope as a JSON string. See Set the user scope.
ADD_QUOTA_USER_SCOPE(<scope>)Add user tags, roles, or user names to the lists that you pass. Doesn’t accept type or operator. Returns the resulting user scope as a JSON string. See Add to or remove from the user scope.
REMOVE_QUOTA_USER_SCOPE(<scope>)Remove user tags, roles, or user names from the lists that you pass. Doesn’t accept type or operator. Returns the resulting user scope as a JSON string. See Add to or remove from the user scope.
GET_QUOTA_SCOPE_V2()Return the full user scope (include, exclude, and named users) and the monitored domains as a JSON string. See Verify the user scope.
GET_USERS()Return the users currently resolved into the quota’s scope.

Legacy user scope methods

The following methods still work but can’t select or exclude users by role. For replacements, see Migrate to the new scope methods.

MethodDescription
SET_USER_TAGS([[<tag_ref>, '<value>'], ...], '<operator>')Replace the include tags and set the operator (UNION or INTERSECTION, required). Roles don’t change. See SET_USER_TAGS.
SET_USER_TAGS([], 'ALL_USERS')Return the quota to all users. Pass an empty tag array. Also clears the tag exclusions and, when changing from a group scope, the username lists. Roles don’t change. See SET_USER_TAGS.
EXCLUDE_USERS('TAG', [[<tag_ref>, '<value>'], ...])Replace the tag exclusions. See EXCLUDE_USERS with tags.
INCLUDE_USERS(['<user>', ...])Add users to the include list by name. See INCLUDE_USERS and EXCLUDE_USERS with user names.
EXCLUDE_USERS('USER', ['<user>', ...])Add users to the exclude list by name. See INCLUDE_USERS and EXCLUDE_USERS with user names.
GET_QUOTA_SCOPE()Return the monitored domains, the users included and excluded by name, and the include and exclude tags and the operator. Doesn’t return roles.

Spending limits

Use the following methods to set and read per-user limits:

MethodDescription
SET_PER_USER_LIMIT(<credits>[, '<cycle>'])Set the per-user credit limit. The value must be a whole number from 1 to 1,000,000,000; zero, negative, NULL, and decimal values return an error. The optional cycle argument accepts 'MONTHLY', 'WEEKLY', or 'DAILY'; the default is monthly. See Set per-user spending limits.
UNSET_PER_USER_LIMIT('<cycle>')Remove the per-user limit for a cycle: 'MONTHLY', 'WEEKLY', or 'DAILY'. The cycle is required.
GET_CONFIG()Return the quota configuration, including PER_USER_LIMIT, PER_USER_LIMIT_WEEKLY, PER_USER_LIMIT_DAILY, and BLOCK_ENFORCEMENT_ENABLED.

Limit overrides

Use the following methods to set, list, and remove per-user limit overrides:

MethodDescription
SET_USER_QUOTA_OVERRIDE(['<user>', ...], '<cycle>', <credits> [ , <expires_on> ])Create or update a per-user credit limit override for one or more users on a cycle ('MONTHLY', 'WEEKLY', or 'DAILY'), with an optional expiration date (DATE or NULL). See Set or update a limit override.
LIST_USER_QUOTA_OVERRIDES()Return all overrides stored on the quota, including USER_ID, USER_NAME, CYCLE, OVERRIDE_VALUE, and EXPIRY_DATE. See View configured overrides.
REMOVE_USER_QUOTA_OVERRIDE('<user>', '<cycle>')Remove the override for one user and one cycle. See Remove limit overrides.
REMOVE_USER_QUOTA_OVERRIDES_BY_USER('<user>')Remove all overrides for one user across every cycle on this quota. See Remove limit overrides.
REMOVE_USER_QUOTA_OVERRIDES_BY_CYCLE('<cycle>')Remove all overrides for the specified cycle across every user on this quota. See Remove limit overrides.
REMOVE_ALL_USER_QUOTA_OVERRIDES()Remove every override on this quota. See Remove limit overrides.

Enforcement

Use the following methods to manage and review block enforcement:

MethodDescription
SET_BLOCK_ENFORCEMENT_ENABLED(<enabled>, <notify_user>)Turn built-in block enforcement on or off. The first Boolean argument enables or disables enforcement. The second Boolean argument specifies whether users are emailed when they’re blocked. See Block users at the limit.
GET_ACTIVE_BLOCKS_V2()Return the users currently blocked by this quota.
GET_ENFORCEMENT_HISTORY('<start>', '<end>')Return the blocking and unblocking history for this quota over a date range.

Notifications

Use the following methods to manage user notifications and admin summaries:

MethodDescription
ADD_NOTIFICATION_THRESHOLD(<threshold>, '<strategy>', <notify_user>[, '<cycle>'])Add an individual-user notification threshold. The optional cycle accepts 'MONTHLY', 'WEEKLY', or 'DAILY'; the default is monthly. See Configure notifications.
REMOVE_NOTIFICATION_THRESHOLD(<threshold>, '<strategy>'[, '<cycle>'])Remove a notification threshold. If you omit the cycle, only the monthly threshold is removed.
GET_NOTIFICATION_THRESHOLDS()List configured notification thresholds and their cycles.
ADD_NOTIFICATION_INTEGRATION('<name>')Add a notification integration for admin summaries.
REMOVE_NOTIFICATION_INTEGRATION('<name>')Remove a notification integration.
GET_NOTIFICATION_INTEGRATIONS()List configured notification integrations.
SET_ADMIN_EMAILS('<email>, ...')Set admin summary email recipients.

Custom actions

Use the following methods to manage stored procedures that run at thresholds:

MethodDescription
ADD_CUSTOM_ACTION(<sproc_ref>, <args>, '<strategy>', <threshold>)Register a stored procedure to run when a threshold is crossed. See Configure custom actions.
REMOVE_CUSTOM_ACTIONS([<threshold>[, '<sproc_fqn>']])Remove all custom actions, those at a threshold, or a specific procedure at a threshold.
GET_CUSTOM_ACTIONS()List configured custom actions.
CONFIRM_CUSTOM_ACTIONS_ACCESS()Verify the quota’s owner role can invoke the configured procedures.

Cycle-start action

Use the following methods to manage the procedure that runs at the start of each month:

MethodDescription
SET_CYCLE_START_ACTION(<sproc_ref>, <args>)Set the procedure to run at the start of each UTC calendar month. See Configure a cycle-start action.
GET_CYCLE_START_ACTION()Return the configured cycle-start action.
REMOVE_CYCLE_START_ACTION()Remove the cycle-start action.

View spending

Use the following methods to review spending:

MethodDescription
GET_SPENDING_DETAILS_BY_USERS('<start>', '<end>')Return finalized per-user usage for a date range. See View user spending.
SNOWFLAKE.LOCAL.MY_BUDGET_SUMMARY()Return the calling user’s limits, usage, and block status for each of their quotas. Any user can call it. See Check your quota usage.