Assign user to groups on user update

I know that you can assign a user to groups on creation, e.g.

curl -v -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-d '{
  "profile": {
    "firstName": "Isaac",
    "lastName": "Brock",
    "email": "isaac.brock@example.com",
    "login": "isaac.brock@example.com",
    "mobilePhone": "555-415-1337"
  },
  "groupIds": [
    "00g1emaKYZTWRYYRRTSK",
    "00garwpuyxHaWOkdV0g4"
  ]
}' "https://${yourOktaDomain}/api/v1/users?activate=false"

But is there any way to do the same thing on user update? From the documentation it seems like you have to add user to group/remove user from group separately, but I’d like to be able to do it in the same operation as updating the profile. Something like:

curl -v -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-d '{
  "profile": {
    "firstName": "Isaac",
    "email": "isaac.brock@update.example.com",
    "mobilePhone": "555-415-1337"
  },
  "groupIds": [
    "00g1emaKYZTWRYYRRTSK",
    "00garwpuyxHaWOkdV0g4"
  ]
}' "https://${yourOktaDomain}/api/v1/users/00ub0oNGTSWTBKOLGLNR"

Thanks!

1 Like

Any suggestions on the above? facing the same issue

Any updates on the above? Having the same issue. Want to update user’s groups, but should add and remove them one by one. As result - very bad performance. Can be 20 separate requests just to update user groups