# 7.5 Get Group By Id

The `getGroupById` returns details of a group. Details include groupId, name, type, groupMembers. Any existing member of the group can retrieve details of the group, including the list of all the group members.

**Method parameters :**

* **groupId** : Group Id of the Group.
* **success** : Success block to be executed after group details are successfully retrieved.
* **failure** : Failure block to be executed if group details could not be retrieved, returns `BayunError`.

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

```java
String groupId = "<groupId>";
Group groupDetails;

// Callbacks to get group info by its id
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        Log.d(TAG, "Get group by id call successful.");
        groupDetails = (Group)message.getData().getSerializable("BayunGetGroup");
        
        Log.d(TAG, "group id: " + groupDetails.groupId);
        Log.d(TAG, "group name: " + groupDetails.groupName);
        Log.d(TAG, "group type: " + groupDetails.groupType);
        ArrayList<GroupMember> groupMembers = (ArrayList<GroupMember>)groupDetails.groupMembers;
        
        for (GroupMember member: groupMembers) {
            Log.d(TAG, "companyEmployeeId: " + member.companyEmployeeId));
            Log.d(TAG, "companyId: " + member.companyId);
            Log.d(TAG, "companyName: " + member.companyName));
        }
        return false;
    }
};

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

bayunCore.getGroupById(groupId, success, failure);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
var groupId = "<groupId>"
var groupDetails: Group

// Callbacks to get group info by its id
val success = Handler.Callback {
    Log.d(TAG, "Get group by id call successful.")
    groupDetails = it.data.getSerializable("BayunGetGroup") as Group
    Log.d(TAG, "group id: " + groupDetails.groupId)
    Log.d(TAG, "group name: " + groupDetails.groupName)
    Log.d(TAG, "group type: "+ groupDetails.groupType)
    
    val groupMembers = groupDetails.groupMembers
    as ArrayList<GroupMember>
    
    for (member in groupMembers) {
        Log.d(TAG, "companyEmployeeId: " + member.companyEmployeeId)
        Log.d(TAG, "companyId: " + member.companyId)
        Log.d(TAG, "companyName: " + member.companyName)
    }
    false
}

val failure = Handler.Callback {
    val error = it.data.getString("BayunError", "")
    Log.d(TAG, "Error getting group.")
    false
}

bayunCore.getGroupById(groupId, 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.5-get-group-by-id.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.
