#TipTuesday Manage group leaders and owners via the API

Options

Are you currently managing your group leaders by inviting them to be a member of the group, waiting for them to accept the invitation, and then manually promoting them to be a leader? Have you ever had to submit a ticket to Support to change the owner of a group? This #TipTuesday will help you streamline the process for managing group leaders and group owners.

What you’ll need:

  1. The groupID of the group you’re updating. You can find this by looking at the groups URL, which will contain a number after www.communitydomain.com/group/… In this example, the Demo Group’s groupID: 4.
  2. The userID of the new leader or owner. You can find this by navigating to the user’s profile and adding “.json” to the end of the URL (www.communitydomain.com.profile/username.json) which will expose some data on the user. In this example, hhowle11’s userID: 19.

Now that you have this info, you can look into…

Adding a user to a group as a leader

  1. Navigate to your API v2 Swagger page (Dashboard > Settings > API v2).
  2. Navigate to the POST /groups/{id}/members API endpoint.
  3. Expand the endpoint and click “Try it Out”. Here, you’ll enter the groupID (4) and update the request body to include the proper user role assignment (“leader”) and userID (19). Click the blue “Execute” button.
  4. Now, when you navigate to the group you will see that user added as a Leader.

Want to take it a step further?

Make a user the group owner

  1. Navigate to your API v2 Swagger page (Dashboard > Settings > API v2).
  2. Navigate to the PATCH /groups/{id} API endpoint.
  3. Expand the endpoint and click “Try it Out”. Here, you’ll enter the groupID (4) and remove all data from the request body except “ownerUserID”, which you’ll update with the userID (19). Click the blue “Execute” button.
    1. ⚠️Note⚠️ Failure to remove the other details in the request body will cause you to overwrite existing group details, like the description, privacy settings, or branding.
  4. Now, when you navigate to the group you will see that user as the Owner.

Hope this helps with your group management efforts!

Tagged:

Comments