# 7.6 Add Group Member

The `addInGroup` method is used to add a new member to the Group. The member to be added in the group may belong to a different company, provided that the company and the member must already be registered with Bayun. Any existing member of the group can add a new member. 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).

**Method parameters :**

* **groupId**:  Group Id of the Group.
* **groupMember** : `GroupMember` with companyName and companyEmployeeId
* **success**: Success block to be executed after member is added to the group.
* **failure**: Failure block to be executed if member could not be added to the group, returns `BayunError`.

{% tabs %}
{% tab title="Java" %}

```java
import com.bayun_module.GroupMember

String companyEmployeeId = "<companyEmployeeId>";
String companyName = "<companyName>";
String groupId = "<groupId>";

GroupMember groupMember = new GroupMember();
groupMember.companyEmployeeId = companyEmployeeId;
groupMember.companyName = companyName;
            
//Success Callback
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        Log.d(TAG, "Member added in the Group successfully.");
        return false;
    }
}

//Failure Callback
Handler.Callback failure = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        String error = message.getData().getString("BayunError", "");
        Log.d(TAG, "Error adding the group member.");
        return false;
    }
};

bayunCore.addInGroup(groupId, groupMember, success, failure);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import com.bayun_module.GroupMember

val companyEmployeeId = "<companyEmployeeId>"
val companyName = "<companyName>"
val groupId = "<groupId>"

val groupMember: GroupMember =  GroupMember()
groupMember.companyEmployeeId = companyEmployeeId
groupMember.companyName = companyName
        
        
//Success Callback
val success = Handler.Callback {
    Log.d(TAG, "Member added in the Group successfully.")
    false
}
//Failure Callback
val failure = Handler.Callback {
    val error = it.data.getString("BayunError", "")
    Log.d(TAG, "Error adding the group member.")
    false
}


bayunCore.addInGroup(groupId, groupMember, success, failure)

```

{% 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-android/6.-groups/6.6-add-group-member.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.
