

# ConfirmSignUp


Confirms the account of a new user. This public API operation submits a code that Amazon Cognito sent to your user when they signed up in your user pool. After your user enters their code, they confirm ownership of the email address or phone number that they provided, and their user account becomes active. Depending on your user pool configuration, your users will receive their confirmation code in an email or SMS message.

Local users who signed up in your user pool are the only type of user who can confirm sign-up with a code. Users who federate through an external identity provider (IdP) have already been confirmed by their IdP.

Administrator-created users, users created with the [AdminCreateUser](API_AdminCreateUser.md) API operation, confirm their accounts when they respond to their invitation email message and choose a password. They do not receive a confirmation code. Instead, they receive a temporary password.

**Note**  
Amazon Cognito doesn't evaluate AWS Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you can't use IAM credentials to authorize requests, and you can't grant IAM permissions in policies. For more information about authorization models in Amazon Cognito, see [Using the Amazon Cognito user pools API and user pool endpoints](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pools-API-operations.html).

## Request Syntax


```
{
   "AnalyticsMetadata": { 
      "AnalyticsEndpointId": "string"
   },
   "ClientId": "string",
   "ClientMetadata": { 
      "string" : "string" 
   },
   "ConfirmationCode": "string",
   "ForceAliasCreation": boolean,
   "SecretHash": "string",
   "Session": "string",
   "UserContextData": { 
      "EncodedData": "string",
      "IpAddress": "string"
   },
   "Username": "string"
}
```

## Request Parameters


