Create a User API automatically prefixes user_id with "auth0|"

Hi there,

We are using the Auth0 Management API v2 to create a user but when doing so it automatically prefixes “auth0|” to a user_id.

The user_id field in the request body looks like “oauth2||auth0|some-id”

Is there a way to prevent that the API automatically adds “auth0|”?

If you need more information, please let me know.

Thank your for your assistance.


Just checking in on this topic, it’s been 3 weeks, anyone? :slight_smile:

Hi @bieber ,

The auth0| prefix is not specific to the Management API, it will always be added to a user even if you create them via Dashboard or if a user signs up. This is to identify various types of objects (MFA methods with email| or phone|, roles with rol_, etc.)

1 Like

And is there a way to prevent this happening?

To make things more clearly I am describing a scenario we face:

Let’s say we are running backups our selves for all social and database connections, looking at one account of those connections: we backup the user_id with “oauth2|Social-Con|auth0|12345”. Now something happens to the connections and all users are gone. We want to recover that specific user, thus creating a new user with the backed up infos. Now the user_id will be “auth0|oauth2|Social-Con|auth0|12345” and cannot be assigned to that specific in our system still existing user because the id’s will never match, plus if you think this process a couple times through you will endup with user_ids like this: auth0|auth0|auth0|auth0…

Hi Dennis :wave:

Sadly, the self-backup/restore scenario you describe would not be possible for Social connections. And neither would it be possible for non Custom Database connections. It’s not currently possible to create a Social Connection in Auth0 directly via the Management API, so recovery of a Social account would require the user to perform first factor authentication again with the social provider; even then the user_id associated with the account could not be guaranteed as this is based on the (user) identifier that comes from the social provided - which may have changed. It’s also not possible to control the user_id generated for a user account associated with an Auth0 managed Database connection: identifiers for Auth0 Database connections are uniquely generated, so a new identifier would typically be created even if you re-created the user account via use of the Auth0 Management API.

1 Like