Send Whatsapp Text Message
curl --request POST \
--url https://api.example.com/api/v1/campaign/whatsapp/message/send \
--header 'Content-Type: application/json' \
--data '
{
"to": "<string>",
"phoneId": "<string>",
"type": "<string>",
"text": {
"preview_url": true,
"body": "<string>"
},
"source": "<string>",
"linkWithRecord": true,
"reportURL": "<string>",
"submissionStatus": true
}
'import requests
url = "https://api.example.com/api/v1/campaign/whatsapp/message/send"
payload = {
"to": "<string>",
"phoneId": "<string>",
"type": "<string>",
"text": {
"preview_url": True,
"body": "<string>"
},
"source": "<string>",
"linkWithRecord": True,
"reportURL": "<string>",
"submissionStatus": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
to: '<string>',
phoneId: '<string>',
type: '<string>',
text: {preview_url: true, body: JSON.stringify('<string>')},
source: '<string>',
linkWithRecord: true,
reportURL: '<string>',
submissionStatus: true
})
};
fetch('https://api.example.com/api/v1/campaign/whatsapp/message/send', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/campaign/whatsapp/message/send",
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([
'to' => '<string>',
'phoneId' => '<string>',
'type' => '<string>',
'text' => [
'preview_url' => true,
'body' => '<string>'
],
'source' => '<string>',
'linkWithRecord' => true,
'reportURL' => '<string>',
'submissionStatus' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/campaign/whatsapp/message/send"
payload := strings.NewReader("{\n \"to\": \"<string>\",\n \"phoneId\": \"<string>\",\n \"type\": \"<string>\",\n \"text\": {\n \"preview_url\": true,\n \"body\": \"<string>\"\n },\n \"source\": \"<string>\",\n \"linkWithRecord\": true,\n \"reportURL\": \"<string>\",\n \"submissionStatus\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/campaign/whatsapp/message/send")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"<string>\",\n \"phoneId\": \"<string>\",\n \"type\": \"<string>\",\n \"text\": {\n \"preview_url\": true,\n \"body\": \"<string>\"\n },\n \"source\": \"<string>\",\n \"linkWithRecord\": true,\n \"reportURL\": \"<string>\",\n \"submissionStatus\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/campaign/whatsapp/message/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"<string>\",\n \"phoneId\": \"<string>\",\n \"type\": \"<string>\",\n \"text\": {\n \"preview_url\": true,\n \"body\": \"<string>\"\n },\n \"source\": \"<string>\",\n \"linkWithRecord\": true,\n \"reportURL\": \"<string>\",\n \"submissionStatus\": true\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"message": "Message sent successfully"
}
{
"status": false,
"message": "Invalid data Provided"
}
{
"status": false,
"message": "Unauthorised"
}
Free-Form / Direct Messages
Send Whatsapp Text Message
POST
/
api
/
v1
/
campaign
/
whatsapp
/
message
/
send
Send Whatsapp Text Message
curl --request POST \
--url https://api.example.com/api/v1/campaign/whatsapp/message/send \
--header 'Content-Type: application/json' \
--data '
{
"to": "<string>",
"phoneId": "<string>",
"type": "<string>",
"text": {
"preview_url": true,
"body": "<string>"
},
"source": "<string>",
"linkWithRecord": true,
"reportURL": "<string>",
"submissionStatus": true
}
'import requests
url = "https://api.example.com/api/v1/campaign/whatsapp/message/send"
payload = {
"to": "<string>",
"phoneId": "<string>",
"type": "<string>",
"text": {
"preview_url": True,
"body": "<string>"
},
"source": "<string>",
"linkWithRecord": True,
"reportURL": "<string>",
"submissionStatus": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
to: '<string>',
phoneId: '<string>',
type: '<string>',
text: {preview_url: true, body: JSON.stringify('<string>')},
source: '<string>',
linkWithRecord: true,
reportURL: '<string>',
submissionStatus: true
})
};
fetch('https://api.example.com/api/v1/campaign/whatsapp/message/send', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/campaign/whatsapp/message/send",
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([
'to' => '<string>',
'phoneId' => '<string>',
'type' => '<string>',
'text' => [
'preview_url' => true,
'body' => '<string>'
],
'source' => '<string>',
'linkWithRecord' => true,
'reportURL' => '<string>',
'submissionStatus' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/campaign/whatsapp/message/send"
payload := strings.NewReader("{\n \"to\": \"<string>\",\n \"phoneId\": \"<string>\",\n \"type\": \"<string>\",\n \"text\": {\n \"preview_url\": true,\n \"body\": \"<string>\"\n },\n \"source\": \"<string>\",\n \"linkWithRecord\": true,\n \"reportURL\": \"<string>\",\n \"submissionStatus\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/campaign/whatsapp/message/send")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"<string>\",\n \"phoneId\": \"<string>\",\n \"type\": \"<string>\",\n \"text\": {\n \"preview_url\": true,\n \"body\": \"<string>\"\n },\n \"source\": \"<string>\",\n \"linkWithRecord\": true,\n \"reportURL\": \"<string>\",\n \"submissionStatus\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/campaign/whatsapp/message/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"<string>\",\n \"phoneId\": \"<string>\",\n \"type\": \"<string>\",\n \"text\": {\n \"preview_url\": true,\n \"body\": \"<string>\"\n },\n \"source\": \"<string>\",\n \"linkWithRecord\": true,\n \"reportURL\": \"<string>\",\n \"submissionStatus\": true\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"message": "Message sent successfully"
}
{
"status": false,
"message": "Invalid data Provided"
}
{
"status": false,
"message": "Unauthorised"
}
You can send messages only if the user session is already active; otherwise, the messages will fail. We recommend sending a approved template message the first time you contact users. Once the session is open, you can send unlimited messages via these APIs. For more info click here
Body
string
required
Specifies the recipient’s phone number in international format (e.g.,
“1xxxxxxxxxx”).
string
required
This is the unique identifier associated with the sender’s phone number given
by WhatsApp. Find the Phone ID on the Zixflow WhatsApp Settings page next to
the number. Whatsapp
Settings
string
default:"text"
required
To send text messages keep message type as “text”
object
required
A Text Object consists of the following fields and formatting options:
Hide text
Hide text
boolean
required
Optional.By default, WhatsApp recognizes URLs and makes them clickable, but you can also include a preview box with more information about the link. Set this field to true if you want to include a URL preview box.The majority of the time when you send a URL, whether with a preview or not, the receiver of the message will see a URL that they can click on.URL previews are only rendered after one of the following has occurred:The business has sent a message template to the user.The user initiates a conversation with a “click to chat” link.The user adds the business phone number to their address book and initiates a conversation.Default: false
string
required
Required for text messages.The text of the text message that can contain URLs and supports formatting. To view available formatting options, see Text Object Formatting Options.If you include URLs in your text and want to include a preview box in text messages (“preview_url”: true), ensure it starts with http:// or https://. You must include a hostname, since IP addresses are not matched.Maximum length: 4096 characters.
string
default:"API"
If the “linkWithRecord” is set to true, the source from which the WhatsApp
message is sent should be mentioned; otherwise, it defaults to API.
boolean
Specify whether to associate the current message with a record and display it
in the inbox. Set it to “true” for linking with a record; otherwise, it
defaults to “false.”
string
(Optional) Specify the URL where the user’s report and deliveries should be
delivered.
boolean
Indicates whether to wait for the submission status. Set it to “true” if you
want to wait for the submission status; otherwise, it defaults to “false.”
Response
boolean
Indicates whether the call was successful. true if successful, false if not.
string
success or error response message
{
"status": true,
"message": "Message sent successfully"
}
{
"status": false,
"message": "Invalid data Provided"
}
{
"status": false,
"message": "Unauthorised"
}
⌘I