Page updated Jan 16, 2024

Delete user account

Invoke the deleteUser API to delete a user from the Auth category. This action will also sign your user out.

If your application uses a Cognito User Pool, which is the default configuration for the Amazon Cognito plugin, this action will delete the user from the Cognito User Pool. It will have no effect if you are federating with a Cognito Identity Pool alone.

Depending on your application, data associated with your user may be stored in other resources such as Amazon DynamoDB or AWS S3. It is recommended that you carefully evaluate this data and implement code to remove or otherwise sanitize it, if necessary, prior to giving users the ability to delete their own user record.

Before invoking the “delete user” API, you can first delete associated user data from the GraphQL API. For example, if you are using Amplify CLI's GraphQL transformer to persist user data via owner based access control, you could follow these instructions to delete associated user data.

This allows you to address any guidelines that require your app to delete data associated with a user who deletes their account.

1Amplify.Auth.deleteUser(
2 () -> Log.i("AuthQuickStart", "Delete user succeeded"),
3 error -> Log.e("AuthQuickStart", "Delete user failed with error " + error.toString())
4);
1Amplify.Auth.deleteUser(
2 { Log.i("AuthQuickStart", "Delete user succeeded") },
3 { Log.e("AuthQuickStart", "Delete user failed with error", it) }
4)
1try {
2 Amplify.Auth.deleteUser()
3 Log.i("AuthQuickStart", "Delete user succeeded")
4} catch (error: AuthException) {
5 Log.e("AuthQuickStart", "Delete user failed with error", error)
6}
1RxAmplify.Auth.deleteUser()
2 .subscribe(
3 () -> Log.i("AuthQuickStart", "Delete user succeeded"),
4 error -> Log.e("AuthQuickStart", "Delete user failed with error " + error.toString())
5 );