Skip to main content
POST
/
tenant
/
{tenantId}
/
admin
/
user
/
roles
PostTenantUserRoles
curl --request POST \
  --url https://api.example.com/tenant/{tenantId}/admin/user/roles \
  --header 'Content-Type: application/json' \
  --data '
{
  "tenantUserId": 256,
  "roles": [
    1,
    2,
    3
  ]
}
'
{
  "isSuccess": true,
  "isFailure": false,
  "error": null,
  "value": {
    "id": 42,
    "name": "Example"
  }
}

Description

This endpoint assigns a set of roles to a tenant user, replacing all existing role assignments. The operation is atomic - either all roles are assigned successfully or the assignment fails.

Input

  • tenantId (path, required): Identifier of the tenant that owns the user
  • request (body, required): Payload containing the user and role identifiers
    • tenantUserId: Identifier of the user receiving role assignments
    • roles: Array of role identifiers to assign
  • cancellationToken (optional): Token to cancel the asynchronous operation

Output

Returns a Result<TenantRoleViewModel[]> containing the resulting role assignments after the operation completes.

Examples

Request:
POST /api/tenant/1024/users/roles
Content-Type: application/json

{
  "tenantUserId": 256,
  "roles": [1, 2, 3]
}
Response (200 OK):
{
  "data": [
    {
      "id": 1,
      "name": "TenantAdministrator",
      "description": "Grants full tenant administration capabilities.",
      "permissions": [
        { "id": 101, "name": "ManageUsers" }
      ]
    },
    {
      "id": 2,
      "name": "WalletOperator",
      "description": "Allows wallet and transaction management.",
      "permissions": [
        { "id": 102, "name": "ManageWallets" }
      ]
    },
    {
      "id": 3,
      "name": "Auditor",
      "description": "Read-only access to tenant data.",
      "permissions": [
        { "id": 105, "name": "ViewReports" }
      ]
    }
  ],
  "isSuccess": true
}

Errors

  • 400 Bad Request: Invalid payload or role identifiers
  • 401 Unauthorized: Authentication credentials are missing or invalid
  • 403 Forbidden: User lacks permission to modify tenant user roles
  • 404 Not Found: Tenant user or specified roles do not exist
  • 500 Internal Server Error: Unexpected server error occurred during assignment

Notes

  • This operation replaces all existing role assignments for the user
  • All specified role identifiers must exist and be valid for the tenant
  • Empty roles array removes all role assignments from the user
  • Changes take effect immediately for the user’s next operation

Path Parameters

tenantId
integer<int64>
required

Identifier of the tenant that owns the user.

Body

application/json

Payload describing the tenant user and role identifiers to assign.

Request to assign roles to a tenant user.

tenantUserId
integer<int64>

Identifier of the tenant user receiving the role assignments.

Example:

256

roles
integer<int64>[]

Collection of role identifiers to assign to the tenant user.

Example:
[1, 2, 3]

Response

Roles assigned successfully.

Wrapper for API operation results containing success status, error information, and return value.

isSuccess
boolean

True if the operation completed successfully, false otherwise.

Example:

true

isFailure
boolean

True if the operation failed, false otherwise.

Example:

false

error
object

Error information returned when the operation fails.

Example:
{
"code": "ValidationError",
"message": "The request parameters failed validation.",
"info": [
"The Name field is required.",
"The Id field must be greater than 0."
]
}
value
object[] | null

The result value returned when the operation is successful.