Assign Role to User
Assign a role to a specific user.Endpoint
Authorization
Requires Administrator role.Request Body
ID of the user to assign the role to
Name of the role to assign (e.g., “Administrator”, “User”, “Manager”)
Response
HTTP status code: 204 No Content on success
Example Request
Validation Rules
- User must exist in the system
- Role must exist in the system
- User cannot have duplicate role assignments
Remove Role from User
Remove a role assignment from a user.Endpoint
Authorization
Requires Administrator role.Request Body
ID of the user to remove the role from
Name of the role to remove
Response
HTTP status code: 204 No Content on success
Example Request
Validation Rules
- User must exist in the system
- Role must exist in the system
- User must currently have the role assigned
Get User Roles
Retrieve all roles assigned to a specific user.Endpoint
Authorization
Requires Administrator role.Path Parameters
ID of the user to retrieve roles for
Response
Array of role names assigned to the user
Example Request
Example Response
Common Use Cases
Promote User to Administrator
Revoke Administrative Access
Batch Role Assignment
Error Responses
Bad Request - Invalid request parameters, user not found, or role not found
Forbidden - User does not have Administrator role
Conflict - Role already assigned (for assign) or role not assigned (for remove)
Best Practices
Verify Before Assigning
Verify Before Assigning
Always check if a user already has a role before assigning it to avoid unnecessary API calls and potential errors.
Audit Role Changes
Audit Role Changes
Log all role assignments and removals for security auditing purposes. Consider implementing a webhook or event system to track these changes.
Handle Errors Gracefully
Handle Errors Gracefully
Always check response status codes and handle errors appropriately. A 400 error may indicate the user or role doesn’t exist.
Use Role Names Consistently
Use Role Names Consistently
Role names are case-sensitive in the request but matched case-insensitively. Use the predefined role constants: “Administrator”, “User”, “Manager”.