Skip to content

Send templated Whatsapp Messages

Template messages allow you to send marketing, utility, and authentication templates to WhatsApp users. Unlike all other message types, template messages do not require a 24-hour customer service window to be open between you and the message recipient before the message can be sent.

Note: Before going further, please read about whatsapp message templates

Endpoint

POST
/whatsapp/v2/send


POSTMAN

Authentication

AUTHORIZATION: Bearer Token

Body

Object

      {
          "messages": [
              {
                  "originator": "{registered phone_number}",
                  "content": {
                      "message_type":  "TEMPLATE",
                      "template": <template>

                  },
                  "recipients": [<recipient>],
                  "report_url": "{report url}"
              }
          ]
      }
{
  "messages": [
    {
                  "originator": "{registered phone_number}",
                  "content": {
                      "message_type":  "TEMPLATE",
                      "template": <template>

                  },
                  "recipients": [<recipient>],
                  "report_url": "{report url}"
              },
    {
                  "originator": "{registered phone_number}",
                  "content": {
                      "message_type":  "TEMPLATE",
                      "template": <template>

                  },
                  "recipients": [<recipient>],
                  "report_url": "{report url}"
              }
  ]
}
{
  "messages": [
    {
                  "originator": "{registered phone_number}",
                  "content": {
                      "message_type":  "TEMPLATE",
                      "template": <template>

                  },
                  "recipients": [<recipient>],
                  "report_url": "{report url}"
              }
  ],
  "message_globals": {  // Global message parameters for all message objects
    "schedule_time": "2021-08-05T12:52+05:30",
  }
}

Body parameters

Parameter Type Description Example
* originator String The Phone number of Sender/Header of a message. We can use your mobile number that is registered and approved in meta. +97156xxxxxxx
* recipients Array(Object) Array of recipient object See examples
*message_type String For templated messages. type is "TEMPLATE" See examples
*template Template Object A template object
report_url HttpUrl To receive delivery status (DLR) for your message, specify the callback server URL where you want to receive the message status updates using the report_url parameter. When the delivery status changes, the status updates will be sent to the specified URL. See more https://url_for_report.com
schedule_time String Schedule request to send at specific time .format: YYYY-MM-DDTHH:MM+HH:MM, must be specified inside message_globals object

Message Objects

    "recipients": [
            {
                "recipient": "{{recipient1}}",
                "recipient_type": "individual",
                "reference": {
                    "cust_ref": "[email protected]",
                    "message_tag1": "d7id00001_m1",
                    "conversation_id": "d7id00001"
                }
            },
            {
                "recipient": "{{recipient2}}",
                "recipient_type": "individual",
                "reference": {
                    "cust_ref": "[email protected]",
                    "message_tag1": "d7id00001_m1",
                    "conversation_id": "d7id00001"
                }
            }
        ],
