Whapi.Cloud is an easy-to-use WhatsApp API compatible with any programming language. Knowing that managing communities in WhatsApp is time-consuming, we have implemented convenient and simple mechanisms for working with communities. Let's familiarize ourselves with them in more detail.
What are WhatsApp Communities?
Simplistically speaking, communities in WhatsApp are a super-group of several smaller individual groups. To illustrate how the community structure works, take a look at the image below:
As you can see, Communities help avoid chaos in large WhatsApp groups by offering a structure where it's easy to manage threaded discussions and send announcements to all participants at once.
You can try our Whapi.Cloud API right now: after signing up, you are given a trial channel, it is limited to five days and does not require a linked card. After that, you can continue on the free plan.
This article will have more detailed instructions on how to get started: Let's Dive into Whapi.Cloud: A Three-Step Journey
How it works?
When you create a community, WhatsApp automatically creates a special group for announcements. While this may seem a bit unexpected, two groups with the same name are actually created. One is used as the “Announcements Group” to send messages to all members of the community, and the other is used for technical communication between groups. However, this won't create any difficulties in managing the community - you can easily work with them through the API.
Let's explore an example to understand how everything functions technically.
We'll begin by covering the basics — creating a new community.
Creating a new community
To create a WhatsApp community through the API, you'll need to use the following endpoint:
POST https://gate.whapi.cloud/communities
Here is an example request to get a new community:
curl --request POST \
--url https://gate.whapi.cloud/communities \
--header 'accept: application/json' \
--header 'authorization: Bearer {YOUR_TOKEN}' \
--header 'content-type: application/json' \
--data '
{
"subject": "A new community of scientists",
"description": "This is where we bring together all our faculties to stay connected and up to date with the latest news"
}
'
After creating a community, you will get its unique identifier, which is needed to bind or unbind groups. When you request a list of groups, you will see two groups with the same name but different identifiers. Pay attention to the “announcements” string - only the second group has it. This is the group you should use to send announcements or add members.
By the way, and in our documentation you will find sample requests in all popular programming languages, which can greatly facilitate the development of your integration
And this is how the response from the system will look like, indicating the successful execution of the request:
{
"id": "120363326919215056@g.us",
"name": "A new community of scientists",
"conversationTimestamp": 1727856652,
"subject": "A new community of scientists",
"subjectOwner": "919984351847@s.whatsapp.net",
"subjectTime": 1727856652,
"size": 1,
"creation": 1727856652,
"owner": "919984351847@s.whatsapp.net",
"desc": "This is where we bring together all our faculties to stay connected and up to date with the latest news",
"descId": "9A7C840518933B604F7257DB",
"restrict": false,
"announce": false,
"isCommunity": true,
"isCommunityAnnounce": false,
"joinApprovalMode": false,
"memberAddMode": false,
"participants": [
{
"id": "919984351847@s.whatsapp.net",
"admin": "superadmin"
}
],
"author": "919984351847@s.whatsapp.net"
}
Adding Participants
Now let's understand how to add a user to a WhatsApp community.
Adding a user to a community also follows the principles of adding a participant to a separate WhatsApp group. For this, use endpoint:
POST https://gate.whapi.cloud/communities/{CommunityID}/participants
An example of the request you need to pass can be found below:
curl --request POST \
--url https://gate.whapi.cloud/communities/120363326919215056%40g.us/participants \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"participants": [
"61371989950",
"919984651849"
]
}
'
- Due to WhatsApp's anti-spam policy, some contacts will not be added to the group automatically!
- All group members are automatically added to the announcements group.
- Removing a group from the community also removes members from the announcement group.
Receiving information about community members
It is often necessary to get general information about a community, such as the community name, description, community avatar and member details.
To do this, the following endpoint will be needed:
GET https://gate.whapi.cloud/communities/{CommunityID}
The API request will look like this:
curl --request GET \
--url https://gate.whapi.cloud/communities/120363330016374615%40g.us \
--header 'accept: application/json' \
--header 'authorization: Bearer {Your_Token}'
You will receive the response in the following form:
{
"id": "120363383016284615@g.us",
"name": "The fans",
"type": "group",
"timestamp": 1726495201,
"chat_pic": "https://pps.whatsapp.net/v/t61.24694-24/45953409_389421433863366_1005252150886406739_n.jpg?stp=dst-jpg_s96x96&ccb=11-4&oh=01_Q5AaID5KTLWAwXvRX9fgs8wo5ktRhbO6BA8_4BjhtULS9jn2&oe=670A3091&_nc_sid=5e03e0&_nc_cat=108",
"not_spam": false,
"last_message": {
"id": "ASh2dw-wngBq53PmZvvVw",
"type": "system",
"subtype": "group_change_icon",
"chat_id": "120363383016284615@g.us",
"from": "919984351847",
"from_me": true,
"source": "system",
"timestamp": 1727128547,
"status": "pending"
},
"participants": [
{
"id": "306894857630",
"rank": "admin"
},
{
"id": "61393175919",
"rank": "creator"
},
{
"id": "905544751391",
"rank": "admin"
}
],
"name_at": 1724862124,
"description": "heavy music fans by country",
"description_id": "6959470654CD9BE1FB509998",
"created_at": 1724862124,
"created_by": "61371989950"
}
It is important to remember that you cannot get information about all members of a community if you are not an administrator of that community. If you are a member, you will only see the number of administrators and the community creator.
However, you can get information about the members of groups that you are a member of as a community member.
Adding an existing WhatsApp group to a community
To connect an existing WhatsApp group to a community, you need to know the community ID as well as the ID of the group you want to connect.
- To get the group ID, use the method
GET https://gate.whapi.cloud/groups
- To add the selected group to the community, you will need the method
PUT https://gate.whapi.cloud/communities/{CommunityID}/{GroupID}
Removing a WhatsApp group from the community
Sometimes you may need to remove a group from the community. To do this, use the following method
DELETE https://gate.whapi.cloud/communities/{CommunityID}/{GroupID}
To get the identifier of the required group, use the endpoint we specified earlier in the previous paragraph.
Sending an announcement to a WhatsApp community
Of course, the main purpose of WhatsApp communities is to send announcements. Sending an announcement to a community is technically fully compliant and follows the rules for sending a message to a regular WhatsApp group. To send this message, use standard messaging methods.
Let's consider sending a simple text message as an example. We will need an endpoint as well as the group ID with the announcements parameter:
POST https://gate.whapi.cloud/messages/text
In the request it will look like this:
curl --request POST \
--url https://gate.whapi.cloud/messages/text \
--header 'accept: application/json' \
--header 'authorization: Bearer your_token' \
--header 'content-type: application/json' \
--data '
{
"to": "120363330016384615@g.us",
"body": "Hello, everybody!"
}
'
Where the to parameter should contain the group ID and the body parameter should contain the text of your message. If you need to send a media file or document, just use the appropriate methods:
to send an image you will need the method
POST https://gate.whapi.cloud/messages/image
to send a document, use this method
POST https://gate.whapi.cloud/messages/document
Summary
As you can see, WhatsApp communities are a convenient and effective tool to increase interaction with your users.
With our API, managing communities becomes even easier and faster, allowing you to easily organize and structure groups for effective communication.
At the same time, using our provider opens up new possibilities in messenger automation! For example, you can:
- Check for a number in WhatsApp;
- Get a list of all your chats;
- Create and send statuses;
- Manage WhatsApp channels.
and more.
We understand that you may have questions or need additional support. That's why our live support team is always available to help you at any stage of integration and utilization. Feel free to ask questions!
We invite you to test our API and see for yourself how easy and convenient it is to manage communities through Whapi.Cloud. Get started today and get the most out of WhatsApp's capabilities for your business!
Top comments (0)