Last Updated: Sep 24, 2024
Overview
This article clarifies if it is possible to change the user_id format from its default value to a custom one.
- For example, if the default user ID is “auth0|example@com”, to be changed to {{tenantName}}::example@com.
Applies To
- Custom User ID
- User ID format
Cause
Auth0 will always add the strategy prefix to a user_id regardless of its source, and this is not configurable (examples of prefixes are auth0 / google-oauth2 / samlp, etc. - the full list is available on this POST connections reference).
Solution
Unfortunately, this is not possible at this time. Auth0 will always prefix a user_id with the strategy of the connection the user is on (“auth0” for a database connection, “google-oauth2” for a Google social connection, etc.), and this is not configurable.
It is possible to specify a custom user_id when creating users via the Management API, a first-time login/signup on a Custom Database connection, or by mapping when using a SAML connection, for example. However, as mentioned above, these will still be prefixed.
An alternative would be to store a secondary ID in the user’s app_metadata. If required, this could be added to tokens using an Action to make it easily accessible to the applications/APIs. Please see Add custom claims to a token for details.
NOTE: When providing custom IDs, the customer is responsible for ensuring that the IDs are unique across the tenant. We recommend adding an additional prefix to the custom ID to distinguish between database connections, for example, to avoid duplicated ID issues between database connections, as they will all share the “auth0” strategy prefix regardless of which database connection the user is on. Please see Identify Users for more details.