Get Started: Group Management using REST APIs and Console

Estimated reading time: 4 minutes

In this part, we will learn about Group Management using REST APIs and Console. Note that this is not the recommended approach and should be only used for administrative purposes. You should instead use real-time Group Management APIs.

Real-time Group Management APIs

Prerequisites

You MUST go through the following prerequisites before you read further.

Creating a Group

You can create a group either using Mesibo Real-time APIs (recommended), Backend APIs, or console. Here, we will describe methods for creating a group - using REST APIs and using the console.

Creating a group using REST API

You need to use Group Management REST APIs.

To create a group, invoke the backend API with the following parameters:

  • op = “groupadd”
  • token = Application Token obtained from mesibo console
  • name = Group Name [Optional]
  • flag = Group Flags (described below)
  • expiry = Expiry in seconds, default 1 year
  • expiryext = Auto extend expiry on group activity, in seconds. Default disabled.
  • active = 1 to enable, 0 to disable Group Flags can be a logical OR combination of one or more flags value below:

  • 0 - normal group, only members can send
  • 1 - only selected members can send (refer add members API below)
  • 2 - anyone can send
  • 0x10 - only selected members can receive (refer add members API below)
  • 0x20 - received by one member in the round-robin fashion
  • 0x40 - do no store group messages
  • 0x80 - loop back to the sender

Response Fields

response[‘group’][‘gid’] = Group ID (GID)

Example:

https://api.mesibo.com/api.php?op=groupadd&token=123434343xxxxxxxxx&name=testGroup&flag=0

If group creation is successful, you should receive a response that looks like below

{..<truncated>.. ,"group":{"gid":102529},"op":"groupadd","result":true}

In the above example, we have created a group with the group-id 102529. Make note of this. You can save this group-id and other group information in your database so that you can access it later. To perform any kind of group management operations like adding or deleting members, changing group permissions, etc. you will need a valid group-id.

Add Group Members using REST API

Now you can add Group Members using GID obtained in that you obtained when you created the group.

  • op = “groupeditmembers”
  • token = Application Token obtained from mesibo console
  • gid = Group ID (GID)
  • m = comma-separated list of user addresses to add or remove in the group
  • cs = 1 if members being added can send messages to the group, 0 for not
  • cr = 1 if members being added can receive group messages, 0 for not
  • canpub = [group calling] 1 if members being added can make (publish) group voice or video calls, 0 for not
  • cansub = [group calling] 1 if members being added can subscribe to group voice or video calls, 0 for not
  • canlist = [group calling] 1 if members being added can get a list of active callers in the group, 0 for not
  • delete = 0 to add members, 1 to remove members

You can only add valid users to the group. So, before you proceed ensure you have created users

For example, to add members with address member1, member2, member3 to the group with group-id 102529 invoke the API as follows:

https://api.mesibo.com/api.php?op=groupeditmembers&token=123434343xxxxxxxxx&gid=102529&m=member1,member2,member3&delete=0

Now, we will learn how to create a group and manage it from the mesibo console.

Creating a Group in mesibo console

If you would like to create a group using the console, Go to your App Settings and click on Groups. Then, click on the + NEW GROUP button. Give a group name - example Mesibo Group and click on Create. Your group with the name Mesibo Group should now be created and be displayed in the table. Click on the edit icon, under actions. This will open the Group Settings page. Replicate settings shown below.

Group Permissions

Adding users to your Group in mesibo console

Go to your App Settings and then click on Groups. Open the group you want to edit, and then Click on the + NEW MEMBER button. Enter the address of the user whom you wish to add. Click on Add. The Members table will now display the member you just added. Similarly, add more users.

The users you add should be existing mesibo users. Otherwise, create those users before you try to add them.

Group Members

mesibo, android, ios, js, group, rest