# 6.7 Add Group Members

The `addGroupMembers` function is used to add  new members to the Group. The members to be added in the group may belong to different companies, provided that the company and the member must already be registered with Bayun. Any existing member of the group can add new members. The developer can enforce stricter access-mechanisms on top if desired (e.g. only group-owner or group-admin is allowed to add new members).

The function takes the following parameters :

* **sessionId** : Unique SessionId which is received in the registration/login function response.
* **groupId**  :  GroupId of the group.
* **groupMembers**  : Members to be added in the group.

{% tabs %}
{% tab title="C++" %}

```cpp
#include "BayunCore.h"

std::vector<Bayun::GroupMember> groupMembers;
Bayun::GroupMember groupMember("<companyEmployeeId>", "<companyName>");
groupMembers.push_back(groupMember);
Bayun::ShAddGroupMembersResponse response = bayunCore->addGroupMembers("<sessionId>", "<groupId>", groupMembers);
std::vector<Bayun::ShAddMemberErrObject>  addMemberErrObjects =  response->addMemberErrObjects;

for (Bayun::ShAddMemberErrObject errObject : addMemberErrObjects) {
        std::string  errorMessage = errObject->errorMessage;
        std::vector<Bayun::ShGroupMember> membersList = errObject->membersList;
        for (Bayun::ShGroupMember groupMember : membersList) {
          std::string companyName = groupMember->companyName;
          std::string companyEmployeeId = groupMember->companyEmployeeId;
        }
 }
      
std::string addedMembersCount = response->addedMembersCount;
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bayun.gitbook.io/bayuncoresdk-cpp/groups/add-group-members.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
