How To Schedule Messages On WhatsApp Groups

January 24, 2025

In this tutorial, you will learn how to schedule the delivery of messages to groups using the API

There are two ways to schedule the delivery of a message to a later time and/or day: by specifying the exact day and time you want it to be sent or by indicating how many minutes, hours or days you’d like to delay the deferred delivery.

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

If you want to send messages from code, you can use any programming language to perform HTTPS API requests. Below is the live API tester with ready-to-use code examples in various programming languages.

Requirements

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

Prepare the request

Target API URL using the POST method

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

Required HTTPS headers > Obtain your API key here

Content-Type: application/json
Token: $API_TOKEN

Use body in JSON format

{ "group": "${@g.us">group_id}@g.us", "message": "This is a scheduled message to be sent tomorrow to a group chat. Date format is based on ISO 8601 format with default UTC time zone", "deliverAt": "2025-01-24T21:18:31.271Z" }

Congrats! You can now send automatic messages using the API to groups on WhatsApp.

🤩 🤖 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:

# Examples requires to have installed requests Python package. # Install it by running: pip install requests

import requests

url = "https://api.wassenger.com/v1/messages"

payload = { "group": "${@g.us">group_id}@g.us", "message": "This is a scheduled message to be sent tomorrow to a group chat. Date format is based on ISO 8601 format with default UTC time zone", "deliverAt": "2025-01-24T21:18:31.271Z" } headers = { "Content-Type": "application/json", "Token": "API TOKEN GOES HERE" }

response = requests.post(url, json=payload, headers=headers)

print(response.json())

<?php
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => '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([
    'group' => '${@g.us">group_id}@g.us',
    'message' =>
      'This is a scheduled message to be sent tomorrow to a group chat.Date format is based on ISO 8601 format with default UTC time zone',
    'deliverAt' => '2025-01-24T21:18:31.271Z',
  ]),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json',
    'Token: API TOKEN GOES HERE',
  ],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
// 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
<?php
$client = new http\Client();
$request = new http\Client\Request();
$body = new http\Message\Body();
$body->append(
  json_encode([
    'group' => '${@g.us">group_id}@g.us',
    'message' =>
      'This is a scheduled message to be sent tomorrow to a group chat.Date format is based on ISO 8601 format with default UTC time zone',
    'deliverAt' => '2025-01-24T21:18:31.271Z',
  ])
);
$request->setRequestUrl('https://api.wassenger.com/v1/messages');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
  'Content-Type' => 'application/json',
  'Token' => 'API TOKEN GOES HERE',
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
// 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
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.wassenger.com/v1/messages', [
  'body' =>
    '{"group":"${@g.us">group_id}@g.us", "message":"This is a scheduled message to be sent tomorrow to a group chat.Date format is based on ISO 8601 format with default UTC time zone", "deliverAt":"2025-01-24T21:18:31.271Z"}',
  'headers' => [
    'Content-Type' => 'application/json',
    'Token' => 'API TOKEN GOES HERE',
  ],
]);
echo $response->getBody();

// This code requires you to have installed RestSharp package. // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "API TOKEN GOES HERE"); request.AddParameter("application/json", "{\"group\":\"${@g.us">group_id}@g.us\",\"message\":\"This is a scheduled message to be sent tomorrow to a group chat. Date format is based on ISO 8601 format with default UTC time zone\",\"deliverAt\":\"2025-01-24T21:18:31.271Z\"}", ParameterType.RequestBody); IRestResponse response = client.Execute(request);

// This code uses the built-in HttpClient package in the .NET framework. // Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0

using System.Net.Http.Headers; var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri("https://api.wassenger.com/v1/messages"), Headers = { { "Token", "API TOKEN GOES HERE" }, }, Content = new StringContent("{\"group\":\"${@g.us">group_id}@g.us\",\"message\":\"This is a scheduled message to be sent tomorrow to a group chat. Date format is based on ISO 8601 format with default UTC time zone\",\"deliverAt\":\"2025-01-24T21:18:31.271Z\"}") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } } }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); }

// This code requires you to have installed Unirest package.
// Documentation: https://kong.github.io/unirest-java/#requests
// Installation: http://kong.github.io/unirest-java/
HttpResponse<String> response = Unirest.post("https://api.wassenger.com/v1/messages")
.header("Content-Type", "application/json")
.header("Token", "API TOKEN GOES HERE")
.body("{\"group\":\"${@g.us">group_id}@g.us\", \"message\":\"This is a scheduled message to be sent tomorrow to a group chat.Date format is based on ISO 8601 format with default UTC time zone\", \"deliverAt\":\"2025-01-24T21:18:31.271Z\"}")
.asString();
$headers=@{}
$headers.Add("Content-Type", "application/json")
$headers.Add("Token", "API TOKEN GOES HERE")
$response = Invoke-WebRequest -Uri 'https://api.wassenger.com/v1/messages' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"group":"${@g.us">group_id}@g.us", "message":"This is a scheduled message to be sent tomorrow to a group chat.Date format is based on ISO 8601 format with default UTC time zone", "deliverAt":"2025-01-24T21:18:31.271Z"}'
require 'uri'
require 'net/http'
url = URI("https://api.wassenger.com/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Token"] = 'API TOKEN GOES HERE'
request.body = "{\"group\":\"${@g.us">group_id}@g.us\", \"message\":\"This is a scheduled message to be sent tomorrow to a group chat.Date format is based on ISO 8601 format with default UTC time zone\", \"deliverAt\":\"2025-01-24T21:18:31.271Z\"}"
response = http.request(request)
puts response.read_body
package main
import(
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url:= "https://api.wassenger.com/v1/messages"
payload:= strings.NewReader("{\"group\":\"${@g.us">group_id}@g.us\", \"message\":\"This is a scheduled message to be sent tomorrow to a group chat.Date format is based on ISO 8601 format with default UTC time zone\", \"deliverAt\":\"2025-01-24T21:18:31.271Z\"}")
req, _:= http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Token", "API TOKEN GOES HERE")
res, _:= http.DefaultClient.Do(req)
defer res.Body.Close()
body, _:= io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}

🤩 🤖 Wassenger is a complete communication platform and API solution for WhatsApp. Explore more than 100+ API use cases and automate anything on WhatsApp by signing up for a free trial and getting started in minutes!

Live testing to send a message to a group via API

Explore our API live tester

FAQs

How to send messages to multiple groups

You just have to send multiple API requests, one per target group.

For instance, if you want to send a message to 10 groups, you should send 10 independent HTTPS requests to the API.

There is no option to send multiple messages in a single API request.

What type of messages can be sent?

You can send different types of messages, including text, images, videos, emojis, audio, gifs, geographic locations and file documents via API.

Check out other tutorials for more information.

Further useful resources

API Documentation

For more details about the endpoint API, please check our documentation. You will find all the details about the accepted request parameters, possible success or error responses, and ready-to-use code examples in multiple programming languages.

https://app.wassenger.com/docs/#tag/Messages

Ready to transform your WhatsApp communication?

Start automating your customer interactions today with Wassenger

Get Started Free