Role members API

Fetch the members who hold a role, and add and remove members from a role, through the Heylo API.

The API is included on the Business plan. See plans.

Role members are the members of a group who hold one role. Updating role members through the API keeps role membership in step with your own system, without an admin doing it by hand. Role members are identified by Heylo user ID, the same IDs that key an event attendance response.

Operations

  • Fetch role members: POST https://api.heylo.com/apiv1-fetch with type set to "roleMembers"
  • Update role members: POST https://api.heylo.com/apiv1-update with type set to "roleMembers"

Fetch role members

Returns the members who hold one role.

POST https://api.heylo.com/apiv1-fetch

Parameters

  • communityId (string, required): the group ID.
  • roleId (string, required): the role's id, from a fetch roles response.
  • type (string, required): "roleMembers".

Returns

  • memberUserIds (array): the Heylo user IDs of the members who hold the role. A role nobody holds returns an empty list.
bash
curl -X POST https://api.heylo.com/apiv1-fetch \
  -H "Authorization: Bearer HEYLO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "communityId": "HEYLO_GROUP_ID",
    "roleId": "HEYLO_ROLE_ID",
    "type": "roleMembers"
  }'
json
{"memberUserIds": ["HEYLO_USER_ID_1", "HEYLO_USER_ID_2"]}

Update role members

Adds and removes members from a role in one request. Role member updates do not need write access on the key.

POST https://api.heylo.com/apiv1-update

Parameters

  • communityId (string, required): the group ID.
  • roleId (string, required): the role's id.
  • type (string, required): "roleMembers".
  • addedUserIds (array, optional): the Heylo user IDs to give the role, up to 100 per request.
  • removedUserIds (array, optional): the Heylo user IDs to take the role from, up to 100 per request.

Send at least one of addedUserIds or removedUserIds. IDs that do not belong to a current member of the group are skipped without an error. An ID in both lists is removed from the role.

Returns

  • addedUserIds (array): the IDs that were given the role.
  • removedUserIds (array): the IDs the role was taken from.

An ID missing from the response was skipped because it is not a current member. A member who already had the role, or never had it, still appears in the response.

bash
curl -X POST https://api.heylo.com/apiv1-update \
  -H "Authorization: Bearer HEYLO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "addedUserIds": ["HEYLO_USER_ID_1"],
    "communityId": "HEYLO_GROUP_ID",
    "removedUserIds": ["HEYLO_USER_ID_2"],
    "roleId": "HEYLO_ROLE_ID",
    "type": "roleMembers"
  }'
json
{"addedUserIds": ["HEYLO_USER_ID_1"], "removedUserIds": ["HEYLO_USER_ID_2"]}

Errors for role members

Role member operations return the standard errors, with these cases:

  • 404: the role does not exist in this group.
  • 400: addedUserIds or removedUserIds holds more than 100 IDs, or both are empty.
  • 403: the role belongs to an organization, and this group is not part of that organization.

Related articles

Still need help?

Contact us and we typically reply within one business day. Or message us in Heylo Support chat.