How to keep Auth0's database and our database in sync?

I have user’s data which is related to Identity and Access Management (such as name, email, etc.) but we also have user’s data which we need for our product. I have a local database which keeps that data, while I use the user’s userId to reference the corresponding user in Auth0’s database.

But I’m afraid that over time, due to various errors etc, the data in these two databases can get out of sync, For example:

  • Backend gets a Create User request to our Backend service. It creates a user on Auth0 using the management API, then use the userId to create a user in our local database. If due to some reason, our local database’s operation fails, we will have a user in our Auth0 database but not in our local database. Now we cannot do a Create User request again with the same user email because our Auth0 management API call will fail since that user already exists.

This is not really an issue with Auth0, however, I would appreciate feedback from more experienced programmers on how to tackle this.

(post deleted by author)

I’m actually curious about this as well as I’m trying to follow a similar work flow as yours.

One potential solution here can be deleting the auth0 user if creating the user in the internal database fails.

However, this would be a pain to implement for other use actions as well (for example, UPDATING a user).