Parameter Type Description Value / Pattern
*recipient Array(string) Mobile Numbers to send Whatsapp seperated by comma in an array. The recipient's phone number should have a country code prefix. +97156xxxxxxx
*recipient_type String Default: individual. Now Support Only individual recipients individual
cust_ref string Any text to store reference of recipient [email protected]
message_tag1 string Any text tag for message reference tag1
message_tag2 string Any text tag for message reference tag2
message_tag3 string Any text tag for message reference tag3
message_tag4 string Any text tag for message reference tag4
message_tag5 string Any text tag for message reference tag5
conversation_id string Any text for conversation reference conversation_marketing
Parameter Type Description
*template_id String Template ID configured for WhatsApp template (HSM). This should be registered and approved by D7. You can create a new Whatsapp Template here
*language String Specifies the code of language the template may be rendered in. Supported languages
body_parameter_values Dict The Object of the body parameter values. Only required if your body text have variables.
media Object Includes the parameters of template header
buttons Object Details of the button object.
carousel Object Carousel template object
limited_time_offer Object LTO Template Object
    "media": {
                "media_type": "image",
                "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
    "media": {
            "media_type": "document",
            "media_url": "http://www.africau.edu/images/default/sample.pdf"
        },
    "media": {
            "media_type": "video",
            "media_url": "http://www.onirikal.com/videos/mp4/nestlegold.mp4"
        },
    "media": {
            "media_type": "location",
            "location": {
                "latitude": "12.93803129081362",
                "longitude": "77.61088653615994",
                "name": "Karix Mobile Pvt Ltd",
                "address": "30, Hosur Rd, 7th Block, Koramangala, Bengaluru, Karnataka 560095"
            }
        }
Parameter Type Description
*media_type String Type of the attachment you want to send through your template. Valid: image, audio, document, video
*media_url String URL for the attachment. Required except the media type is location/text.
media_caption String Caption for the attachment.
document_file_name String Describes the filename for the specific document. Only required if the media type is document
*text_header_title String Required only if approved template having text header and a parameter included in header text.
*location Object Details of the location object, if media type is location

Parameter Type Description
*quick_replies Array(Object) List of quick_replies button object. This is required if you wants to add quick reply buttons in your message.
*actions Array(object) List of actions button object. This is required if you wants to add call to action buttons in your message.
*coupon_code Array(Object) List of coupon code button object. This is required if you wants to add coupon code buttons in your message.
    "buttons": {
            "quick_replies": [
                {
                    "button_index": "0",
                    "button_payload": "SMS"
                },
                 {
                    "button_index": "1",
                    "button_payload": "VIBER",
                }
            ]
        }
Parameter Type Description
*button_index String Position index of the button. Required if you have quick reply in your template.
*button_payload String Developer-defined payload that will be returned when the button is clicked.
    "buttons": {
            "actions": [
                {
                    "action_index": "0",
                    "action_type": "URL",
                    "action_payload": "invoice/2345345345"
                }
            ]
        }
Parameter Type Description
*action_type String Type of action that whats to do while clicking the button. Supported Values: Dial and URL.
*action_index String Position index of the button. Required if you have either url or dial button in your template.
*action_payload String Developer-defined payload that will be returned when the button is clicked. For Dial Its a phone number and For URL it is a url.
    "buttons": {
            "coupon_code": [
                {
                    "index": 0,
                    "type": "copy_code",
                    "coupon_code": "GCBTS23"
                }
            ]
        }
Parameter Type Description
*index String Position index of the button. Required if you have copy code button in your template.
*type String Type of the coupen code
*coupon_code String The coupon code to be copied when the customer taps the button.
    "limited_time_offer": {
                "expiration_time_ms": 1708804800000
            },
Parameter Type Description
*expiration_time_ms number Offer code expiration time as a UNIX timestamp in milliseconds.
    "carousel": {
                "cards": [
                    {
                        "card_index": "0",
                        "components": [
                            {
                                "type": "header",
                                "parameters": [
                                    {
                                        "type": "image",
                                        "image": {
                                            "id": "1585106238959535"
                                        }
                                    }
                                ]
                            },
                            {
                                "type": "body",
                                "parameters": [
                                    {
                                        "type": "text",
                                        "text": "15OFF"
                                    },
                                    {
                                        "type": "text",
                                        "text": "15%"
                                    }
                                ]
                            },
                            {
                                "type": "button",
                                "sub_type": "quick_reply",
                                "index": "0",
                                "parameters": [
                                    {
                                        "type": "payload",
                                        "payload": "59NqSd"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "card_index": "1",
                        "components": [
                            {
                                "type": "header",
                                "parameters": [
                                    {
                                        "type": "image",
                                        "image": {
                                            "id": "1585106238959535"
                                        }
                                    }
                                ]
                            },
                            {
                                "type": "body",
                                "parameters": [
                                    {
                                        "type": "text",
                                        "text": "20OFFEXOTIC"
                                    },
                                    {
                                        "type": "text",
                                        "text": "20%"
                                    }
                                ]
                            },
                            {
                                "type": "button",
                                "sub_type": "quick_reply",
                                "index": "0",
                                "parameters": [
                                    {
                                        "type": "payload",
                                        "payload": "59NqSdd"
                                    }
                                ]
                            }
                        ]
                    }
                ]
                }
Parameter Type Description
*card_index number Zero-indexed order in which card appears within the card carousel. 0 indicates first card, 1 indicates second card, etc.
*components Array(Object) Includes the header object, body object and button object. See example

Response

When the request is validated, request_id, status and created time will be returned. Users can use this request_id to query status using the Get status endpoint.

200 - Success
{
    "request_id": "d9835609-a4e0-10ea-a26a-eeafbe700fef",
    "status": "accepted",
    "created_at": "2001-08-05T12:52:38.393Z"
}
401 - Unauthorized
{ 
    "detail": { 
    "code": "ACCESS_TOKEN_SIGNATURE_VERIFICATION_FAILED",
    "message": "It looks like your requests were failed due to a missing or invalid 'Access Token'. Sign up at https://app.d7networks.com and create an authentication token in the developer section."
    } 
} 
422 - Validation Error
{
    "detail": [
        {
            "loc": [
            "string"
            ],
        "msg": "string",
        "type": "string"
        }
    ]
} 
404 - Not Found
    {
        "detail": [
            {
                "code": "INVALID_WHATSAPP_ORIGINATOR",
                "message": "Invalid Originator configured"
            }
        ]
    }

Response Parameters

Parameter Value / Pattern
request_id Unique id for each Whatsapp message request. This request_id is required to check delivery status of your Whatsapp message.
status The status of Whatsapp message request. Possible request status are accepted and rejected
created_at Date and time of the Whatsapp message request.

Programing Examples:

One to One Message

1. Template without media and buttons

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")

const response = await client.whatsapp.sendWhatsAppTemplatedMessage({
            originator : "91906152XXXX",
            recipient : "91999999XXXX",
            template_id : "{{template_id}}",
            body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}});

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

client = Client(api_token="Your API token")

client.whatsapp.send_whatsapp_templated_message(originator="91906152XXXX", recipient="91906152XXXX", message_type="TEMPLATE", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"})

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$client = new Client(api_token="Your API token")

$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template']

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator: '9190615XXXXX',
    recipients: [["recipient" => "{recipient}", "recipient_type" => "individual"]],
    template_id: '{{template_id}}',
    body_parameter_values: $body_parameter_values,
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
whatsapp := direct7.NewWhatsApp(client)
originator := "{{originator}}"
recipient := "{{recipient}}"
templateID := "marketing_template"
optParams := &OptionalParams{bodyParameterValues: map[string]interface{}{
    "0": "Anu",
}}

response, err := whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateID, optParams)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"originator\": \"{{originator}}\",\n        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\":{\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n    }\n  ]\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v2/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n  `"messages`": [`n    {`n        `"originator`": `"{{originator}}`",`n        `"originator_name`": `"{{originator_name}}`",`n        `"recipients`": [`"{{recipient1}}`"],`n        `"content`": {`n        `"message_type`": `"TEMPLATE`",`n        `"template`": {`n        `"template_id`": `"{{template_id}}`",`n      `"body_parameter_values`": {`n        `"0`": `"first_parameter_in_your_template`",`n        `"2`": `"second_parameter_in_your_template`"`n}`n}`n},`n       `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n}`n  ] `n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v2/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
1
2
3
4
5
require 'direct7'

client = Direct7::Client.new('Your API token')

client.whatsapp.send_whatsapp_templated_message(originator="91906152XXXX", recipient="91906152XXXX", message_type="TEMPLATE", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"})
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"originator\": \"{{originator}}\",\n        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\":{\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n    }\n  ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

One to Many Message

1. Message type Template without media and buttons

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}'
var axios = require('axios');
var data = JSON.stringify({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v2/send',
headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer {{api_access_token}}'
},
data : data
};

axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json

url = "https://api.d7networks.com/whatsapp/v2/send"

payload = json.dumps({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token


$payload = '{
    "messages": [
        "originator": "{{originator}}",
        "recipients": [
            {
                "recipient": "{{recipient1}}",
                "recipient_type": "individual",
                "reference": {
                    "cust_ref": "[email protected]",
                    "messageTag1": "SomeMessageTag",
                    "conversationId": "ConversationId"
                }
            },
            {
                "recipient": "{{recipient2}}",
                "recipient_type": "individual",
                "reference": {
                    "cust_ref": "[email protected]",
                    "messageTag1": "SomeMessageTag",
                    "conversationId": "ConversationId"
                }
            }
        ],
        "content": {
            "message_type": "TEMPLATE",
            "template": {
                "template_id": "{{template_id}}",
                "body_parameter_values": {
                    "0": "first_parameter_in_your_template",
                    "1": "second_parameter_in_your_template"
                }
            }
        },
        "report_url": "https://the_url_to_recieve_delivery_report.com"
    ]
}' ;

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v2/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$payload,
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Accept: application/json',
    'Authorization: Bearer '.$token
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
// Add custom code to save the response in database and use it later to track the delivery report
?>
package main

import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)

func main() {

url := "https://api.d7networks.com/whatsapp/v2/send"
method := "POST"

payload := strings.NewReader(`{
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}`)

client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
    fmt.Println(err)
    return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer {{api_access_token}}")

res, err := client.Do(req)
if err != nil {
    fmt.Println(err)
    return
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n        \"messages\": [\n            {\n                \"originator\": \"{{originator}}\",\n                \"content\": {\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v2/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n        `"messages`": [`n            {`n                `"originator`": `"{{originator}}`",`n                `"content`": {`n                    `"message_type`": `"TEMPLATE`",`n                    `"template`": {`n                        `"template_id`": `"{{template_id}}`",`n                        `"body_parameter_values`": {`n                            `"0`": `"first_parameter_in_your_template`",`n                            `"1`": `"second_parameter_in_your_template`"`n                        }`n                    }`n                },`n                `"recipients`": [`n                    {`n                        `"recipient`": `"{{recipient1}}`",`n                        `"recipient_type`": `"individual`",`n                        `"reference`": {`n                            `"cust_ref`": `"[email protected]`",`n                            `"messageTag1`": `"SomeMessageTag`",`n                            `"conversationId`": `"ConversationId`"`n                        }`n                    },`n                    {`n                        `"recipient`": `"{{recipient2}}`",`n                        `"recipient_type`": `"individual`",`n                        `"reference`": {`n                            `"cust_ref`": `"[email protected]`",`n                            `"messageTag1`": `"SomeMessageTag`",`n                            `"conversationId`": `"ConversationId`"`n                        }`n                    }`n                ],`n                `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n            }`n        ]`n    }"

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v2/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v2/send")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
})

response = https.request(request)
puts response.read_body
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n        \"messages\": [\n            {\n                \"originator\": \"{{originator}}\",\n                \"content\": {\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Many to Many Message

1. Message type Template without media and buttons

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}'
var axios = require('axios');
var data = JSON.stringify({
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v2/send',
headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer {{api_access_token}}'
},
data : data
};

axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json

url = "https://api.d7networks.com/whatsapp/v2/send"

payload = json.dumps({
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token


$payload = '{
    "messages: [{
        "originator": "{{originator}}",
        "recipients": [
            {
                "recipient": "{{recipient1}}",
                "recipient_type": "individual",
                "reference": {
                    "cust_ref": "[email protected]",
                    "messageTag1": "d7id00001",
                    "conversationId": "d7id00001"
                }
            },
            {
                "recipient": "{{recipient2}}",
                "recipient_type": "individual",
                "reference": {
                    "cust_ref": "[email protected]",
                    "messageTag1": "d7id00001",
                    "conversationId": "d7id00001"
                }
            }
        ],
        "content": {
            "message_type": "TEMPLATE",
            "template": {
                "template_id": "{{template_id}}",
                "body_parameter_values": {
                    "0": "first_parameter_in_your_template",
                    "1": "second_parameter_in_your_template"
                }
            }
        },
        "report_url": "https://the_url_to_recieve_delivery_report.com"
    }]
}' ;


curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v2/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$payload,
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Accept: application/json',
    'Authorization: Bearer '.$token
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
// Add custom code to save the response in database and use it later to track the delivery report
?>
package main

import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)

func main() {

url := "https://api.d7networks.com/whatsapp/v2/send"
method := "POST"

payload := strings.NewReader(`{
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}`)

client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
    fmt.Println(err)
    return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer {{api_access_token}}")

res, err := client.Do(req)
if err != nil {
    fmt.Println(err)
    return
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"messages\": [\n            {\n                \"originator\": \"{{originator1}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            },\n            {\n                \"originator\": \"{{originator2}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v2/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n        `"messages`": [`n            {`n                `"originator`": `"{{originator1}}`",`n                `"content`": {`n                    `"preview_url`": false,`n                    `"message_type`": `"TEMPLATE`",`n                    `"template`": {`n                        `"template_id`": `"{{template_id}}`",`n                        `"body_parameter_values`": {`n                            `"0`": `"first_parameter_in_your_template`",`n                            `"1`": `"second_parameter_in_your_template`"`n                        }`n                    }`n                },`n                `"recipients`": [`n                    {`n                        `"recipient`": `"{{recipient1}}`",`n                        `"recipient_type`": `"individual`",`n                        `"reference`": {`n                            `"cust_ref`": `"[email protected]`",`n                            `"messageTag1`": `"d7id00001`",`n                            `"conversationId`": `"d7id00001`"`n                        }`n                    },`n                    {`n                        `"recipient`": `"{{recipient2}}`",`n                        `"recipient_type`": `"individual`",`n                        `"reference`": {`n                            `"cust_ref`": `"[email protected]`",`n                            `"messageTag1`": `"d7id00001`",`n                            `"conversationId`": `"d7id00001`"`n                        }`n                    }`n                ],`n                `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n            },`n            {`n                `"originator`": `"{{originator2}}`",`n                `"content`": {`n                    `"preview_url`": false,`n                    `"message_type`": `"TEMPLATE`",`n                    `"template`": {`n                        `"template_id`": `"{{template_id}}`",`n                        `"body_parameter_values`": {`n                            `"0`": `"first_parameter_in_your_template`",`n                            `"1`": `"second_parameter_in_your_template`"`n                        }`n                    }`n                },`n                `"recipients`": [`n                    {`n                        `"recipient`": `"{{recipient1}}`",`n                        `"recipient_type`": `"individual`",`n                        `"reference`": {`n                            `"cust_ref`": `"[email protected]`",`n                            `"messageTag1`": `"d7id00001`",`n                            `"conversationId`": `"d7id00001`"`n                        }`n                    },`n                    {`n                        `"recipient`": `"{{recipient2}}`",`n                        `"recipient_type`": `"individual`",`n                        `"reference`": {`n                            `"cust_ref`": `"[email protected]`",`n                            `"messageTag1`": `"d7id00001`",`n                            `"conversationId`": `"d7id00001`"`n                        }`n                    }`n                ],`n                `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n            }`n        ]`n    }"

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v2/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v2/send")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "[email protected]",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
})

response = https.request(request)
puts response.read_body
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n        \"messages\": [\n            {\n                \"originator\": \"{{originator1}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            },\n            {\n                \"originator\": \"{{originator2}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"[email protected]\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Send scheduled messages

    curl --location 'https://api.d7networks.com/whatsapp/v2/send' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer {{api_access_token}}' \
    --data '{
        "messages": [
            {
                "originator": "{{originator}}",
                "recipients": [
                    "{{recipient1}}"
                ],
                "content": {
                    "message_type": "TEMPLATE",
                    "template": {
                        "template_id": "{{template_id}}",
                        "language": "en",
                        "body_parameter_values": {
                            "0": "first_parameter_in_your_template",
                            "1": "second_parameter_in_your_template"
                        }
                    }
                },
                "report_url": "https://the_url_to_recieve_delivery_report.com"
            }
        ],
        "message_globals": {
            "schedule_time": "2024-06-19T08:14:42+0000"
        }
    }'
    const axios = require('axios');
    let data = JSON.stringify({
    "messages": [
        {
        "originator": "{{originator}}",
        "recipients": [
            "{{recipient1}}"
        ],
        "content": {
            "message_type": "TEMPLATE",
            "template": {
            "template_id": "{{template_id}}",
            "language": "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
            }
        },
        "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ],
    "message_globals": {
        "schedule_time": "2024-06-19T08:14:42+0000"
    }
    });

    let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://api.d7networks.com/whatsapp/v2/send',
    headers: { 
        'Content-Type': 'application/json', 
        'Authorization': 'Bearer {{api_access_token}}'
    },
    data : data
    };

    axios.request(config)
    .then((response) => {
    console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
    console.log(error);
    });
i   mport requests
    import json

    url = "https://api.d7networks.com/whatsapp/v2/send"

    payload = json.dumps({
    "messages": [
        {
        "originator": "{{originator}}",
        "recipients": [
            "{{recipient1}}"
        ],
        "content": {
            "message_type": "TEMPLATE",
            "template": {
            "template_id": "{{template_id}}",
            "language": "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
            }
        },
        "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ],
    "message_globals": {
        "schedule_time": "2024-06-19T08:14:42+0000"
    }
    })
    headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {{api_access_token}}'
    }

    response = requests.request("POST", url, headers=headers, data=payload)

    print(response.text)
    <?php

    $curl = curl_init();

    curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v2/send',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
        "messages": [
            {
                "originator": "{{originator}}",
                "recipients": [
                    "{{recipient1}}"
                ],
                "content": {
                    "message_type": "TEMPLATE",
                    "template": {
                        "template_id": "{{template_id}}",
                        "language": "en",
                        "body_parameter_values": {
                            "0": "first_parameter_in_your_template",
                            "1": "second_parameter_in_your_template"
                        }
                    }
                },
                "report_url": "https://the_url_to_recieve_delivery_report.com"
            }
        ],
        "message_globals": {
            "schedule_time": "2024-06-19T08:14:42+0000"
        }
    }',
    CURLOPT_HTTPHEADER => array(
        'Content-Type: application/json',
        'Authorization: Bearer {{api_access_token}}'
    ),
    ));

    $response = curl_exec($curl);

    curl_close($curl);
    echo $response;
    package main

    import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
    )

    func main() {

    url := "https://api.d7networks.com/whatsapp/v2/send"
    method := "POST"

    payload := strings.NewReader(`{
        "messages": [
            {
                "originator": "{{originator}}",
                "recipients": [
                    "{{recipient1}}"
                ],
                "content": {
                    "message_type": "TEMPLATE",
                    "template": {
                        "template_id": "{{template_id}}",
                        "language": "en",
                        "body_parameter_values": {
                            "0": "first_parameter_in_your_template",
                            "1": "second_parameter_in_your_template"
                        }
                    }
                },
                "report_url": "https://the_url_to_recieve_delivery_report.com"
            }
        ],
        "message_globals": {
            "schedule_time": "2024-06-19T08:14:42+0000"
        }
    }`)

    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
        fmt.Println(err)
        return
    }
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Bearer {{api_access_token}}")

    res, err := client.Do(req)
    if err != nil {
        fmt.Println(err)
        return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(string(body))
    }
    OkHttpClient client = new OkHttpClient().newBuilder()
    .build();
    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"recipients\": [\n                \"{{recipient1}}\"\n            ],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"language\": \"en\",\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ],\n    \"message_globals\": {\n        \"schedule_time\": \"2024-06-19T08:14:42+0000\"\n    }\n}");
    Request request = new Request.Builder()
    .url("https://api.d7networks.com/whatsapp/v2/send")
    .method("POST", body)
    .addHeader("Content-Type", "application/json")
    .addHeader("Authorization", "Bearer {{api_access_token}}")
    .build();
    Response response = client.newCall(request).execute();
    var headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {{api_access_token}}'
    };
    var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
    request.body = json.encode({
    "messages": [
        {
        "originator": "{{originator}}",
        "recipients": [
            "{{recipient1}}"
        ],
        "content": {
            "message_type": "TEMPLATE",
            "template": {
            "template_id": "{{template_id}}",
            "language": "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
            }
        },
        "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ],
    "message_globals": {
        "schedule_time": "2024-06-19T08:14:42+0000"
    }
    });
    request.headers.addAll(headers);

    http.StreamedResponse response = await request.send();

    if (response.statusCode == 200) {
    print(await response.stream.bytesToString());
    }
    else {
    print(response.reasonPhrase);
    }
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("Content-Type", "application/json")
    $headers.Add("Authorization", "Bearer {{api_access_token}}")

    $body = @"
    {
        `"messages`": [
            {
                `"originator`": `"{{originator}}`",
                `"recipients`": [
                    `"{{recipient1}}`"
                ],
                `"content`": {
                    `"message_type`": `"TEMPLATE`",
                    `"template`": {
                        `"template_id`": `"{{template_id}}`",
                        `"language`": `"en`",
                        `"body_parameter_values`": {
                            `"0`": `"first_parameter_in_your_template`",
                            `"1`": `"second_parameter_in_your_template`"
                        }
                    }
                },
                `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"
            }
        ],
        `"message_globals`": {
            `"schedule_time`": `"2024-06-19T08:14:42+0000`"
        }
    }
    "@

    $response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v2/send' -Method 'POST' -Headers $headers -Body $body
    $response | ConvertTo-Json
    require "uri"
    require "json"
    require "net/http"

    url = URI("https://api.d7networks.com/whatsapp/v2/send")

    https = Net::HTTP.new(url.host, url.port)
    https.use_ssl = true

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = "application/json"
    request["Authorization"] = "Bearer {{api_access_token}}"
    request.body = JSON.dump({
    "messages": [
        {
        "originator": "{{originator}}",
        "recipients": [
            "{{recipient1}}"
        ],
        "content": {
            "message_type": "TEMPLATE",
            "template": {
            "template_id": "{{template_id}}",
            "language": "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
            }
        },
        "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ],
    "message_globals": {
        "schedule_time": "2024-06-19T08:14:42+0000"
    }
    })

    response = https.request(request)
    puts response.read_body
1
2
3
4
5
6
7
8
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
    request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
    var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"recipients\": [\n                \"{{recipient1}}\"\n            ],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"language\": \"en\",\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ],\n    \"message_globals\": {\n        \"schedule_time\": \"2024-06-19T08:14:42+0000\"\n    }\n}", null, "application/json");
    request.Content = content;
    var response = await client.SendAsync(request);
    response.EnsureSuccessStatusCode();
    Console.WriteLine(await response.Content.ReadAsStringAsync());