Help Desk
Search
⌃K
Comment on page

How to Send a Group Message

How to create a WhatsApp group or send messages to the group
To send a message to a group you need to know the group ID.
You can get the group ID in several ways:
The group ID looks like this: [email protected]. This information cannot be seen in the application or Web version!
Once you know the group ID, you can use the method to send any message. For example, a text message
In the “to” parameter you insert the ID of the group you want to send the message to. And in the “body”, the text of the message
​

How to create a group via API

  1. 1.
    Now that your group is up and running, it's time to acquire its unique identifier. Make a quick call to /getgroup and you'll have what you need.
  2. 2.
    With the identifier in your grasp, you're all set to spread the word! Use POST /sendmessagetext to shower your group with your initial messages.

Example usage for WhatsApp API using PHP

Send your first WhatsApp message in group.
For a detailed breakdown of the messaging method, including a comprehensive description of all parameters, additional examples, and options for testing, please visit our Developer Hub at:
const BASE_URL = 'https://gate.whapi.cloud/';
$token = 'bg3FeZJ6jWGw32goN02PRnkKO7k03GtX'; // Specify your channel token here
$data = array (
'to' => '[email protected]',
'body' => 'Hello, world!',
'typing_time' => 0,
'view_once' => true,
);
$data = json_encode($data);
$url = BASE_URL . 'messages/text';
$options = array('http' => array(
'method' => 'POST',
'header' => 'Authorization: Bearer '.$token,
'content' => json_encode($data)
));
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
  • 'to': The recipient’s WhatsApp number with international format e.g., 14409416972 or chatID for contact or group e.g [email protected] or [email protected]
  • 'body' : Message text.
​
We offer a convenient service for testing requests and using ready-made code fragments in any programming language. You will only need to transfer the saved API-token and fill in the required parameters:
Paste your API token and parameters, then copy code snippet
Save the PHP script and run it on your server. The specified message will be sent to the specified WhatsApp number. Remember to replace variables with your actual details.
Please note that this is a basic example and doesn't include any error handling. For a production environment, ensure to add appropriate error and exception handling.
Enjoy communicating with your users on a platform they love and use daily! Please don't hesitate to reach out to share your experiences or pose any questions you might have.
​Get Started Free​