For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [AnalyticsMetadata](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-AnalyticsMetadata"></a>
Information that supports analytics outcomes with Amazon Pinpoint, including the user's endpoint ID. The endpoint ID is a destination for Amazon Pinpoint push notifications, for example a device identifier, email address, or phone number.  
Type: [AnalyticsMetadataType](API_AnalyticsMetadataType.md) object  
Required: No

 ** [ClientId](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-ClientId"></a>
The ID of the app client associated with the user pool.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 128.  
Pattern: `[\w+]+`   
Required: Yes

 ** [ClientMetadata](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-ClientMetadata"></a>
A map of custom key-value pairs that you can provide as input for any custom workflows that this action triggers. You create custom workflows by assigning AWS Lambda functions to user pool triggers.  
When Amazon Cognito invokes any of these functions, it passes a JSON payload, which the function receives as input. This payload contains a `clientMetadata` attribute that provides the data that you assigned to the ClientMetadata parameter in your request. In your function code, you can process the `clientMetadata` value to enhance your workflow for your specific needs.  
To review the Lambda trigger types that Amazon Cognito invokes at runtime with API requests, see [ Connecting API actions to Lambda triggers](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-working-with-lambda-triggers.html#lambda-triggers-by-event) in the *Amazon Cognito Developer Guide*.  
When you use the `ClientMetadata` parameter, note that Amazon Cognito won't do the following:  
+ Store the `ClientMetadata` value. This data is available only to AWS Lambda triggers that are assigned to a user pool to support custom workflows. If your user pool configuration doesn't include triggers, the `ClientMetadata` parameter serves no purpose.
+ Validate the `ClientMetadata` value.
+ Encrypt the `ClientMetadata` value. Don't send sensitive information in this parameter.
Type: String to string map  
Key Length Constraints: Minimum length of 0. Maximum length of 131072.  
Value Length Constraints: Minimum length of 0. Maximum length of 131072.  
Required: No

 ** [ConfirmationCode](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-ConfirmationCode"></a>
The confirmation code that your user pool sent in response to the `SignUp` request.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 2048.  
Pattern: `[\S]+`   
Required: Yes

 ** [ForceAliasCreation](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-ForceAliasCreation"></a>
When `true`, forces user confirmation despite any existing aliases. Defaults to `false`. A value of `true` migrates the alias from an existing user to the new user if an existing user already has the phone number or email address as an alias.  
Say, for example, that an existing user has an `email` attribute of `bob@example.com` and email is an alias in your user pool. If the new user also has an email of `bob@example.com` and your `ConfirmSignUp` response sets `ForceAliasCreation` to `true`, the new user can sign in with a username of `bob@example.com` and the existing user can no longer do so.  
If `false` and an attribute belongs to an existing alias, this request returns an **AliasExistsException** error.  
For more information about sign-in aliases, see [Customizing sign-in attributes](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-aliases).  
Type: Boolean  
Required: No

 ** [SecretHash](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-SecretHash"></a>
A keyed-hash message authentication code (HMAC) calculated using the secret key of a user pool client and username plus the client ID in the message. For more information about `SecretHash`, see [Computing secret hash values](https://docs.aws.amazon.com/cognito/latest/developerguide/signing-up-users-in-your-app.html#cognito-user-pools-computing-secret-hash).  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 128.  
Pattern: `[\w+=/]+`   
Required: No

 ** [Session](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-Session"></a>
The optional session ID from a `SignUp` API request. You can sign in a user directly from the sign-up process with the `USER_AUTH` authentication flow.  
Type: String  
Length Constraints: Minimum length of 20. Maximum length of 2048.  
Required: No

 ** [UserContextData](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-UserContextData"></a>
Contextual data about your user session like the device fingerprint, IP address, or location. Amazon Cognito threat protection evaluates the risk of an authentication event based on the context that your app generates and passes to Amazon Cognito when it makes API requests.  
For more information, see [Collecting data for threat protection in applications](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-viewing-threat-protection-app.html).  
Type: [UserContextDataType](API_UserContextDataType.md) object  
Required: No

 ** [Username](#API_ConfirmSignUp_RequestSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-request-Username"></a>
The name of the user that you want to query or modify. The value of this parameter is typically your user's username, but it can be any of their alias attributes. If `username` isn't an alias attribute in your user pool, this value must be the `sub` of a local user or the username of a user from a third-party IdP.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 128.  
Pattern: `[\p{L}\p{M}\p{S}\p{N}\p{P}]+`   
Required: Yes

## Response Syntax


```
{
   "Session": "string"
}
```

## Response Elements


If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [Session](#API_ConfirmSignUp_ResponseSyntax) **   <a name="CognitoUserPools-ConfirmSignUp-response-Session"></a>
A session identifier that you can use to immediately sign in the confirmed user. You can automatically sign users in with the one-time password that they provided in a successful `ConfirmSignUp` request.  
To do this, pass the `Session` parameter from this response in the `Session` parameter of an [InitiateAuth](API_InitiateAuth.md) or [AdminInitiateAuth](API_AdminInitiateAuth.md) request.  
Type: String  
Length Constraints: Minimum length of 20. Maximum length of 2048.

## Errors


For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** AliasExistsException **   
This exception is thrown when a user tries to confirm the account with an email address or phone number that has already been supplied as an alias for a different user profile. This exception indicates that an account with this email address or phone already exists in a user pool that you've configured to use email address or phone number as a sign-in alias.    
 ** message **   
The message that Amazon Cognito sends to the user when the value of an alias attribute is already linked to another user profile.
HTTP Status Code: 400

 ** CodeMismatchException **   
This exception is thrown if the provided code doesn't match what the server was expecting.    
 ** message **   
The message provided when the code mismatch exception is thrown.
HTTP Status Code: 400

 ** ExpiredCodeException **   
This exception is thrown if a code has expired.    
 ** message **   
The message returned when the expired code exception is thrown.
HTTP Status Code: 400

 ** ForbiddenException **   
This exception is thrown when AWS WAF doesn't allow your request based on a web ACL that's associated with your user pool.    
 ** message **   
The message returned when AWS WAF doesn't allow your request based on a web ACL that's associated with your user pool.
HTTP Status Code: 400

 ** InternalErrorException **   
This exception is thrown when Amazon Cognito encounters an internal error.    
 ** message **   
The message returned when Amazon Cognito throws an internal error exception.
HTTP Status Code: 500

 ** InvalidLambdaResponseException **   
This exception is thrown when Amazon Cognito encounters an invalid AWS Lambda response.    
 ** message **   
The message returned when Amazon Cognito throws an invalid AWS Lambda response exception.
HTTP Status Code: 400

 ** InvalidParameterException **   
This exception is thrown when the Amazon Cognito service encounters an invalid parameter.    
 ** message **   
The message returned when the Amazon Cognito service throws an invalid parameter exception.  
 ** reasonCode **   
The reason code of the exception.
HTTP Status Code: 400

 ** LimitExceededException **   
This exception is thrown when a user exceeds the limit for a requested AWS resource.    
 ** message **   
The message returned when Amazon Cognito throws a limit exceeded exception.
HTTP Status Code: 400

 ** NotAuthorizedException **   
This exception is thrown when a user isn't authorized.    
 ** message **   
The message returned when the Amazon Cognito service returns a not authorized exception.
HTTP Status Code: 400

 ** ResourceNotFoundException **   
This exception is thrown when the Amazon Cognito service can't find the requested resource.    
 ** message **   
The message returned when the Amazon Cognito service returns a resource not found exception.
HTTP Status Code: 400

 ** TooManyFailedAttemptsException **   
This exception is thrown when the user has made too many failed attempts for a given action, such as sign-in.    
 ** message **   
The message returned when Amazon Cognito returns a `TooManyFailedAttempts` exception.
HTTP Status Code: 400

 ** TooManyRequestsException **   
This exception is thrown when the user has made too many requests for a given operation.    
 ** message **   
The message returned when the Amazon Cognito service returns a too many requests exception.
HTTP Status Code: 400

 ** UnexpectedLambdaException **   
This exception is thrown when Amazon Cognito encounters an unexpected exception with AWS Lambda.    
 ** message **   
The message returned when Amazon Cognito returns an unexpected Lambda exception.
HTTP Status Code: 400

 ** UserLambdaValidationException **   
This exception is thrown when the Amazon Cognito service encounters a user validation exception with the AWS Lambda service.    
 ** message **   
The message returned when the Amazon Cognito service returns a user validation exception with the Lambda service.
HTTP Status Code: 400

 ** UserNotFoundException **   
This exception is thrown when a user isn't found.    
 ** message **   
The message returned when a user isn't found.
HTTP Status Code: 400

## Examples


### Example


The following example request confirms sign-up for the user "testuser" with the submitted confirmation code `123456`. The response includes a session ID that your application can pass to [InitiateAuth](API_InitiateAuth.md) or [AdminInitiateAuth](API_AdminInitiateAuth.md) for automatic email or SMS OTP sign-in with the already-submitted `123456` confirmation code.

#### Sample Request


```
POST HTTP/1.1
Host: cognito-idp.us-west-2.amazonaws.com
X-Amz-Date: 20230613T200059Z
Accept-Encoding: gzip, deflate, br
X-Amz-Target: AWSCognitoIdentityProviderService.ConfirmSignUp
User-Agent: <UserAgentString>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature>
Content-Length: <PayloadSizeBytes>
{
    "ClientId": "1example23456789",
    "ConfirmationCode": "123456",
    "Username": "testuser"
}
```

#### 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
{
   "Session":"AYABeC1-y8qooiuysEv0uM4wAqQAHQABAAdTZXJ2aWNlABBDb2duaXRvVXNlclBvb2xzAAEAB2F3cy1rbXMAS2Fybjphd3M6a21zOnVzLXd..."
}
```

## See Also


For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/cognito-idp-2016-04-18/ConfirmSignUp) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/cognito-idp-2016-04-18/ConfirmSignUp) 