UpdateUserPool
Updates the configuration of a user pool. To avoid setting parameters to Amazon Cognito defaults, construct this API request to pass the existing configuration of your user pool, modified to include the changes that you want to make.
Important
If you don't provide a value for an attribute, Amazon Cognito sets it to its default value.
You can get a list of the current user pool settings using DescribeUserPool.
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
If you have never used SMS text messages with Amazon Cognito or any other AWS 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.
Note
Amazon Cognito evaluates AWS 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.
Request Syntax
{
"AccountRecoverySetting": {
"RecoveryMechanisms": [
{
"Name": "string
",
"Priority": number
}
]
},
"AdminCreateUserConfig": {
"AllowAdminCreateUserOnly": boolean
,
"InviteMessageTemplate": {
"EmailMessage": "string
",
"EmailSubject": "string
",
"SMSMessage": "string
"
},
"UnusedAccountValidityDays": number
},
"AutoVerifiedAttributes": [ "string
" ],
"DeletionProtection": "string
",
"DeviceConfiguration": {
"ChallengeRequiredOnNewDevice": boolean
,
"DeviceOnlyRememberedOnUserPrompt": boolean
},
"EmailConfiguration": {
"ConfigurationSet": "string
",
"EmailSendingAccount": "string
",
"From": "string
",
"ReplyToEmailAddress": "string
",
"SourceArn": "string
"
},
"EmailVerificationMessage": "string
",
"EmailVerificationSubject": "string
",
"LambdaConfig": {
"CreateAuthChallenge": "string
",
"CustomEmailSender": {
"LambdaArn": "string
",
"LambdaVersion": "string
"
},
"CustomMessage": "string
",
"CustomSMSSender": {
"LambdaArn": "string
",
"LambdaVersion": "string
"
},
"DefineAuthChallenge": "string
",
"KMSKeyID": "string
",
"PostAuthentication": "string
",
"PostConfirmation": "string
",
"PreAuthentication": "string
",
"PreSignUp": "string
",
"PreTokenGeneration": "string
",
"PreTokenGenerationConfig": {
"LambdaArn": "string
",
"LambdaVersion": "string
"
},
"UserMigration": "string
",
"VerifyAuthChallengeResponse": "string
"
},
"MfaConfiguration": "string
",
"Policies": {
"PasswordPolicy": {
"MinimumLength": number
,
"PasswordHistorySize": number
,
"RequireLowercase": boolean
,
"RequireNumbers": boolean
,
"RequireSymbols": boolean
,
"RequireUppercase": boolean
,
"TemporaryPasswordValidityDays": number
},
"SignInPolicy": {
"AllowedFirstAuthFactors": [ "string
" ]
}
},
"PoolName": "string
",
"SmsAuthenticationMessage": "string
",
"SmsConfiguration": {
"ExternalId": "string
",
"SnsCallerArn": "string
",
"SnsRegion": "string
"
},
"SmsVerificationMessage": "string
",
"UserAttributeUpdateSettings": {
"AttributesRequireVerificationBeforeUpdate": [ "string
" ]
},
"UserPoolAddOns": {
"AdvancedSecurityAdditionalFlows": {
"CustomAuthMode": "string
"
},
"AdvancedSecurityMode": "string
"
},
"UserPoolId": "string
",
"UserPoolTags": {
"string
" : "string
"
},
"UserPoolTier": "string
",
"VerificationMessageTemplate": {
"DefaultEmailOption": "string
",
"EmailMessage": "string
",
"EmailMessageByLink": "string
",
"EmailSubject": "string
",
"EmailSubjectByLink": "string
",
"SmsMessage": "string
"
}
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- AccountRecoverySetting
-
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.Type: AccountRecoverySettingType object
Required: No
- AdminCreateUserConfig
-
The configuration for administrative creation of users. Includes the template for the invitation message for new users, the duration of temporary passwords, and permitting self-service sign-up.
Type: AdminCreateUserConfigType object
Required: No
- AutoVerifiedAttributes
-
The attributes that you want your user pool to automatically verify. Possible values: email, phone_number. For more information see Verifying contact information at sign-up.
Type: Array of strings
Valid Values:
phone_number | email
Required: No
- DeletionProtection
-
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.Type: String
Valid Values:
ACTIVE | INACTIVE
Required: No
- DeviceConfiguration
-
The device-remembering configuration for a user pool. Device remembering or device tracking is a "Remember me on this device" option for user pools that perform authentication with the device key of a trusted device in the back end, instead of a user-provided MFA code. For more information about device authentication, see Working with user devices in your 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. For more inforType: DeviceConfigurationType object
Required: No
- EmailConfiguration
-
The email configuration of your user pool. The email configuration type sets your preferred sending method, AWS Region, and sender for email invitation and verification messages from your user pool.
Type: EmailConfigurationType object
Required: No
- EmailVerificationMessage
-
This parameter is no longer used. See VerificationMessageTemplateType.
Type: String
Length Constraints: Minimum length of 6. Maximum length of 20000.
Pattern:
[\p{L}\p{M}\p{S}\p{N}\p{P}\s*]*\{####\}[\p{L}\p{M}\p{S}\p{N}\p{P}\s*]*
Required: No
- EmailVerificationSubject
-
This parameter is no longer used. See VerificationMessageTemplateType.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 140.
Pattern:
[\p{L}\p{M}\p{S}\p{N}\p{P}\s]+
Required: No
- LambdaConfig
-
A collection of user pool Lambda triggers. Amazon Cognito invokes triggers at several possible stages of authentication operations. Triggers can modify the outcome of the operations that invoked them.
Type: LambdaConfigType object
Required: No
- MfaConfiguration
-
Sets multi-factor authentication (MFA) to be on, off, or optional. When
ON
, all users must set up MFA before they can sign in. WhenOPTIONAL
, your application must make a client-side determination of whether a user wants to register an MFA device. For user pools with adaptive authentication with threat protection, chooseOPTIONAL
.When
MfaConfiguration
isOPTIONAL
, managed login doesn't automatically prompt users to set up MFA. Amazon Cognito generates MFA prompts in API responses and in managed login for users who have chosen and configured a preferred MFA factor.Type: String
Valid Values:
OFF | ON | OPTIONAL
Required: No
- Policies
-
The password policy and sign-in policy in the user pool. The password policy sets options like password complexity requirements and password history. The sign-in policy sets the options available to applications in choice-based authentication.
Type: UserPoolPolicyType object
Required: No
- PoolName
-
The updated name of your user pool.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
[\w\s+=,.@-]+
Required: No
- SmsAuthenticationMessage
-
The contents of the SMS message that your user pool sends to users in SMS authentication.
Type: String
Length Constraints: Minimum length of 6. Maximum length of 140.
Pattern:
.*\{####\}.*
Required: No
- SmsConfiguration
-
The SMS configuration with the settings for your Amazon Cognito user pool to send SMS message with Amazon Simple Notification Service. To send SMS messages with Amazon SNS in the AWS Region that you want, the Amazon Cognito user pool uses an AWS Identity and Access Management (IAM) role in your AWS account. For more information see SMS message settings.
Type: SmsConfigurationType object
Required: No
- SmsVerificationMessage
-
This parameter is no longer used. See VerificationMessageTemplateType.
Type: String
Length Constraints: Minimum length of 6. Maximum length of 140.
Pattern:
.*\{####\}.*
Required: No
- UserAttributeUpdateSettings
-
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.Type: UserAttributeUpdateSettingsType object
Required: No
- UserPoolAddOns
-
Contains settings for activation of threat protection, including the operating mode and additional authentication types. To log user security information but take no action, set to
AUDIT
. To configure automatic security responses to potentially unwanted traffic to your user pool, set toENFORCED
.For more information, see Adding advanced security to a user pool. To activate this setting, your user pool must be on the Plus tier.
Type: UserPoolAddOnsType object
Required: No
- UserPoolId
-
The ID of the user pool you want to update.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 55.
Pattern:
[\w-]+_[0-9a-zA-Z]+
Required: Yes
- UserPoolTags
-
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.
Type: String to string map
Key Length Constraints: Minimum length of 1. Maximum length of 128.
Value Length Constraints: Minimum length of 0. Maximum length of 256.
Required: No
- UserPoolTier
-
The user pool feature plan, or tier. This parameter determines the eligibility of the user pool for features like managed login, access-token customization, and threat protection. Defaults to
ESSENTIALS
.Type: String
Valid Values:
LITE | ESSENTIALS | PLUS
Required: No
- VerificationMessageTemplate
-
The template for the verification message that your user pool delivers to users who set an email address or phone number attribute.
Set the email message type that corresponds to your
DefaultEmailOption
selection. ForCONFIRM_WITH_LINK
, specify anEmailMessageByLink
and leaveEmailMessage
blank. ForCONFIRM_WITH_CODE
, specify anEmailMessage
and leaveEmailMessageByLink
blank. When you supply both parameters with either choice, Amazon Cognito returns an error.Type: VerificationMessageTemplateType object
Required: No
Response Elements
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
Errors
For information about the errors that are common to all actions, see Common Errors.
- ConcurrentModificationException
-
This exception is thrown if two or more modifications are happening concurrently.
HTTP Status Code: 400
- FeatureUnavailableInTierException
-
This exception is thrown when a feature you attempted to configure isn't available in your current feature plan.
HTTP Status Code: 400
- InternalErrorException
-
This exception is thrown when Amazon Cognito encounters an internal error.
HTTP Status Code: 500
- InvalidEmailRoleAccessPolicyException
-
This exception is thrown when Amazon Cognito isn't allowed to use your email identity. HTTP status code: 400.
HTTP Status Code: 400
- InvalidParameterException
-
This exception is thrown when the Amazon Cognito service encounters an invalid parameter.
HTTP Status Code: 400
- InvalidSmsRoleAccessPolicyException
-
This exception is returned when the role provided for SMS configuration doesn't have permission to publish using Amazon SNS.
HTTP Status Code: 400
- InvalidSmsRoleTrustRelationshipException
-
This exception is thrown when the trust relationship is not valid for the role provided for SMS configuration. This can happen if you don't trust
cognito-idp.amazonaws.com
or the external ID provided in the role does not match what is provided in the SMS configuration for the user pool.HTTP Status Code: 400
- NotAuthorizedException
-
This exception is thrown when a user isn't authorized.
HTTP Status Code: 400
- ResourceNotFoundException
-
This exception is thrown when the Amazon Cognito service can't find the requested resource.
HTTP Status Code: 400
- TierChangeNotAllowedException
-
This exception is thrown when you've attempted to change your feature plan but the operation isn't permitted.
HTTP Status Code: 400
- TooManyRequestsException
-
This exception is thrown when the user has made too many requests for a given operation.
HTTP Status Code: 400
- UserImportInProgressException
-
This exception is thrown when you're trying to modify a user pool while a user import job is in progress for that pool.
HTTP Status Code: 400
- UserPoolTaggingException
-
This exception is thrown when a user pool tag can't be set or updated.
HTTP Status Code: 400
Examples
Example
The following UpdateUserPool
request updates some common features
of the target user pool.
Sample Request
POST HTTP/1.1
Host: cognito-idp.ca-central-1.amazonaws.com
X-Amz-Date: 20230613T200059Z
Accept-Encoding: gzip, deflate, br
X-Amz-Target: AWSCognitoIdentityProviderService.UpdateUserPool
User-Agent: <UserAgentString>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature>
Content-Length: <PayloadSizeBytes>
{
"AccountRecoverySetting": {
"RecoveryMechanisms": [
{
"Name": "verified_email",
"Priority": 1
},
{
"Name": "verified_phone_number",
"Priority": 2
}
]
},
"AdminCreateUserConfig": {
"AllowAdminCreateUserOnly": false,
"UnusedAccountValidityDays": 7
},
"AliasAttributes": [
"email",
"phone_number",
"preferred_username"
],
"Arn": "arn:aws:cognito-idp:ca-central-1:123456789012:userpool/ca-central-1_EXAMPLE",
"AutoVerifiedAttributes": [
"email"
],
"DeletionProtection": "ACTIVE",
"Domain": "cognitoexample",
"EmailConfiguration": {
"ConfigurationSet": "my-sesconfigset",
"EmailSendingAccount": "DEVELOPER",
"SourceArn": "arn:aws:ses:us-east-1:123456789012:identity/admin@example.com"
},
"LambdaConfig": {
"PreSignUp": "arn:aws:lambda:ca-central-1:123456789012:function:my-function"
},
"MfaConfiguration": "OPTIONAL",
"Name": "my-test-user-pool",
"Policies": {
"PasswordPolicy": {
"MinimumLength": 8,
"RequireLowercase": true,
"RequireNumbers": true,
"RequireSymbols": true,
"RequireUppercase": true,
"TemporaryPasswordValidityDays": 7
},
"SignInPolicy": {
"AllowedFirstAuthFactors": [
"PASSWORD",
"EMAIL_OTP",
"WEB_AUTHN"
]
}
},
"SmsConfiguration": {
"ExternalId": "ALPHA-BRAVO",
"SnsCallerArn": "arn:aws:iam::123456789012:role/My-SMS-Role",
"SnsRegion": "us-east-1"
},
"UserAttributeUpdateSettings": {
"AttributesRequireVerificationBeforeUpdate": [
"email"
]
},
"UsernameConfiguration": {
"CaseSensitive": false
},
"UserPoolAddOns": {
"AdvancedSecurityAdditionalFlows": {
},
"AdvancedSecurityMode": "OFF"
},
"UserPoolId": "ca-central-1_EXAMPLE",
"UserPoolTags": {
},
"UserPoolTier": "PLUS",
"VerificationMessageTemplate": {
"DefaultEmailOption": "CONFIRM_WITH_CODE"
}
}
Sample Response
HTTP/1.1 200 OK
Date: Tue, 13 Jun 2023 20:00:59 GMT
Content-Type: application/x-amz-json-1.0
Content-Length: <PayloadSizeBytes>
x-amzn-requestid: a1b2c3d4-e5f6-a1b2-c3d4-EXAMPLE11111
Connection: keep-alive
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: