VerifyUserAttributeCommand

Submits a verification code for a signed-in user who has added or changed a value of an auto-verified attribute. When successful, the user's attribute becomes verified and the attribute email_verified or phone_number_verified becomes true.

If your user pool requires verification before Amazon Cognito updates the attribute value, this operation updates the affected attribute to its pending value.

Authorize this action with a signed-in user's access token. It must include the scope aws.cognito.signin.user.admin.

Amazon Cognito doesn't evaluate 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 .

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CognitoIdentityProviderClient, VerifyUserAttributeCommand } from "@aws-sdk/client-cognito-identity-provider"; // ES Modules import
// const { CognitoIdentityProviderClient, VerifyUserAttributeCommand } = require("@aws-sdk/client-cognito-identity-provider"); // CommonJS import
const client = new CognitoIdentityProviderClient(config);
const input = { // VerifyUserAttributeRequest
  AccessToken: "STRING_VALUE", // required
  AttributeName: "STRING_VALUE", // required
  Code: "STRING_VALUE", // required
};
const command = new VerifyUserAttributeCommand(input);
const response = await client.send(command);
// {};

VerifyUserAttributeCommand Input

See VerifyUserAttributeCommandInput for more details

Parameter
Type
Description
AccessToken
Required
string | undefined

A valid access token that Amazon Cognito issued to the currently signed-in user. Must include a scope claim for aws.cognito.signin.user.admin.

AttributeName
Required
string | undefined

The name of the attribute that you want to verify.

Code
Required
string | undefined

The verification code that your user pool sent to the added or changed attribute, for example the user's email address.

VerifyUserAttributeCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
AliasExistsException
client

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.

CodeMismatchException
client

This exception is thrown if the provided code doesn't match what the server was expecting.

ExpiredCodeException
client

This exception is thrown if a code has expired.

ForbiddenException
client

This exception is thrown when WAF doesn't allow your request based on a web ACL that's associated with your user pool.

InternalErrorException
server

This exception is thrown when Amazon Cognito encounters an internal error.

InvalidParameterException
client

This exception is thrown when the Amazon Cognito service encounters an invalid parameter.

LimitExceededException
client

This exception is thrown when a user exceeds the limit for a requested Amazon Web Services resource.

NotAuthorizedException
client

This exception is thrown when a user isn't authorized.

PasswordResetRequiredException
client

This exception is thrown when a password reset is required.

ResourceNotFoundException
client

This exception is thrown when the Amazon Cognito service can't find the requested resource.

TooManyRequestsException
client

This exception is thrown when the user has made too many requests for a given operation.

UserNotConfirmedException
client

This exception is thrown when a user isn't confirmed successfully.

UserNotFoundException
client

This exception is thrown when a user isn't found.

CognitoIdentityProviderServiceException
Base exception class for all service exceptions from CognitoIdentityProvider service.