Hello! I’d like my application to be notified when a user is created/added to an organization (either by accepting an invitation and manually being added via the Auth0 UI) and when a user is deleted from an organization.
I see that events is in Beta and hooks are deprecated. What is the current best way to set this up. Thank you!
Hi @dashabobrova
Welcome to the Auth0 Community!
Reading and understanding your current use-case, I believe that currently we do not have an out-of-the-box solution that could easily accomplish this, but you will need to utilize different tools in order to accomplish the goal.
One way that I would recommend approaching this would be utilizing Auth0 Log Streams to search for newly added users and the Management API to retrieve the current list of Organization members, which can tell if there are users who were recently deleted from the Org.
You can Create Custom Log Streams Using Webhooks and filter the Log Stream by organization_member_added
which would show the new users added to the Organization.
With regards to members Deleted from an Organization, you can use the Management API to call the api/v2/organizations/:id/members
endpoint to retrieve a list of Organization members and compare it with a list of users that could be locally stored in your application.
In addition, you can also use Retrieve User’s Organization Memberships to check a user’s current Organization membership.
Hope this helped!
Gerald