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 entityId not provided
  • Cross-entity assignment requires hierarchy access (parent can assign in child entities)
  • Requires role:create permission in the target entity
Path Parameters
  • userId
    Type: stringFormat: uuid
    required

    User ID (UUID)

Body
required
application/json
  • roleName
    Type: string
    required

    Role name to assign (e.g., entity-admin, team-admin)

  • entityId
    Type: stringFormat: uuid

    Entity scope (defaults to current user's entity). Requires hierarchy access for cross-entity assignments.

  • resourceGroupId
    Type: stringFormat: uuid

    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