# Is there a way to get role\_id

**URL:** <https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125>\
**Category:** Get Help\
**Tags:** management-api, roles\
**Created:** [October 23, 2023, 5:05am UTC](https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125 "2023-10-23T05:05:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyql](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andyql/32/75461_2.png) [@andyql](https://community.auth0.com/u/andyql)\
**Post date:** [October 23, 2023, 5:05am UTC](https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125/1 "2023-10-23T05:05:41Z")

</div>

current we can get roles from the api, but it’s by names, is there any way to get role\_id instead?

use case being update user roles by adding new roles.  
in the roles set api, has to use role\_id, but we cannot get the role\_ids of the user’s current roles, only the role names, which cannot be used to update the roles.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 24, 2023, 12:56am UTC](https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125/3 "2023-10-24T00:56:33Z")

</div>

Hey there @andyql !

> [@andyql](#):
>
> current we can get roles from the api, but it’s by names, is there any way to get role\_id instead?
> 
> use case being update user roles by adding new roles.

Which endpoint are you using currently to get roles and which are you looking to use to assign new roles to users? I just want to make sure I am on the same page 🙂

---

<div class="post-metadata">

**Author:** ![andyql](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andyql/32/75461_2.png) [@andyql](https://community.auth0.com/u/andyql)\
**Post date:** [October 24, 2023, 1:35am UTC](https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125/4 "2023-10-24T01:35:45Z")

</div>

thx @ty.frith

two apis return same results:

- `event.authorization.roles`
- iirc `users/${userId}/roles`

they both give you eg ‘admin’ or ‘user’, instead of `<admin_id>` which you use to assgin the roles.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 24, 2023, 3:45pm UTC](https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125/5 "2023-10-24T15:45:25Z")

</div>

Thanks for confirming!

In looking at [users/${userId}/roles](https://auth0.com/docs/api/management/v2/users/get-user-roles) the role id should be returned - Here’s an example of what I’m seeing:

```auto
[
  {
    "id": "rol_9bRdc5NZmfrghayE04",
    "name": "admin",
    "description": "admin role for go_api_server"
  },
  {
    "id": "rol_qT4pcK3345HbCJ05t",
    "name": "newUser",
    "description": "newUser"
  },
  {
    "id": "rol_bJ7P72pauDr454xsqN",
    "name": "org_role666",
    "description": "role only assigned at org level"
  }
]

```

---

<div class="post-metadata">

**Author:** ![andyql](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andyql/32/75461_2.png) [@andyql](https://community.auth0.com/u/andyql)\
**Post date:** [October 25, 2023, 2:37am UTC](https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125/6 "2023-10-25T02:37:09Z")

</div>

that’s great! tested working. i must be using a different api. tyvm!

---

<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:** [November 8, 2023, 2:37am UTC](https://community.auth0.com/t/is-there-a-way-to-get-role-id/119125/7 "2023-11-08T02:37:48Z")

</div>

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