Send Message API
End Point: https://wbiztool.com/api/v1/send_msg/
Request Type: POST
Required Fields in Request
phone
parameter for individual messages or the group_name
parameter for group messages, but not both in the same request.
-
client_id (Integer)
- Your Client Id (Given on API Keys page -
api_key (String)
- Your Api Key (Given on API Keys page -
whatsapp_client (Integer)
- Your WhatsApp Client Id (Given on Whatsapp Setting Page) Click here -
msg_type (Integer)
- 0 for Text msg, 1 for Image with msg, 2 for File with msg -
img_url (String, Optional)
- Image Url (Mandotary when msg_type is 1) and url should be ending with valid image extension (.png, .jpg, .jpeg etc) -
file_url (String, Optional)
- File Url from which file can be directly downloaded (Mandotary when msg_type is 2 and file is not uploaded) -
file_name (String, Optional)
- File Name (Mandotary when msg_type is 2) -
file (FILE, Optional)
- File(Mandotary when msg_type is 2 and file_url is not provided) -
phone (String)
- Receiver's Whatsapp Number with country code. eg: 919632066772. Use either phone OR group_name, not both. -
group_name (String)
- WhatsApp group name for group messages (e.g., "My Group"). Use either phone OR group_name, not both. -
country_code (string)
- Receiver's country code. eg: 91 for india, 1 for USA. Only applies to phone messages. -
msg (String)
- Message Text -
expire_after_seconds (Integer, Optional)
- Expire message if not sent before given seconds -
webhook (String, Optional)
- Webhook Url where msg_id and status will be posted
Fields in Response
-
msg_id (Integer)
- If successfully submitted your message then msg id. You can save this id to check the status of particular message. You can save it for future reference. -
message (String)
- Readable status of your request -
status (Integer)
- 0/1 if status is 0 then there is some error with this request explanation will be given in message key
Example
The following example uses curl to make an API request. Note the use of the api key, client id, whatsapp client id and the setting of the Content-Type header.
Example for Phone Number Message:
curl -X POST https://wbiztool.com/api/v1/send_msg/ -d '{
"client_id": "client_id",
"api_key": "api_key",
"whatsapp_client": whatsapp_client_id,
"msg_type": 0,
"msg": "Hi, This is a *test* msg from _WbizTool.com_",
"phone":"9632066772",
"country_code":"91"
}'
// Response
{"status": 1, "message": "Created", "msg_id": <unique_msg_id}
Example for Group Message:
curl -X POST https://wbiztool.com/api/v1/send_msg/ -d '{
"client_id": "client_id",
"api_key": "api_key",
"whatsapp_client": whatsapp_client_id,
"msg_type": 0,
"msg": "Hi, This is a *test* msg from _WbizTool.com_",
"group_name":"My WhatsApp Group"
}'
// Response
{"status": 1, "message": "Created", "msg_id": <unique_msg_id}
Integrate Whatsapp Send Message API with Python
Install it with:
pip install wbiztool-client
Normal Text Msg to Phone Number
import requests
data={
"client_id" : "client_id",
"api_key" : "api_key",
"whatsapp_client" : whatsapp_client_id,
"msg_type": 0,
"msg" : "Hi, This is a *test* msg from _WbizTool.com_",
"phone" : "9632066772",
"country_code":"91"
}
url = 'https://wbiztool.com/api/v1/send_msg/'
response = requests.post(url,data=data).text
Normal Text Msg to WhatsApp Group
import requests
data={
"client_id" : "client_id",
"api_key" : "api_key",
"whatsapp_client" : whatsapp_client_id,
"msg_type": 0,
"msg" : "Hi, This is a *test* msg from _WbizTool.com_",
"group_name" : "My WhatsApp Group"
}
url = 'https://wbiztool.com/api/v1/send_msg/'
response = requests.post(url,data=data).text
Image Text Msg with Image url
import requests
data={
"client_id" : "client_id",
"api_key" : "api_key",
"whatsapp_client" : whatsapp_client_id,
"msg_type": 1,
"img_url":"img_url",
"msg" : "Hi, This is a *test* msg from _WbizTool.com_",
"phone" : "9632066772",
"country_code":"91"
}
url = 'https://wbiztool.com/api/v1/send_msg/'
response = requests.post(url,data=data).text
Image Text Msg with Image File
import requests
data={
"client_id" : "client_id",
"api_key" : "api_key",
"whatsapp_client" : whatsapp_client_id,
"msg_type": 1,
"msg" : "Hi, This is a *test* msg from _WbizTool.com_",
"phone" : "9632066772",
"country_code":"91"
}
url = 'https://wbiztool.com/api/v1/send_msg/'
files = {'file': open('path/to/image/file', 'rb')}
response = requests.post(url,data=data,files=files).text
File Text Msg with File url
import requests
data={
"client_id" : "client_id",
"api_key" : "api_key",
"whatsapp_client" : whatsapp_client_id,
"msg_type": 2,
"file_url":"file_url",
"msg" : "Hi, This is a *test* msg from _WbizTool.com_",
"phone" : "9632066772",
"country_code":"91"
}
url = 'https://wbiztool.com/api/v1/send_msg/'
response = requests.post(url,data=data).text
File Text Msg with File
import requests
data={
"client_id" : "client_id",
"api_key" : "api_key",
"whatsapp_client" : whatsapp_client_id,
"msg_type": 2,
"msg" : "Hi, This is a *test* msg from _WbizTool.com_",
"phone" : "9632066772"
"country_code":"91"
}
url = 'https://wbiztool.com/api/v1/send_msg/'
files = {'file': open('path/to/file', 'rb')}
response = requests.post(url,data=data,files=files).text
Integrate Whatsapp Send Message API with PHP
Normal Text Msg
$url = 'https://wbiztool.com/api/v1/send_msg/';
$myvars = 'client_id=client_id&api_key=api_key&whatsapp_client=whatsapp_client_id&msg_type=0&phone=9632066772&country_code=91&msg=Test';
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
$response = curl_exec( $ch );
echo $response;
Image Text Msg With Image Url
$url = 'https://wbiztool.com/api/v1/send_msg/';
$myvars = 'client_id=client_id&api_key=api_key&whatsapp_client=whatsapp_client_id&phone=9632066772&country_code=91&msg=Test&msg_type=1&img_url=<img_url';
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
$response = curl_exec( $ch );
echo $response;
Image Text Msg With Image File
$url = 'https://wbiztool.com/api/v1/send_msg/';
$data = array(
'client_id' => 'client_id',
'api_key' => 'api_key',
'whatsapp_client' => 'whatsapp_client_id',
'phone' => '9632066772',
'country_code' => '91',
'msg' => 'Test',
'msg_type' => '1'
);
// Open the file for reading
$filePath = '/my/folder/invoice.png';
$file = fopen($filePath, 'rb');
// Create a CURLFile object
if (function_exists('curl_file_create')) { // For PHP 5.5 and later
$data['file'] = curl_file_create($filePath, 'application/pdf', 'invoice.pdf');
} else { // For PHP 5.4 and earlier
$data['file'] = '@' . realpath($filePath);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Optional: Disable SSL verification if necessary (not recommended for production)
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
echo 'Error: ' . $error_msg;
} else {
echo 'Response: ' . $response;
}
curl_close($ch);
// Close the file
fclose($file);
File Text Msg With File Url
$url = 'https://wbiztool.com/api/v1/send_msg/';
$myvars = 'client_id=client_id&api_key=api_key&whatsapp_client=whatsapp_client_id&phone=9632066772&country_code=91&msg=Test&msg_type=2&file_url=<file_url';
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
$response = curl_exec( $ch );
echo $response;
File Text Msg With File
$url = 'https://wbiztool.com/api/v1/send_msg/';
$data = array(
'client_id' => 'client_id',
'api_key' => 'api_key',
'whatsapp_client' => 'whatsapp_client_id',
'phone' => '9632066772',
'country_code' => '91',
'msg' => 'Test',
'msg_type' => '1',
'file_name' => 'invoice_123.pdf'
);
// Open the file for reading
$filePath = '/my/folder/invoice.pdf';
$file = fopen($filePath, 'rb');
// Create a CURLFile object
if (function_exists('curl_file_create')) { // For PHP 5.5 and later
$data['file'] = curl_file_create($filePath, 'application/pdf', 'invoice.pdf');
} else { // For PHP 5.4 and earlier
$data['file'] = '@' . realpath($filePath);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Optional: Disable SSL verification if necessary (not recommended for production)
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
echo 'Error: ' . $error_msg;
} else {
echo 'Response: ' . $response;
}
curl_close($ch);
// Close the file
fclose($file);
Integrate Whatsapp Send Message API with Ruby
require 'net/http'
params = {
client_id: "client_id",
api_key: "api_key",
whatsapp_client: "whatsapp_client_id",
msg_type: 0,
msg: "Hi, This is a *test* msg from _WbizTool.com_",
phone: "919632066772",
country_code:"91",
}
url = 'https://wbiztool.com/api/v1/send_msg/'
uri = URI(url)
res = Net::HTTP.post_form(uri, params)
JSON.parse(res.body)
Integrate Whatsapp Send Message API with Nodejs
var request = require('request');
var headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
var dataString = {
"client_id": client_id,
"api_key": "api_key",
"whatsapp_client": whatsapp_client_id,
"msg_type": 0,
"msg": "Hi, This is a *test* msg from _WbizTool.com_",
"phone":"9632066772",
"country_code":"91"
};
var options = {
url: 'https://wbiztool.com/api/v1/send_msg/',
method: 'POST',
headers: headers,
body: JSON.stringify(dataString)
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
request(options, callback);
Integrate Whatsapp Send Message API with Java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws IOException {
URL url = new URL("https://wbiztool.com/api/v1/send_msg/");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpConn.setDoOutput(true);
JSONObject obj = new JSONObject();
obj.put("client_id","client_id");
obj.put("api_key","api_key");
obj.put("whatsapp_client",whatsapp_client_id);
obj.put("msg_type",0);
obj.put("msg","Hi, This is a *test* msg from _WbizTool.com_");
obj.put("phone","9632066772");
obj.put("country_code","91");
OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
writer.write(obj.toString(););
writer.flush();
writer.close();
httpConn.getOutputStream().close();
InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
System.out.println(response);
}
}
Integrate Whatsapp Send Message API with GO
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
)
func main() {
client := &http.Client{}
var data = strings.NewReader(`{
"client_id": "client_id",
"api_key": "api_key",
"whatsapp_client": whatsapp_client_id,
"msg_type": 0,
"msg": "Hi, This is a *test* msg from _WbizTool.com_",
"phone":"9632066772",
"country_code":"91"
}`)
req, err := http.NewRequest("POST", "https://wbiztool.com/api/v1/send_msg/", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
<ul class="nav nav-pills bg-nav-pills nav-justified mb-3"
<li class="nav-item"
<a href="#home1" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0"
<i class="mdi mdi-home-variant d-md-none d-block"</i
<span class="d-none d-md-block"Home</span
</a
</li
<li class="nav-item"
<a href="#profile1" data-toggle="tab" aria-expanded="true" class="nav-link rounded-0 active"
<i class="mdi mdi-account-circle d-md-none d-block"</i
<span class="d-none d-md-block"Profile</span
</a
</li
<li class="nav-item"
<a href="#settings1" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0"
<i class="mdi mdi-settings-outline d-md-none d-block"</i
<span class="d-none d-md-block"Settings</span
</a
</li
</ul
<div class="tab-content"
<div class="tab-pane" id="home1"
<p...</p
</div
<div class="tab-pane show active" id="profile1"
<p...</p
</div
<div class="tab-pane" id="settings1"
<p...</p
</div
</div