Automate WhatsApp Channel Messages Using PHP

March 11, 2025

WhatsApp channels are essential for businesses looking to connect with their teams, customers, or communities. However, manually managing them can be time-consuming. What if you could automate the creation and messaging of WhatsApp channels? With Wassenger and PHP, it’s easy 🤖

🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!

In this guide, we’ll show you how to:

✅ Create a WhatsApp Channel  ✅ Send Messages to a WhatsApp Channel  ✅ Automate Channel Messaging for Updates and Announcements

Why Automate WhatsApp Channel Messaging? 🤔

Manually managing and messaging WhatsApp channels can be a hassle. Automating the process allows you to:

Save Time — No more sending individual messages to multiple channels.

Boost Engagement — Keep your teams or customers updated in real-time.

Improve Consistency — Ensure messages are sent at the right time without missing updates.

Scale Communication — Reach more people effortlessly with automated messaging.

📢 Want to get started? Sign up for Wassenger now! 🚀

Requirements

  • Having a WhatsApp number already linked to the platform and online.
  • Channel ID (WID) which can be found in two ways:
  1. On your WhatsApp number’s management panel, go to “channels”. From there you will see the channels your number has access to.
  2. Using the API, query the available channel in your device for this endpoint.

Prepare the request

Target API URL using the POST method to create a channel

http://api.wassenger.com/v1/devices/{deviceId}/channels

Target API URL using the POST method to send messages to a channel

https://api.wassenger.com/v1/messages

Required HTTPS headers > Obtain your API key here

Content-Type: application/json
Token: $API_TOKEN

🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!

Are you a developer?

Explore how to use the code in your browser without installing any software.

Also, you can find different languages you can test on Replit.com:

1. How to Create a WhatsApp Channel Using PHP

Creating a WhatsApp Channel through Wassenger API is easy. Here’s how to do it in PHP:

Create a Channel with PHP (Guzzle)

// This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP. // Install it first following these instructions: // https://docs.guzzlephp.org/en/stable/overview.html#installation

