Assign the user to multiple User Groups
POST/groups-srv/usergroups/maps/:sub
Assign or change multiple group memberships for one user in a single request.
Use the instruction field to control how each entry in userGroupMaps is handled.
Memberships not listed in the request are never added or removed by this call alone.
Instructions (choose one):
| Instruction | When to use | Effect on listed groups | Effect on other memberships for this user |
|---|---|---|---|
insert | Add groups without changing existing memberships | Creates a new membership per entry | Left unchanged |
update | Change roles only where the user is already a member | Updates roles for existing (sub, groupId) only | Left unchanged |
upsert | Add or change roles in one call | Creates missing memberships; updates roles if already a member | Left unchanged |
replaceAll | Update roles for listed groups only (same as update per entry) | Updates roles for existing (sub, groupId) only | Left unchanged |
Per-instruction details:
insert: Creates new memberships only. If(sub, groupId)already exists, that entry is skipped and reported in the bulk response (other entries still process).update: Updates roles for existing memberships only. Does not create new memberships. Entries without an existing map fail for that item only.upsert: Creates the membership if it does not exist, or updates roles (including clearing roles when an emptyrolesarray is sent) if it does.replaceAll: Behaves likeupdatefor each listed group — updates roles where membership already exists; does not create new memberships and does not remove groups omitted from the list.
Choosing an instruction:
- Add the user to more groups →
insert - Change roles when membership already exists →
update - Add groups or change roles (membership may or may not exist) →
upsert
Setting an exact membership list (recommended design):
This endpoint does not remove unlisted groups in one step. Compose calls as needed:
- Adjust a few groups:
GET /groups-srv/usergroups/maps/{sub}to read current memberships, thenDELETE /groups-srv/usergroups/{groupId}/users/{sub}for each group to remove, andPOSTthis endpoint withupsert(orinsertfor add-only) for the desired set. - Replace the full set:
DELETE /groups-srv/usergroups/maps/{sub}to remove all memberships for the user, thenPOSTwithinstruction: upsertand the completeuserGroupMapslist.
Request body:
instruction(required): One ofinsert,update,upsert,replaceAlluserGroupMaps(required): Non-empty array of memberships to process
Validation rules:
- Path
subis required and identifies the user. - Each map should use the same
subas the path parameter (or omitsubso the path value applies). groupIdmust reference an existing user group.rolesmust comply with the group's groupTyperoleMode(when roles are provided).
Response behavior:
- Returns a bulk result with per-entry status. HTTP
200when the request is processed; individual entries may succeed, fail, or be skipped depending oninstructionand validation. - This is not all-or-nothing: one invalid
groupIddoes not roll back successful entries unless a fatal error aborts the request.
Related endpoints:
GET /groups-srv/usergroups/maps/{sub}— list current membershipsDELETE /groups-srv/usergroups/{groupId}/users/{sub}— remove one membershipDELETE /groups-srv/usergroups/maps/{sub}— remove all memberships for a user (optional transfer via request body)
Request
Responses
- 200
- 400
- 401
OK
Bad Request
Unauthorized