# Get users and roles by Management API V2

**URL:** <https://community.auth0.com/t/get-users-and-roles-by-management-api-v2/75277>\
**Category:** Get Help\
**Tags:** managment-api-v2, auth0\
**Created:** [December 21, 2021, 3:26pm UTC](https://community.auth0.com/t/get-users-and-roles-by-management-api-v2/75277 "2021-12-21T15:26:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asaf1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/asaf1/32/33010_2.png) [@asaf1](https://community.auth0.com/u/asaf1)\
**Post date:** [December 21, 2021, 3:26pm UTC](https://community.auth0.com/t/get-users-and-roles-by-management-api-v2/75277/1 "2021-12-21T15:26:51Z")

</div>

Hi.  
I couldn’t find how to perform the following queries, maybe someone will have ideas:

1. get all the users by role (like https://${AUTH0\_DOMAIN}/api/v2/roles/${roleID}/users), but I want that the users will have all the fields, including metadata, like in the get user by ID.
2. In continue to #1, is it possible to query for list of role IDs and not only a single roleID?
3. query for roles by role name

Thanks,  
Asaf

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 21, 2021, 6:17pm UTC](https://community.auth0.com/t/get-users-and-roles-by-management-api-v2/75277/3 "2021-12-21T18:17:51Z")

</div>

Hi @asaf1,

Thanks for reaching out to the Auth0 Community!

> [@asaf1](#):
>
> get all the users by role (like https://${AUTH0\_DOMAIN}/api/v2/roles/${roleID}/users), but I want that the users will have all the fields, including metadata, like in the get user by ID.

To accomplish this, you will need to use the Management API v2 [Get a role’s users endpoint](https://auth0.com/docs/api/management/v2#!/Roles/get_role_user) in conjunction with the [Get users by ID endpoint](https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id).

After querying the list of `user_id`’s associated with a role, you can pass `user_id` to get the user profile.

> [@asaf1](#):
>
> In continue to #1, is it possible to query for list of role IDs and not only a single roleID?

Unfortunately, it’s not possible to use the Get a role’s users endpoint for more than one role.

However, you could get the use the [Get roles endpoint](https://auth0.com/docs/api/management/v2#!/Roles/get_roles) and iteratively pass the Role ID to the [Get a role’s users endpoint](https://auth0.com/docs/api/management/v2#!/Roles/get_role_user).

> [@asaf1](#):
>
> query for roles by role name

Unfortunately, this is not possible. You must query by Role ID.

I hope this answers your questions.

Please let me know if you have any other questions or concerns. I’d be happy to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![asaf1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/asaf1/32/33010_2.png) [@asaf1](https://community.auth0.com/u/asaf1)\
**Post date:** [December 22, 2021, 8:17am UTC](https://community.auth0.com/t/get-users-and-roles-by-management-api-v2/75277/4 "2021-12-22T08:17:37Z")

</div>

Thanks a lot.  
So apparently I use that API as expected, and no shortcuts there…

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 6, 2022, 8:17am UTC](https://community.auth0.com/t/get-users-and-roles-by-management-api-v2/75277/5 "2022-01-06T08:17:39Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
