We’ve used the assign a role call to try and update a user’s role (link here). However, we don’t want to add the role to a list of roles but rather replace it. So it is possible to update the role assigned to the user without adding to that list? So far I can only see a possibility of deleting the associated roles to the user and then adding a fresh one using that call, hopefully there’s something more straight forward than that option?
Thank you loads
Welcome to the Auth0 Community!
Yes, this is possible! To update an existing Role assigned to a user, you can call the Management API’s Update a role endpoint.
Please let me know if you have additional questions!
Thanks for your reply. Apologies for the miscommunication, what I meant was not updating the role itself but if I can basically replace one role assigned to a user with another. For example, if a user has the role of an admin, I want to know if there’s a patch or put request in the user directory or somewhere where it would make them a manager instead. So when looking at their roles, I would only see manager and not any other role assigned to them.
Thanks again for your time
Thanks for following up!
Unfortunately, there isn’t an endpoint to “replace” the user’s role with another one. One way I can think of to accomplish this behavior would be to delete the user’s old role first and then assign the new role to the user. However, this approach wouldn’t scale well if there are a lot of users assigned to this role.
So, one alternative that would work is to use the Management API’s Update a role endpoint to update the role with a new name and description. And if needed, modify the permissions. This can also be done on the Auth0 Dashboard > User Management > Roles > Your Role section.
And if needed, you could back up your Role first by using the Deploy CLI Tool.
I hope the explanation is clear!
Please let me know if you have any further questions.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.