User Groups API
Manage large fleets of administrators via unified User Groups. Supports bulk operations, cascading deletions, and additive role assignments.
The User Groups API manages bulk collections of roles and field restrictions assigned to administrators. Removing a group, restricting a permission, or cascading a deletion updates all attached administrators instantly at their next token refresh.
User Groups CRUD
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/v1/UserGroups | Retrieve a paginated list of all User Groups. SuperAdmins see global groups; Tenant Admins see only their tenant's. | 🔒 Required |
| GET | /api/v1/UserGroups/myTenantGroups | Quick-fetch essential group data for the authenticated user's active tenant (optimized for dropdowns). | 🔒 Required |
| GET | /api/v1/UserGroups/{id} | Fetch massive detail for a specific User Group, including all active members, roles, and JSON field restrictions. | 🔒 Required |
| GET | /api/v1/UserGroups/byTenantId/{tenantId} | SuperAdmin only. Fetch groups filtered directly by a specific TenantId. | 🔒 Required |
| POST | /api/v1/UserGroups | Create a new User Group, strictly validating that the provided RoleIds exist and belong to the target Tenant. | 🔒 Required |
| POST | /api/v1/UserGroups/createForMyTenant | Create a new User Group automatically mapped to the JWT's TenantId context. | 🔒 Required |
| PUT | /api/v1/UserGroups/{id} | Update core group metadata (Name, Description, Status) and perform a full nuke-and-pave synchronization of RoleIds. | 🔒 Required |
| DELETE | /api/v1/UserGroups/{id} | Soft-delete a User Group (AdminAdminGroup relations are automatically orphaned). | 🔒 Required |
GET /api/v1/UserGroups/{id} — Response (200 OK)JSON
{
"id": "ENCRYPTED_USER_GROUP_ID",
"nameEn": "Finance Team",
"nameAr": "فريق المالية",
"code": "FINANCE_TEAM",
"descriptionEn": "All finance department admins",
"descriptionAr": "جميع مشرفي القسم المالي",
"tenantId": "ENCRYPTED_TENANT_ID",
"isActive": true,
"members": [
{
"adminId": "ENCRYPTED_ADMIN_ID",
"firstName": "John",
"lastName": "Doe",
"username": "johndoe",
"email": "john@example.com",
"isActive": true
}
],
"roles": [
{
"roleId": "ENCRYPTED_ROLE_ID",
"nameEn": "Accountant",
"nameAr": "محاسب",
"code": "ACCOUNTANT",
"permissionCount": 12
}
],
"restrictions": [
{
"permissionCode": "admins.view",
"restrictedFields": ["salary", "ssn", "bankAccount"]
}
]
}Group Members
Manage the administrators assigned to a specific User Group.
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/v1/UserGroups/{groupId}/members | Append one or more AdminIds to the group. This operation is idempotent. | 🔒 Required |
| DELETE | /api/v1/UserGroups/{groupId}/members/{adminId} | Sever the link between an Admin and the Group. Does not affect the Admin's directly assigned roles. | 🔒 Required |
POST /api/v1/UserGroups/{groupId}/members — RequestJSON
{
"adminIds": [
"ENCRYPTED_ADMIN_ID_1",
"ENCRYPTED_ADMIN_ID_2"
]
}Group Roles & Restrictions
Manage the exact role payloads and field-level serialization blocks inherited by the group's members.
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| PUT | /api/v1/UserGroups/{groupId}/roles | Perform a destructive, nuke-and-pave synchronization of all RoleIds assigned to the Group. | 🔒 Required |
| PUT | /api/v1/UserGroups/{groupId}/restrictions | Perform a destructive, nuke-and-pave synchronization of all JSON field restrictions for the Group. | 🔒 Required |
PUT /api/v1/UserGroups/{groupId}/roles — RequestJSON
{
"roleIds": [
"ENCRYPTED_ROLE_ID_1",
"ENCRYPTED_ROLE_ID_2"
]
}Bulk & Cascade Operations
Execute massive operational commands across thousands of records simultaneously, optionally cascading the effects down to the associated member administrators.
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/v1/UserGroups/bulk/activate | Bulk set IsActive=true for multiple User Groups. Options to cascade activation to members. | 🔒 Required |
| POST | /api/v1/UserGroups/bulk/deactivate | Bulk set IsActive=false for multiple User Groups. Options to cascade deactivation to members. | 🔒 Required |
| POST | /api/v1/UserGroups/bulk/delete | Bulk soft-delete multiple User Groups. Options to cascade soft-delete to members. | 🔒 Required |
| POST | /api/v1/UserGroups/bulk/activate-all | Bulk activate all User Groups matching the specified filter criteria (supports cascadeAdmins). | 🔒 Required |
| POST | /api/v1/UserGroups/bulk/deactivate-all | Bulk deactivate all User Groups matching the specified filter criteria (supports cascadeAdmins). | 🔒 Required |
| POST | /api/v1/UserGroups/bulk/delete-all | Bulk soft-delete all User Groups matching the specified filter criteria (supports cascadeAdmins). | 🔒 Required |
POST /api/v1/UserGroups/bulk/{activate|deactivate|delete} — RequestJSON
{
"ids": [
"ENCRYPTED_GROUP_ID_1",
"ENCRYPTED_GROUP_ID_2"
],
"cascadeAdmins": true
}