request('POST', 'https://api.wassenger.com/v1/devices/%7B%7Bdevice.id%7D%7D/channels', \[ 'body' => '{"name":"Channel name","description":"This is a channel sample description, up to 2048 characters allowed","image":{"url":"https://picsum.photos/600"}}', 'headers' => \[ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE', \], \]); echo $response\->getBody(); **Create a Channel with PHP (http2)** // This code example requires to have installed pecl\_http package, a simple and elegant HTTP client for PHP. // Install it by running: pecl install pecl\_http // More information: https://mdref.m6w6.name/http append(json\_encode(\[ 'name' => 'Channel name', 'description' => 'This is a channel sample description, up to 2048 characters allowed', 'image' => \[ 'url' => 'https://picsum.photos/600' \] \])); $request\->setRequestUrl('https://api.wassenger.com/v1/devices/%7B%7Bdevice.id%7D%7D/channels'); $request\->setRequestMethod('POST'); $request\->setBody($body); $request\->setHeaders(\[ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE' \]); $client\->enqueue($request)->send(); $response = $client\->getResponse(); echo $response\->getBody(); **Create a Channel with PHP (curl)** ```php 'https://api.wassenger.com/v1/devices/{{device.id}}/channels', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode([ 'name' => 'Channel name', 'description' => 'This is a channel sample description, up to 2048 characters allowed', 'image' => [ 'url' => 'https://picsum.photos/600', ], ]), CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Token: ENTER API KEY HERE', ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo 'cURL Error #:' . $err; } else { echo $response; } ``` ✅ **This creates a new WhatsApp channel** named “Channel name”. > *🤩 🤖* [***Wassenger***](https://wassenger.com/) *is a complete communication platform and API solution for WhatsApp.* [***Explore more than 100+ API use cases and automate anything on WhatsApp***](https://wassenger.com/) *by signing up* [*for a free trial and getting started in minutes****!***](https://wassenger.com/register) ### 2\. How to Send Messages to a WhatsApp Channel Using PHP Once the channel is created, you can send messages to it using the channel’s unique ID: **Send Text Message with PHP (Guzzle)** ```php // This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP. // Install it first following these instructions: // https://docs.guzzlephp.org/en/stable/overview.html#installation request('POST', 'https://api.wassenger.com/v1/messages', [ 'body' => '{"channel":"{{channel}}", "message":"This is a sample message sent to a channel"}', 'headers' => [ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE', ], ]); echo $response->getBody(); ``` **Send Text Message with PHP (http2)** ```php // This code example requires to have installed pecl_http package, a simple and elegant HTTP client for PHP. // Install it by running: pecl install pecl_http // More information: https://mdref.m6w6.name/http append( json_encode([ 'channel' => '{{channel}}', 'message' => 'This is a sample message sent to a channel', ]) ); $request->setRequestUrl('https://api.wassenger.com/v1/messages'); $request->setRequestMethod('POST'); $request->setBody($body); $request->setHeaders([ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE', ]); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` **Send Text Message with PHP (curl)** ```php 'https://api.wassenger.com/v1/messages', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode([ 'channel' => '{{channel}}', 'message' => 'This is a sample message sent to a channel', ]), CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Token: ENTER API KEY HERE', ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo 'cURL Error #:' . $err; } else { echo $response; } ``` You can also add media to your messages: **Send Media Messages with PHP (Guzzle)** ```php // This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP. // Install it first following these instructions: // https://docs.guzzlephp.org/en/stable/overview.html#installation request('POST', 'https://api.wassenger.com/v1/messages', [ 'body' => '{"channel":"channel_id@newsletter", "message":"This is a caption for an image message", "media":{"url":"https://picsum.photos/seed/picsum/600/400", "viewOnce":false}}', 'headers' => [ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE', ], ]); echo $response->getBody(); ``` **Send Media Messages with PHP (http2)** ```php // This code example requires to have installed pecl_http package, a simple and elegant HTTP client for PHP. // Install it by running: pecl install pecl_http // More information: https://mdref.m6w6.name/http append( json_encode([ 'channel' => 'channel_id@newsletter', 'message' => 'This is a caption for an image message', 'media' => [ 'url' => 'https://picsum.photos/seed/picsum/600/400', 'viewOnce' => null, ], ]) ); $request->setRequestUrl('https://api.wassenger.com/v1/messages'); $request->setRequestMethod('POST'); $request->setBody($body); $request->setHeaders([ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE', ]); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` **Send Media Messages with PHP (curl)** ```php 'https://api.wassenger.com/v1/messages', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode([ 'channel' => 'channel_id@newsletter', 'message' => 'This is a caption for an image message', 'media' => [ 'url' => 'https://picsum.photos/seed/picsum/600/400', 'viewOnce' => null, ], ]), CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Token: ENTER API KEY HERE', ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo 'cURL Error #:' . $err; } else { echo $response; } ``` ✅ **This sends a message to the specified WhatsApp channel automatically.** > ***Was this helpful****? Find more examples in our* [***API Live Tester***](https://app.wassenger.com/help/api-tester) *🤖* ### 3\. How to Schedule Messages in a WhatsApp Channel Using PHP Scheduling messages allows you to send updates at the perfect time: **Schedule Message with PHP (Guzzle)** ```php // This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP. // Install it first following these instructions: // https://docs.guzzlephp.org/en/stable/overview.html#installation request('POST', 'https://api.wassenger.com/v1/messages', [ 'body' => '{"channel":"channel_id@newsletter", "message":"This is a scheduled message to be sent tomorrow to a channel.Date format is based on ISO 8601 format with default UTC time zone", "deliverAt":"2025-03-07T10:23:53.810Z"}', 'headers' => [ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE', ], ]); echo $response->getBody(); ``` **Schedule Message with PHP (http2)** ```php // This code example requires to have installed pecl_http package, a simple and elegant HTTP client for PHP. // Install it by running: pecl install pecl_http // More information: https://mdref.m6w6.name/http append( json_encode([ 'channel' => 'channel_id@newsletter', 'message' => 'This is a scheduled message to be sent tomorrow to a channel.Date format is based on ISO 8601 format with default UTC time zone', 'deliverAt' => '2025-03-07T10:23:53.810Z', ]) ); $request->setRequestUrl('https://api.wassenger.com/v1/messages'); $request->setRequestMethod('POST'); $request->setBody($body); $request->setHeaders([ 'Content-Type' => 'application/json', 'Token' => 'ENTER API KEY HERE', ]); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` **Schedule Message with PHP (curl)** ```php 'https://api.wassenger.com/v1/messages', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode([ 'channel' => 'channel_id@newsletter', 'message' => 'This is a scheduled message to be sent tomorrow to a channel.Date format is based on ISO 8601 format with default UTC time zone', 'deliverAt' => '2025-03-07T10:23:53.810Z', ]), CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Token: ENTER API KEY HERE', ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo 'cURL Error #:' . $err; } else { echo $response; } ``` ✅ **This schedules a message to be sent at a later time automatically.** > ***Was this helpful****? Find more examples in our* [***API Live Tester***](https://app.wassenger.com/help/api-tester) *🤖* ![](/images/blog/automate-whatsapp-channel-messages-using-ph-02.png) [Try our API-Live tester now](https://app.wassenger.com/help/api-tester)! ### Frequently Asked Questions (FAQ) 🤔 #### 1\. Can I use Wassenger API to remove users from a WhatsApp channel? This guide focuses on messaging, but Wassenger API provides channel management options, including adding or removing users. 📢 **Need more help?** Visit the [Wassenger Help Center](https://app.wassenger.com/help) for detailed documentation and support! #### 2\. Can I send images, videos, or documents to WhatsApp Channels using Wassenger API? Absolutely! Wassenger API allows you to send multimedia content such as images, videos, PDFs, and more to your WhatsApp channels. #### 3\. How can I check if my message was successfully delivered to a WhatsApp channel? You can use the Wassenger API to retrieve message status updates, ensuring your messages are delivered and read. #### 4\. Can I mention specific users in a WhatsApp channel message? Yes! You can mention specific participants by including their phone numbers in the message payload. > *📌* ***Ready to automate your WhatsApp messaging?*** [*Start your free trial today!*](https://app.wassenger.com/register) *🚀* With [**Wassenger**](https://wassenger.com) **and PHP**, you can create, send, and schedule messages to WhatsApp channels effortlessly, making communication smoother and more efficient.

Ready to transform your WhatsApp communication?

Start automating your customer interactions today with Wassenger

Get Started Free