madmaniac
KKinde
•Created by madmaniac on 8/9/2024 in #💻┃support
Remove all roles of a user
Hello,
I'm trying to remove all the roles of a user using one API call. Let's say I have a user with 5 roles.
I tried using "PATCH /api/v1/organizations/{org_code}/users". In this request, if I pass in 1 role (or more), the user is updated and will have 1 role only. But if I pass in no roles (empty array), then the request returns 200, but does nothing. The users still has all previous roles.
Do I need to use "DELETE /api/v1/organizations/{org_code}/users/{user_id}/roles/{role_id}"? That would be cumbersome. I would first have to request the current roles, and then do 5 calls to delete each one of them.
Instead, I could use "PATCH /api/v1/organizations/{org_code}/users" to reduse the user's roles from 5 to 1, and then use "DELETE /api/v1/organizations/{org_code}/users/{user_id}/roles/{role_id}" to delete the user's role. But that would be weird.
What is the best approach here?
8 replies