Skip to main content

users

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

Overview

Nameusers
TypeResource
Idsnowflake.user.users

Fields

NameDatatypeDescription
namestringUser name
commentstringComment about the user.
created_onstring
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_warehousestringThe default warehouse to use when this user starts a session
disabledbooleanHas this user been disabled from the system
display_namestringDisplay name
emailstringEmail address
enable_unredacted_query_syntax_errorbooleanWhether to show unredacted query syntax errors in the query history.
expires_atstring
ext_authn_duoboolean
ext_authn_uidstring
first_namestringFirst name
has_passwordboolean
has_rsa_public_keyboolean
last_namestringLast name
last_successful_loginstring
locked_untilstring
login_namestringLogin name
middle_namestringMiddle name
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
passwordstringPassword
password_last_setstring
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

NameAccessible byRequired ParamsOptional ParamsDescription
fetch_userSELECTname, endpoint-Fetch user information using the result of the DESCRIBE command
list_usersSELECTendpointlike, startsWith, showLimit, fromNameLists the users in the system.
create_userINSERTdata__name, endpointcreateModeCreate a user according to the parameters given
delete_userDELETEname, endpointifExistsDelete a user with the given name.
create_or_alter_userREPLACEname, data__name, endpoint-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.

Optional Parameter Details
NameDescriptionTypeDefault
createModeQuery 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.stringerrorIfExists
fromNameQuery 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.string-
ifExistsQuery 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.booleanfalse
likeQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.string-
showLimitQuery parameter to limit the maximum number of rows returned by a command.integer-
startsWithQuery 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.string-

SELECT examples

Lists the users in the system.

SELECT
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,
display_name,
email,
enable_unredacted_query_syntax_error,
expires_at,
ext_authn_duo,
ext_authn_uid,
first_name,
has_password,
has_rsa_public_key,
last_name,
last_successful_login,
locked_until,
login_name,
middle_name,
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 }}';

INSERT example

Use the following StackQL query and manifest file to create a new users resource.

/*+ create */
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
)
SELECT
'{{ name }}',
'{{ 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 }}'
;

REPLACE example

Replaces all fields in the specified users resource.

/*+ update */
REPLACE snowflake.user.users
SET
name = '{{ name }}',
password = '{{ password }}',
login_name = '{{ login_name }}',
display_name = '{{ display_name }}',
first_name = '{{ first_name }}',
middle_name = '{{ middle_name }}',
last_name = '{{ last_name }}',
email = '{{ email }}',
must_change_password = true|false,
disabled = true|false,
days_to_expiry = '{{ days_to_expiry }}',
mins_to_unlock = '{{ mins_to_unlock }}',
default_warehouse = '{{ default_warehouse }}',
default_namespace = '{{ default_namespace }}',
default_role = '{{ default_role }}',
default_secondary_roles = '{{ default_secondary_roles }}',
mins_to_bypass_mfa = '{{ mins_to_bypass_mfa }}',
rsa_public_key = '{{ rsa_public_key }}',
rsa_public_key_2 = '{{ rsa_public_key_2 }}',
comment = '{{ comment }}',
type = '{{ type }}',
enable_unredacted_query_syntax_error = true|false,
network_policy = '{{ network_policy }}'
WHERE
name = '{{ name }}'
AND data__name = '{{ data__name }}'
AND endpoint = '{{ endpoint }}';

DELETE example

Deletes the specified users resource.

/*+ delete */
DELETE FROM snowflake.user.users
WHERE name = '{{ name }}'
AND endpoint = '{{ endpoint }}';