> For the complete documentation index, see [llms.txt](https://bayun.gitbook.io/bayuncoresdk-javascript-programming-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bayun.gitbook.io/bayuncoresdk-javascript-programming-guide/groups.md).

# 7. Groups

BayunSDK provides public APIs for secure group-based data-access and basic group-management. Every group has its own secret-key that is unique for the group, and is accessible only to the members of that group. This shared group-key is used to encrypt the messages that are locked with encryption-policy of group, and also authenticate members, and control access to group resources. Since nobody other than group-members have access to the group's secret-key, only those belonging to the group will be able to access data encrypted with group-policy tied to that specific groupId.

Note that the main purpose of Groups functionality in Bayun framework is to enable enforcement of arbitrary data-access policies that are cryptographically tied to the data, and without burdening the developer with the headaches of key-management for the same. The framework provides only basic group-management functions for creating, modifying, and deleting a group in such a way that the developer can optionally create stricter access-control mechanisms for group-management if so desired, depending on the use-case at hand. For example, the Bayun framework treats every existing member of the group equally for group-management privileges, including the ability to add/remove other members, or delete the group. The developer can always build, or enforce, finer-grained group-management functionality on top of this, e.g. by introducing the notion of group-owner or group-admins with privileged access-rights etc.

## Group Types

Group type is defined when creating a new group. GroupType is an enum type and has following values:

**`PUBLIC`** : The group is public to the organization. Any employee of the organization can join this group, and hence get access to the shared group-key. The group's secret-key is kept encrypted in every member's own lockbox as well as kept encrypted with company's own secret-key, so that nobody outside the company can get access to it. An existing member, who already has access to the group-key, can add any other members to the group (even those outside the company).

**`PRIVATE`** : The group is private and accessible only to the existing members of the group. The group's secret-key is kept encrypted in every member's own lockbox only. An existing member can add anyone else to the member-list of the group, irrespective of whether they belong to the same company or not.

## Group APIs

{% content-ref url="/pages/-MWYAOgu04aK9lUT51J0" %}
[7.1 Create Group](/bayuncoresdk-javascript-programming-guide/groups/create-group.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWYCqVrU1E8cTKTMzHn" %}
[7.2 Get My Groups](/bayuncoresdk-javascript-programming-guide/groups/get-my-groups.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWYDT1WtfLNmF\_fBDv1" %}
[7.3 Get Unjoined Public Groups](/bayuncoresdk-javascript-programming-guide/groups/get-unjoined-public-groups.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWYDY3\_E1y8Iy4jdsFS" %}
[7.4 Join Public Group](/bayuncoresdk-javascript-programming-guide/groups/join-public-group.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWYDsXJzbtPlXJg-uKT" %}
[7.5 Get Group By Id](/bayuncoresdk-javascript-programming-guide/groups/get-group-by-id.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWYE5202NH0JxWqGSeW" %}
[7.6 Add Group Member](/bayuncoresdk-javascript-programming-guide/groups/add-group-member.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWYpXG03bPkYARuDb2y" %}
[7.7 Add Group Members](/bayuncoresdk-javascript-programming-guide/groups/add-group-members.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWYsmiKzAwhumfJM4xp" %}
[7.8 Remove Group Member](/bayuncoresdk-javascript-programming-guide/groups/remove-group-member.md)
{% endcontent-ref %}

{% content-ref url="/pages/4JbI85rnBYHgkyhrErow" %}
[7.9 Remove Group Members](/bayuncoresdk-javascript-programming-guide/groups/7.9-remove-group-members.md)
{% endcontent-ref %}

{% content-ref url="/pages/r0yZF47ps3CU6MV63UcU" %}
[7.10 Remove Group Members Except List](/bayuncoresdk-javascript-programming-guide/groups/7.10-remove-group-members-except-list.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWZ4fro1e9\_xhHZqwy8" %}
[7.11 Leave Group](/bayuncoresdk-javascript-programming-guide/groups/leave-group.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MWZ4wsa-lBYsz1laETm" %}
[7.12 Delete Group](/bayuncoresdk-javascript-programming-guide/groups/delete-group.md)
{% endcontent-ref %}
