Skip to main content

users

Creates, updates, deletes, gets or lists a users resource.

Overview

Nameusers
TypeResource
Idsnowflake.user.users

Fields

The following fields are returned by SELECT queries:

Properties of user.

NameDatatypeDescription
namestringUser name (example: jackpatel)
display_namestringDisplay name
first_namestringFirst name
last_namestringLast name
login_namestringLogin name
middle_namestringMiddle name
commentstringComment about the user. (example: A distinguished user)
created_onstring (date-time)
custom_landing_page_urlstring
custom_landing_page_url_flush_next_ui_loadbooleanWhether or not to flush the custom landing page of the user on next UI load
days_to_expiryintegerHow many days until this user expires
default_namespacestringThe default namespace to use when this user starts a session
default_rolestringThe default role to use when this user starts a session
default_secondary_rolesstringThe default secondary roles of this user to use when starting a session. Only valid set values are ALL or NONE. Default is ALL after 2024-07 BCR. (default: ALL)
default_warehousestringThe default warehouse to use when this user starts a session
disabledbooleanHas this user been disabled from the system
emailstringEmail address
enable_unredacted_query_syntax_errorbooleanWhether to show unredacted query syntax errors in the query history.
expires_atstring (date-time)
ext_authn_duoboolean
ext_authn_uidstring
has_passwordboolean
has_rsa_public_keyboolean
last_successful_loginstring (date-time)
locked_untilstring (date-time)
mins_to_bypass_mfaintegerHow many minutes until MFA is required again
mins_to_bypass_network_policyintegerTemporary bypass network policy on the user for a specified number of minutes
mins_to_unlockintegerHow many minutes until the account is unlocked after multiple failed logins
must_change_passwordbooleanDoes this user need to change their password (e.g., after assigning a temp password)
network_policystringSpecifies an existing network policy is active for the user. Otherwise, use account default.
ownerstring
passwordstring (password)Password
password_last_setstring (date-time)
rsa_public_keystringRSA public key of the user
rsa_public_key_2stringSecond RSA public key of the user
rsa_public_key_2_fpstringFingerprint of the user's second RSA public key
rsa_public_key_fpstringFingerprint of the user's RSA public key
snowflake_lockbooleanWhether the user, account, or organization is locked by Snowflake.
snowflake_supportbooleanWhether Snowflake Support is allowed to use the user or account
typestringIndicates the type of user (PERSON | SERVICE | LEGACY_SERVICE)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_usersselectendpointlike, startsWith, showLimit, fromNameLists the users in the system.
fetch_userselectname, endpointFetch user information using the result of the DESCRIBE command
create_userinsertendpointcreateModeCreate a user according to the parameters given
create_or_alter_userreplacename, endpointCreate a (or alter an existing) user. Even if the operation is just an alter, the full property set must be provided. Note that password is not currently altered by this operation but is supported for a newly-created object.
delete_userdeletename, endpointifExistsDelete a user with the given name.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
endpointstringOrganization and Account Name (default: orgid-acctid)
namestringIdentifier (i.e. name) for the resource.
createModestringQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
fromNamestringQuery parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.
ifExistsbooleanQuery parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.
likestringQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerQuery parameter to limit the maximum number of rows returned by a command.
startsWithstringQuery parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.

SELECT examples

Lists the users in the system.

SELECT
name,
display_name,
first_name,
last_name,
login_name,
middle_name,
comment,
created_on,
custom_landing_page_url,
custom_landing_page_url_flush_next_ui_load,
days_to_expiry,
default_namespace,
default_role,
default_secondary_roles,
default_warehouse,
disabled,
email,
enable_unredacted_query_syntax_error,
expires_at,
ext_authn_duo,
ext_authn_uid,
has_password,
has_rsa_public_key,
last_successful_login,
locked_until,
mins_to_bypass_mfa,
mins_to_bypass_network_policy,
mins_to_unlock,
must_change_password,
network_policy,
owner,
password,
password_last_set,
rsa_public_key,
rsa_public_key_2,
rsa_public_key_2_fp,
rsa_public_key_fp,
snowflake_lock,
snowflake_support,
type
FROM snowflake.user.users
WHERE endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}';

INSERT examples

Create a user according to the parameters given

INSERT INTO snowflake.user.users (
data__name,
data__password,
data__login_name,
data__display_name,
data__first_name,
data__middle_name,
data__last_name,
data__email,
data__must_change_password,
data__disabled,
data__days_to_expiry,
data__mins_to_unlock,
data__default_warehouse,
data__default_namespace,
data__default_role,
data__default_secondary_roles,
data__mins_to_bypass_mfa,
data__rsa_public_key,
data__rsa_public_key_2,
data__comment,
data__type,
data__enable_unredacted_query_syntax_error,
data__network_policy,
endpoint,
createMode
)
SELECT
'{{ name }}' --required,
'{{ password }}',
'{{ login_name }}',
'{{ display_name }}',
'{{ first_name }}',
'{{ middle_name }}',
'{{ last_name }}',
'{{ email }}',
{{ must_change_password }},
{{ disabled }},
{{ days_to_expiry }},
{{ mins_to_unlock }},
'{{ default_warehouse }}',
'{{ default_namespace }}',
'{{ default_role }}',
'{{ default_secondary_roles }}',
{{ mins_to_bypass_mfa }},
'{{ rsa_public_key }}',
'{{ rsa_public_key_2 }}',
'{{ comment }}',
'{{ type }}',
{{ enable_unredacted_query_syntax_error }},
'{{ network_policy }}',
'{{ endpoint }}',
'{{ createMode }}'
;

REPLACE examples

Create a (or alter an existing) user. Even if the operation is just an alter, the full property set must be provided. Note that password is not currently altered by this operation but is supported for a newly-created object.

REPLACE snowflake.user.users
SET
data__name = '{{ name }}',
data__password = '{{ password }}',
data__login_name = '{{ login_name }}',
data__display_name = '{{ display_name }}',
data__first_name = '{{ first_name }}',
data__middle_name = '{{ middle_name }}',
data__last_name = '{{ last_name }}',
data__email = '{{ email }}',
data__must_change_password = {{ must_change_password }},
data__disabled = {{ disabled }},
data__days_to_expiry = {{ days_to_expiry }},
data__mins_to_unlock = {{ mins_to_unlock }},
data__default_warehouse = '{{ default_warehouse }}',
data__default_namespace = '{{ default_namespace }}',
data__default_role = '{{ default_role }}',
data__default_secondary_roles = '{{ default_secondary_roles }}',
data__mins_to_bypass_mfa = {{ mins_to_bypass_mfa }},
data__rsa_public_key = '{{ rsa_public_key }}',
data__rsa_public_key_2 = '{{ rsa_public_key_2 }}',
data__comment = '{{ comment }}',
data__type = '{{ type }}',
data__enable_unredacted_query_syntax_error = {{ enable_unredacted_query_syntax_error }},
data__network_policy = '{{ network_policy }}'
WHERE
name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND data__name = '{{ name }}' --required;

DELETE examples

Delete a user with the given name.

DELETE FROM snowflake.user.users
WHERE name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';