Forum Discussion

mkuehnkhoros's avatar
5 years ago

Bulk Add Users to Group Hubs via API Calls?

Is there any way to programmatically bulk add users to multiple group hubs using API calls?Ideally, I'd like to take a CSV data with columns "group_hub_id, user_id, role" and iterate over it, adding ...
  • allensmith81's avatar
    5 years ago

    Hi mkuehnkhoros 

    Some good news on this, you can actually do this, but you have to bypass the membership API in v2.

    You essentially need to call the APIv1 endpoint and add users i.e:

    https://yourcommunity.com/restapi/vc/roles/id/<roleid>/users/add?role.user=id/<userid>&restapi.session_key=<apiKey>
    
    you can use other varients of this but in my example above lest assume we want to add user 52 to the owner role for Group Hub MyHub, which has a role id of 216.
    
    You would make a post call like this:
    https://yourcommunity.com/restapi/vc/roles/id/216/users/add?role.user=id/52&restapi.session_key=dkldjlkfjgdlkfjdflkjg4989438u