Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Why is it impossible for me to change the group membership of a user via PATCH?

    Posted 04-14-2025 05:54

    According to [PATCH /api/v2/users/{userId}](https://developer.genesys.cloud/useragentman/users/#patch-api-v2-users--userId-), it looks like it should be possible for me to change the group membership of a user by sending the appropriate "groups" array containing the names and types of the groups the agent should be a member of.

    But when I try to change a user by using the API Explorer, I do not get any error, but also no effect - the PATCH-request has no request.

    The request I send along looks like this (group names have been redacted):

    {
      "version": 73,
      "groups": [
        {
          "type": "official",
          "name": "group-name-redacted",
          "visibility": "public",
          "rulesVisible": true
        }
      ]
    }

    I get back a result code of 200, but the group membership is not changed. This is the case both for existing and for new groups.

    What is the problem with this approach, and is there any way to debug this by some kind of cloud audit log?

    Thanks in advance,

    Wolfgang Liebich


    #Integrations
    #PlatformAPI
    #PlatformSDK

    ------------------------------
    Wolfgang Liebich
    Consultant
    ------------------------------


  • 2.  RE: Why is it impossible for me to change the group membership of a user via PATCH?

    Posted 04-15-2025 09:23

    Hi Wolfgang, 

    I located some information on this. 

    The patch user API is not the correct API to add the user to a group. 

    The correct API is: https://developer.genesys.cloud/devapps/api-explorer#post-api-v2-groups--groupId--members

    The PATCH API will only edit the current information that this user already has, but it will not add them to any groups as there is a dedicated API for this function.



    ------------------------------
    Lonny Schwartz
    Principal PS Consultant
    ------------------------------



  • 3.  RE: Why is it impossible for me to change the group membership of a user via PATCH?

    Posted 04-16-2025 08:26

    Hi, Lonny,

    thanks for your answer - that is exactly like it looked for me.

    I did finally use the APIS [POST /api/v2/groups/{groupId}/members](https://developer.genesys.cloud/useragentman/groups/#post-api-v2-groups--groupId--members) and [DELETE /api/v2/groups/{groupId}/members](https://developer.genesys.cloud/useragentman/groups/#delete-api-v2-groups--groupId--members) (which you need to delete users from a group), but the PATCH USER API would have been easier to use and also require fewer API calls.

    I do not really understand, though, why the payload for this API contains a "Groups" field at all - it seems that it will be useless anyway, or can it have any effect?

    Making this API also work for setting the group memberships of a user would be useful, as it would simplify the logic (we do not have to find out which groups the user must be added to and from which the user must be removed), and it would also cut down on the number of API calls.

    Regards,

    Wolfgang Liebich



    ------------------------------
    Wolfgang Liebich
    Consultant
    ------------------------------