# 7.1 Create Group

Using `createGroup` method a new group is created. The group can be either of type `PUBLIC` or `PRIVATE`, from the enum GroupType in BayunCore. The user creating the group automatically becomes a member of the group, with full authorization for complete group-management functionality for that group. The developer can choose to enforce more fine-grained access controls if desired.

**Method parameters :**

* **groupName**: Group name(Optional)
* **groupType**: Type of group.
* **success**: Success block to be executed after group is successfully created.
* **failure**: Failure block to be executed if group creation fails, returns BayunError.

{% tabs %}
{% tab title="Java" %}
```java
String groupName = "<groupName>";

//Success Callback
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        String groupId = message.getData().getString("groupId");
        Log.d(TAG, "Group created 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 creating group.");
        return false;
    }
};

bayunCore.createGroup(groupName, BayunCore.GroupType.PUBLIC, success, failure);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val groupName = "<groupName>"

//Success Callback
val success = Handler.Callback {
    val groupId = it.data.getString("groupId")
    Log.d(TAG, "Group created successfully.")
    false
}
//Failure Callback
val failure = Handler.Callback {
    val error = it.data.getString("BayunError", "")
    Log.d(TAG, "Error creating group.")
    false
}

bayunCore.createGroup(groupName, BayunCore.GroupType.PUBLIC, success, failure)
```
{% endtab %}
{% endtabs %}
