Is there a way to query users with no roles?

Is there any way to determine users that don’t have any roles? I know I can use the api/v2/roles endpoint to find all users belonging to a role, but this excludes all users who don’t have a role.

What I’m trying to do is ensure that roles assigned to users within our application align with the roles in Auth0. Using the above API, I can retrieve everything I need EXCEPT for those users who for some reason do not have any roles assigned in Auth0. I saw the excellent idea to propagate the roles to app_metadata via a rule, but it would take time for the data to populate.

Hi @john.boldt1

There doesn’t seem to be a built-in method to return Users with empty roles, or even in general to filter on the Roles for Users.

However, you could query all users and store them to a collection. Then use the “Get a role’s users GET /api/v2/roles/{id}/users” and for any users returned from that latter call, since they are associated to a role, remove them from the collection.