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

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”]
}

Hi @saurya.dacharya,

Welcome to the Auth0 Community!

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:

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.