Hello @konstantinov.v.konst welcome to the community!
When a user logs in via Auth0, depending on the implementation both the associated ID token and Access token will have a sub
claim which is the Auth0 user ID.
Alternatively, you could add an Action that calls an API (that you would write) when a user is first created, grabs your external database userid. It would then add the userid to the user’s app_metadata and eventually as a custom claim to a token.
I recommend taking a look at our Architecture Scenarios documentation for an overview of what this may look like:
Hope this helps!