How to delete users when using Custom Databases

Problem statement

Unable to delete users when using Custom Databases.


Troubleshooting Custom Databases Scripts

If you encounter issues with your Custom Database scripts, proceed by using the Real-time Webtask Logs Extension to troubleshoot.

Use Real-time Webtask Logs Extension:

  1. Begin by Installing the Real-time Webtask Logs Extension on your Auth0 Dashboard > Extensions > All Extensions.
  2. Launch the Real-time Webtask Logs Extension by navigating to the Auth0 Dashboard > Extensions > Installed Extensions.
  3. Using the Extension, you can view the results from your Database Scripts such as success messages, error messages, and console.log() statements.

Relevant docs:


  • User is unable to be deleted
  • Delete User script was not implemented
  • User being deleted with import mode off
  • User was not deleted when trying to create the user again.


There are two scenarios to consider when using Custom Databases to delete users. The first scenario is when Import Mode is enabled, and the second scenario is when Import mode is disabled.

Import Mode enabled

When Import Mode is enabled, you can delete the user using the Management API v2 Delete a user endpoint to delete the user.

Or alternatively, you could use the Management API v2 Delete a connection user endpoint to delete the user.

After that is completed, confirm that the user does not exist in your legacy database.

Import Mode Disabled

When Import Mode is disabled, you will need to implement a Delete script in your Custom Database. Please see Delete Script Templates for a template you can use. There are templates for:

Note that deleting a user using the Auth0 Dashboard or the Auth0 Management API performs deletion of both the user profile and the user identity. If you do not implement this script correctly, then this will not be done as an atomic operation, which may leave a user identity still in existence even after the user’s profile has been removed. Conversely, deleting a user identity outside of Auth0 will typically leave a disconnected (orphaned) profile in Auth0 that has no associated user identity. This may cause unpredictable issues.

If this happens, you may need to check that the user is removed from both Auth0 and your Custom Database. And then verify any issues in the Delete script to avoid this from recurring in the future.

Relevant Docs