CognitoIdentityProvider / Client / update_user_pool
update_user_pool#
- CognitoIdentityProvider.Client.update_user_pool(**kwargs)#
Note
This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with Amazon Pinpoint. Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in.
If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Services service, Amazon Simple Notification Service might place your account in the SMS sandbox. In sandbox mode , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see SMS message settings for Amazon Cognito user pools in the Amazon Cognito Developer Guide.
Updates the specified user pool with the specified attributes. You can get a list of the current user pool settings using DescribeUserPool.
Warning
If you don’t provide a value for an attribute, Amazon Cognito sets it to its default value.
Note
Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.
Learn more
See also: AWS API Documentation
Request Syntax
response = client.update_user_pool( UserPoolId='string', Policies={ 'PasswordPolicy': { 'MinimumLength': 123, 'RequireUppercase': True|False, 'RequireLowercase': True|False, 'RequireNumbers': True|False, 'RequireSymbols': True|False, 'PasswordHistorySize': 123, 'TemporaryPasswordValidityDays': 123 } }, DeletionProtection='ACTIVE'|'INACTIVE', LambdaConfig={ 'PreSignUp': 'string', 'CustomMessage': 'string', 'PostConfirmation': 'string', 'PreAuthentication': 'string', 'PostAuthentication': 'string', 'DefineAuthChallenge': 'string', 'CreateAuthChallenge': 'string', 'VerifyAuthChallengeResponse': 'string', 'PreTokenGeneration': 'string', 'UserMigration': 'string', 'PreTokenGenerationConfig': { 'LambdaVersion': 'V1_0'|'V2_0', 'LambdaArn': 'string' }, 'CustomSMSSender': { 'LambdaVersion': 'V1_0', 'LambdaArn': 'string' }, 'CustomEmailSender': { 'LambdaVersion': 'V1_0', 'LambdaArn': 'string' }, 'KMSKeyID': 'string' }, AutoVerifiedAttributes=[ 'phone_number'|'email', ], SmsVerificationMessage='string', EmailVerificationMessage='string', EmailVerificationSubject='string', VerificationMessageTemplate={ 'SmsMessage': 'string', 'EmailMessage': 'string', 'EmailSubject': 'string', 'EmailMessageByLink': 'string', 'EmailSubjectByLink': 'string', 'DefaultEmailOption': 'CONFIRM_WITH_LINK'|'CONFIRM_WITH_CODE' }, SmsAuthenticationMessage='string', UserAttributeUpdateSettings={ 'AttributesRequireVerificationBeforeUpdate': [ 'phone_number'|'email', ] }, MfaConfiguration='OFF'|'ON'|'OPTIONAL', DeviceConfiguration={ 'ChallengeRequiredOnNewDevice': True|False, 'DeviceOnlyRememberedOnUserPrompt': True|False }, EmailConfiguration={ 'SourceArn': 'string', 'ReplyToEmailAddress': 'string', 'EmailSendingAccount': 'COGNITO_DEFAULT'|'DEVELOPER', 'From': 'string', 'ConfigurationSet': 'string' }, SmsConfiguration={ 'SnsCallerArn': 'string', 'ExternalId': 'string', 'SnsRegion': 'string' }, UserPoolTags={ 'string': 'string' }, AdminCreateUserConfig={ 'AllowAdminCreateUserOnly': True|False, 'UnusedAccountValidityDays': 123, 'InviteMessageTemplate': { 'SMSMessage': 'string', 'EmailMessage': 'string', 'EmailSubject': 'string' } }, UserPoolAddOns={ 'AdvancedSecurityMode': 'OFF'|'AUDIT'|'ENFORCED', 'AdvancedSecurityAdditionalFlows': { 'CustomAuthMode': 'AUDIT'|'ENFORCED' } }, AccountRecoverySetting={ 'RecoveryMechanisms': [ { 'Priority': 123, 'Name': 'verified_email'|'verified_phone_number'|'admin_only' }, ] } )
- Parameters:
UserPoolId (string) –
[REQUIRED]
The user pool ID for the user pool you want to update.
Policies (dict) –
A container with the policies you want to update in a user pool.
PasswordPolicy (dict) –
The password policy.
MinimumLength (integer) –
The minimum length of the password in the policy that you have set. This value can’t be less than 6.
RequireUppercase (boolean) –
In the password policy that you have set, refers to whether you have required users to use at least one uppercase letter in their password.
RequireLowercase (boolean) –
In the password policy that you have set, refers to whether you have required users to use at least one lowercase letter in their password.
RequireNumbers (boolean) –
In the password policy that you have set, refers to whether you have required users to use at least one number in their password.
RequireSymbols (boolean) –
In the password policy that you have set, refers to whether you have required users to use at least one symbol in their password.
PasswordHistorySize (integer) –
The number of previous passwords that you want Amazon Cognito to restrict each user from reusing. Users can’t set a password that matches any of
n
previous passwords, wheren
is the value ofPasswordHistorySize
.Password history isn’t enforced and isn’t displayed in DescribeUserPool responses when you set this value to
0
or don’t provide it. To activate this setting, advanced security features must be active in your user pool.TemporaryPasswordValidityDays (integer) –
The number of days a temporary password is valid in the password policy. If the user doesn’t sign in during this time, an administrator must reset their password. Defaults to
7
. If you submit a value of0
, Amazon Cognito treats it as a null value and setsTemporaryPasswordValidityDays
to its default value.Note
When you set
TemporaryPasswordValidityDays
for a user pool, you can no longer set a value for the legacyUnusedAccountValidityDays
parameter in that user pool.
DeletionProtection (string) –
When active,
DeletionProtection
prevents accidental deletion of your user pool. Before you can delete a user pool that you have protected against deletion, you must deactivate this feature.When you try to delete a protected user pool in a
DeleteUserPool
API request, Amazon Cognito returns anInvalidParameterException
error. To delete a protected user pool, send a newDeleteUserPool
request after you deactivate deletion protection in anUpdateUserPool
API request.LambdaConfig (dict) –
The Lambda configuration information from the request to update the user pool.
PreSignUp (string) –
A pre-registration Lambda trigger.
CustomMessage (string) –
A custom Message Lambda trigger.
PostConfirmation (string) –
A post-confirmation Lambda trigger.
PreAuthentication (string) –
A pre-authentication Lambda trigger.
PostAuthentication (string) –
A post-authentication Lambda trigger.
DefineAuthChallenge (string) –
Defines the authentication challenge.
CreateAuthChallenge (string) –
Creates an authentication challenge.
VerifyAuthChallengeResponse (string) –
Verifies the authentication challenge response.
PreTokenGeneration (string) –
The Amazon Resource Name (ARN) of the function that you want to assign to your Lambda trigger.
Set this parameter for legacy purposes. If you also set an ARN in
PreTokenGenerationConfig
, its value must be identical toPreTokenGeneration
. For new instances of pre token generation triggers, set theLambdaArn
ofPreTokenGenerationConfig
.You can set
UserMigration (string) –
The user migration Lambda config type.
PreTokenGenerationConfig (dict) –
The detailed configuration of a pre token generation trigger. If you also set an ARN in
PreTokenGeneration
, its value must be identical toPreTokenGenerationConfig
.LambdaVersion (string) – [REQUIRED]
The user pool trigger version of the request that Amazon Cognito sends to your Lambda function. Higher-numbered versions add fields that support new features.
LambdaArn (string) – [REQUIRED]
The Amazon Resource Name (ARN) of the function that you want to assign to your Lambda trigger.
This parameter and the
PreTokenGeneration
property ofLambdaConfig
have the same value. For new instances of pre token generation triggers, setLambdaArn
.
CustomSMSSender (dict) –
A custom SMS sender Lambda trigger.
LambdaVersion (string) – [REQUIRED]
The user pool trigger version of the request that Amazon Cognito sends to your Lambda function. Higher-numbered versions add fields that support new features.
You must use a
LambdaVersion
ofV1_0
with a custom sender function.LambdaArn (string) – [REQUIRED]
The Amazon Resource Name (ARN) of the function that you want to assign to your Lambda trigger.
CustomEmailSender (dict) –
A custom email sender Lambda trigger.
LambdaVersion (string) – [REQUIRED]
The user pool trigger version of the request that Amazon Cognito sends to your Lambda function. Higher-numbered versions add fields that support new features.
You must use a
LambdaVersion
ofV1_0
with a custom sender function.LambdaArn (string) – [REQUIRED]
The Amazon Resource Name (ARN) of the function that you want to assign to your Lambda trigger.
KMSKeyID (string) –
The Amazon Resource Name (ARN) of an KMS key. Amazon Cognito uses the key to encrypt codes and temporary passwords sent to
CustomEmailSender
andCustomSMSSender
.
AutoVerifiedAttributes (list) –
The attributes that are automatically verified when Amazon Cognito requests to update user pools.
(string) –
SmsVerificationMessage (string) – This parameter is no longer used. See VerificationMessageTemplateType.
EmailVerificationMessage (string) – This parameter is no longer used. See VerificationMessageTemplateType.
EmailVerificationSubject (string) – This parameter is no longer used. See VerificationMessageTemplateType.
VerificationMessageTemplate (dict) –
The template for verification messages.
SmsMessage (string) –
The template for SMS messages that Amazon Cognito sends to your users.
EmailMessage (string) –
The template for email messages that Amazon Cognito sends to your users. You can set an
EmailMessage
template only if the value of EmailSendingAccount isDEVELOPER
. When your EmailSendingAccount isDEVELOPER
, your user pool sends email messages with your own Amazon SES configuration.EmailSubject (string) –
The subject line for the email message template. You can set an
EmailSubject
template only if the value of EmailSendingAccount isDEVELOPER
. When your EmailSendingAccount isDEVELOPER
, your user pool sends email messages with your own Amazon SES configuration.EmailMessageByLink (string) –
The email message template for sending a confirmation link to the user. You can set an
EmailMessageByLink
template only if the value of EmailSendingAccount isDEVELOPER
. When your EmailSendingAccount isDEVELOPER
, your user pool sends email messages with your own Amazon SES configuration.EmailSubjectByLink (string) –
The subject line for the email message template for sending a confirmation link to the user. You can set an
EmailSubjectByLink
template only if the value of EmailSendingAccount isDEVELOPER
. When your EmailSendingAccount isDEVELOPER
, your user pool sends email messages with your own Amazon SES configuration.DefaultEmailOption (string) –
The default email option.
SmsAuthenticationMessage (string) – The contents of the SMS authentication message.
UserAttributeUpdateSettings (dict) –
The settings for updates to user attributes. These settings include the property
AttributesRequireVerificationBeforeUpdate
, a user-pool setting that tells Amazon Cognito how to handle changes to the value of your users’ email address and phone number attributes. For more information, see Verifying updates to email addresses and phone numbers.AttributesRequireVerificationBeforeUpdate (list) –
Requires that your user verifies their email address, phone number, or both before Amazon Cognito updates the value of that attribute. When you update a user attribute that has this option activated, Amazon Cognito sends a verification message to the new phone number or email address. Amazon Cognito doesn’t change the value of the attribute until your user responds to the verification message and confirms the new value.
You can verify an updated email address or phone number with a VerifyUserAttribute API request. You can also call the AdminUpdateUserAttributes API and set
email_verified
orphone_number_verified
to true.When
AttributesRequireVerificationBeforeUpdate
is false, your user pool doesn’t require that your users verify attribute changes before Amazon Cognito updates them. In a user pool whereAttributesRequireVerificationBeforeUpdate
is false, API operations that change attribute values can immediately update a user’semail
orphone_number
attribute.(string) –
MfaConfiguration (string) –
Possible values include:
OFF
- MFA tokens aren’t required and can’t be specified during user registration.ON
- MFA tokens are required for all user registrations. You can only specify ON when you’re initially creating a user pool. You can use the SetUserPoolMfaConfig API operation to turn MFA “ON” for existing user pools.OPTIONAL
- Users have the option when registering to create an MFA token.
DeviceConfiguration (dict) –
The device-remembering configuration for a user pool. A null value indicates that you have deactivated device remembering in your user pool.
Note
When you provide a value for any
DeviceConfiguration
field, you activate the Amazon Cognito device-remembering feature.ChallengeRequiredOnNewDevice (boolean) –
When true, a remembered device can sign in with device authentication instead of SMS and time-based one-time password (TOTP) factors for multi-factor authentication (MFA).
Note
Whether or not
ChallengeRequiredOnNewDevice
is true, users who sign in with devices that have not been confirmed or remembered must still provide a second factor in a user pool that requires MFA.DeviceOnlyRememberedOnUserPrompt (boolean) –
When true, Amazon Cognito doesn’t automatically remember a user’s device when your app sends a ConfirmDevice API request. In your app, create a prompt for your user to choose whether they want to remember their device. Return the user’s choice in an UpdateDeviceStatus API request.
When
DeviceOnlyRememberedOnUserPrompt
isfalse
, Amazon Cognito immediately remembers devices that you register in aConfirmDevice
API request.
EmailConfiguration (dict) –
The email configuration of your user pool. The email configuration type sets your preferred sending method, Amazon Web Services Region, and sender for email invitation and verification messages from your user pool.
SourceArn (string) –
The ARN of a verified email address or an address from a verified domain in Amazon SES. You can set a
SourceArn
email from a verified domain only with an API request. You can set a verified email address, but not an address in a verified domain, in the Amazon Cognito console. Amazon Cognito uses the email address that you provide in one of the following ways, depending on the value that you specify for theEmailSendingAccount
parameter:If you specify
COGNITO_DEFAULT
, Amazon Cognito uses this address as the custom FROM address when it emails your users using its built-in email account.If you specify
DEVELOPER
, Amazon Cognito emails your users with this address by calling Amazon SES on your behalf.
The Region value of the
SourceArn
parameter must indicate a supported Amazon Web Services Region of your user pool. Typically, the Region in theSourceArn
and the user pool Region are the same. For more information, see Amazon SES email configuration regions in the Amazon Cognito Developer Guide.ReplyToEmailAddress (string) –
The destination to which the receiver of the email should reply.
EmailSendingAccount (string) –
Specifies whether Amazon Cognito uses its built-in functionality to send your users email messages, or uses your Amazon Simple Email Service email configuration. Specify one of the following values:
COGNITO_DEFAULT
When Amazon Cognito emails your users, it uses its built-in email functionality. When you use the default option, Amazon Cognito allows only a limited number of emails each day for your user pool. For typical production environments, the default email limit is less than the required delivery volume. To achieve a higher delivery volume, specify DEVELOPER to use your Amazon SES email configuration.
To look up the email delivery limit for the default option, see Limits in the Amazon Cognito Developer Guide.
The default FROM address is
no-reply@verificationemail.com
. To customize the FROM address, provide the Amazon Resource Name (ARN) of an Amazon SES verified email address for theSourceArn
parameter.DEVELOPER
When Amazon Cognito emails your users, it uses your Amazon SES configuration. Amazon Cognito calls Amazon SES on your behalf to send email from your verified email address. When you use this option, the email delivery limits are the same limits that apply to your Amazon SES verified email address in your Amazon Web Services account.
If you use this option, provide the ARN of an Amazon SES verified email address for the
SourceArn
parameter.Before Amazon Cognito can email your users, it requires additional permissions to call Amazon SES on your behalf. When you update your user pool with this option, Amazon Cognito creates a service-linked role, which is a type of role in your Amazon Web Services account. This role contains the permissions that allow you to access Amazon SES and send email messages from your email address. For more information about the service-linked role that Amazon Cognito creates, see Using Service-Linked Roles for Amazon Cognito in the Amazon Cognito Developer Guide.
From (string) –
Either the sender’s email address or the sender’s name with their email address. For example,
testuser@example.com
orTest User <testuser@example.com>
. This address appears before the body of the email.ConfigurationSet (string) –
The set of configuration rules that can be applied to emails sent using Amazon Simple Email Service. A configuration set is applied to an email by including a reference to the configuration set in the headers of the email. Once applied, all of the rules in that configuration set are applied to the email. Configuration sets can be used to apply the following types of rules to emails:
Event publishing
Amazon Simple Email Service can track the number of send, delivery, open, click, bounce, and complaint events for each email sent. Use event publishing to send information about these events to other Amazon Web Services services such as and Amazon CloudWatch
IP pool management
When leasing dedicated IP addresses with Amazon Simple Email Service, you can create groups of IP addresses, called dedicated IP pools. You can then associate the dedicated IP pools with configuration sets.
SmsConfiguration (dict) –
The SMS configuration with the settings that your Amazon Cognito user pool must use to send an SMS message from your Amazon Web Services account through Amazon Simple Notification Service. To send SMS messages with Amazon SNS in the Amazon Web Services Region that you want, the Amazon Cognito user pool uses an Identity and Access Management (IAM) role in your Amazon Web Services account.
SnsCallerArn (string) – [REQUIRED]
The Amazon Resource Name (ARN) of the Amazon SNS caller. This is the ARN of the IAM role in your Amazon Web Services account that Amazon Cognito will use to send SMS messages. SMS messages are subject to a spending limit.
ExternalId (string) –
The external ID provides additional security for your IAM role. You can use an
ExternalId
with the IAM role that you use with Amazon SNS to send SMS messages for your user pool. If you provide anExternalId
, your Amazon Cognito user pool includes it in the request to assume your IAM role. You can configure the role trust policy to require that Amazon Cognito, and any principal, provide theExternalID
. If you use the Amazon Cognito Management Console to create a role for SMS multi-factor authentication (MFA), Amazon Cognito creates a role with the required permissions and a trust policy that demonstrates use of theExternalId
.For more information about the
ExternalId
of a role, see How to use an external ID when granting access to your Amazon Web Services resources to a third partySnsRegion (string) –
The Amazon Web Services Region to use with Amazon SNS integration. You can choose the same Region as your user pool, or a supported Legacy Amazon SNS alternate Region.
Amazon Cognito resources in the Asia Pacific (Seoul) Amazon Web Services Region must use your Amazon SNS configuration in the Asia Pacific (Tokyo) Region. For more information, see SMS message settings for Amazon Cognito user pools.
UserPoolTags (dict) –
The tag keys and values to assign to the user pool. A tag is a label that you can use to categorize and manage user pools in different ways, such as by purpose, owner, environment, or other criteria.
(string) –
(string) –
AdminCreateUserConfig (dict) –
The configuration for
AdminCreateUser
requests.AllowAdminCreateUserOnly (boolean) –
Set to
True
if only the administrator is allowed to create user profiles. Set toFalse
if users can sign themselves up via an app.UnusedAccountValidityDays (integer) –
The user account expiration limit, in days, after which a new account that hasn’t signed in is no longer usable. To reset the account after that time limit, you must call
AdminCreateUser
again, specifying"RESEND"
for theMessageAction
parameter. The default value for this parameter is 7.Note
If you set a value for
TemporaryPasswordValidityDays
inPasswordPolicy
, that value will be used, andUnusedAccountValidityDays
will be no longer be an available parameter for that user pool.InviteMessageTemplate (dict) –
The message template to be used for the welcome message to new users.
See also Customizing User Invitation Messages.
SMSMessage (string) –
The message template for SMS messages.
EmailMessage (string) –
The message template for email messages. EmailMessage is allowed only if EmailSendingAccount is DEVELOPER.
EmailSubject (string) –
The subject line for email messages. EmailSubject is allowed only if EmailSendingAccount is DEVELOPER.
UserPoolAddOns (dict) –
User pool add-ons. Contains settings for activation of advanced security features. To log user security information but take no action, set to
AUDIT
. To configure automatic security responses to risky traffic to your user pool, set toENFORCED
.For more information, see Adding advanced security to a user pool.
AdvancedSecurityMode (string) – [REQUIRED]
The operating mode of advanced security features for standard authentication types in your user pool, including username-password and secure remote password (SRP) authentication.
AdvancedSecurityAdditionalFlows (dict) –
Advanced security configuration options for additional authentication types in your user pool, including custom authentication.
CustomAuthMode (string) –
The operating mode of advanced security features in custom authentication with Custom authentication challenge Lambda triggers.
AccountRecoverySetting (dict) –
The available verified method a user can use to recover their password when they call
ForgotPassword
. You can use this setting to define a preferred method when a user has more than one method available. With this setting, SMS doesn’t qualify for a valid password recovery mechanism if the user also has SMS multi-factor authentication (MFA) activated. In the absence of this setting, Amazon Cognito uses the legacy behavior to determine the recovery method where SMS is preferred through email.RecoveryMechanisms (list) –
The list of
RecoveryOptionTypes
.(dict) –
A map containing a priority as a key, and recovery method name as a value.
Priority (integer) – [REQUIRED]
A positive integer specifying priority of a method with 1 being the highest priority.
Name (string) – [REQUIRED]
The recovery method for a user.
- Return type:
dict
- Returns:
Response Syntax
{}
Response Structure
(dict) –
Represents the response from the server when you make a request to update the user pool.
Exceptions
CognitoIdentityProvider.Client.exceptions.ResourceNotFoundException
CognitoIdentityProvider.Client.exceptions.InvalidParameterException
CognitoIdentityProvider.Client.exceptions.ConcurrentModificationException
CognitoIdentityProvider.Client.exceptions.TooManyRequestsException
CognitoIdentityProvider.Client.exceptions.NotAuthorizedException
CognitoIdentityProvider.Client.exceptions.UserImportInProgressException
CognitoIdentityProvider.Client.exceptions.InternalErrorException
CognitoIdentityProvider.Client.exceptions.InvalidSmsRoleAccessPolicyException
CognitoIdentityProvider.Client.exceptions.InvalidSmsRoleTrustRelationshipException
CognitoIdentityProvider.Client.exceptions.UserPoolTaggingException
CognitoIdentityProvider.Client.exceptions.InvalidEmailRoleAccessPolicyException