Assign a role to a user
Assign a role to a user with optional entity or team scope.
Entity Authorization:
- Defaults to current user's entity if
entityIdnot provided - Cross-entity assignment requires hierarchy access (parent can assign in child entities)
- Requires
role:createpermission in the target entity
Path Parameters
- Type: stringFormat: uuiduser
Id requiredUser ID (UUID)
Body
required
application/json
- Type: stringrole
Name requiredRole name to assign (e.g., entity-admin, team-admin)
- Type: stringFormat: uuidentity
Id Entity scope (defaults to current user's entity). Requires hierarchy access for cross-entity assignments.
- Type: stringFormat: uuidresource
Group Id Resource group scope (optional, for group-scoped roles)
Responses
- 201
Role assigned successfully
- application/json
- 403
Forbidden - No access to target entity or insufficient permissions
- 404
Role not found
- application/json
Request Example for post/users/{userId}/roles
curl https://api.gpcn.com/v1/users/123e4567-e89b-12d3-a456-426614174000/roles \
--request POST \
--header 'Content-Type: application/json' \
--header 'X-API-Key: YOUR_SECRET_TOKEN' \
--data '{
"roleName": "",
"entityId": "",
"resourceGroupId": ""
}'
No Body
.png)