DeleteUserCommand

Deletes the profile of the currently signed-in user. A deleted user profile can no longer be used to sign in and can't be restored.

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, DeleteUserCommand } from "@aws-sdk/client-cognito-identity-provider"; // ES Modules import
// const { CognitoIdentityProviderClient, DeleteUserCommand } = require("@aws-sdk/client-cognito-identity-provider"); // CommonJS import
const client = new CognitoIdentityProviderClient(config);
const input = { // DeleteUserRequest
  AccessToken: "STRING_VALUE", // required
};
const command = new DeleteUserCommand(input);
const response = await client.send(command);
// {};

DeleteUserCommand Input

See DeleteUserCommandInput 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.

DeleteUserCommand Output

See DeleteUserCommandOutput for details

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

Throws

Name
Fault
Details
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.

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.