# Is there any way to assign roles to the user by role name instead of actual role id?

**URL:** <https://community.auth0.com/t/is-there-any-way-to-assign-roles-to-the-user-by-role-name-instead-of-actual-role-id/81451>\
**Category:** Get Help\
**Tags:** signup, auth0\
**Created:** [April 8, 2022, 1:37pm UTC](https://community.auth0.com/t/is-there-any-way-to-assign-roles-to-the-user-by-role-name-instead-of-actual-role-id/81451 "2022-04-08T13:37:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saurya.dacharya](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saurya.dacharya/32/33507_2.png) [@saurya.dacharya](https://community.auth0.com/u/saurya.dacharya)\
**Post date:** [April 8, 2022, 1:37pm UTC](https://community.auth0.com/t/is-there-any-way-to-assign-roles-to-the-user-by-role-name-instead-of-actual-role-id/81451/1 "2022-04-08T13:37:57Z")

</div>

I want to assign roles to the user by role name instead of actual role id.

By sending the request POST request to api like

{  
roles: [“ROLE\_NAME1”, “ROLE\_NAME2”]  
}

---

<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:** [April 8, 2022, 5:38pm UTC](https://community.auth0.com/t/is-there-any-way-to-assign-roles-to-the-user-by-role-name-instead-of-actual-role-id/81451/3 "2022-04-08T17:38:04Z")

</div>

Hi @saurya.dacharya,

Welcome to the Auth0 Community!

> [@saurya.dacharya](#):
>
> I want to assign roles to the user by role name instead of actual role id.

Unfortunately, this is not possible, and you must use the Role ID to make the request.

You could, however, mimic this behavior by abstracting the Role IDs as constants and calling them. For example:

```auto
const adminRole = 'ROLE_ID';
const userRole = 'ROLE_ID';
var data = { roles:[adminRole, userRole] };

```

Doing so should provide more natural language in the code when assigning Roles to Users.

Please let me know if there’s anything else I can do to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![nacho](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nacho/32/12799_2.png) [@nacho](https://community.auth0.com/u/nacho)\
**Post date:** [October 23, 2022, 2:27pm UTC](https://community.auth0.com/t/is-there-any-way-to-assign-roles-to-the-user-by-role-name-instead-of-actual-role-id/81451/4 "2022-10-23T14:27:48Z")

</div>

Thank you. This post is super helpful as I was struggling to figure out why my action failed to update the user’s role. The [API docs](https://auth0.github.io/node-auth0/ManagementClient.html#assignRolestoUser) fails to mention the correlation between role name and role id.

Using role ID makes user admin code non-portable. We have a separate dev and prod tenant, and have to adjust role IDs accordingly.
