Skip to content

Send templated Whatsapp Messages

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}"
              }
          ]
      }

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

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:

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}}","{{recipient2}}"],
        "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',
    recipient: '91999999XXXX',
    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}}\",\"{{recipient2}}\"],\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}}","{{recipient2}}"],
        "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}}`",`"{{recipient2}}`"],`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}}\",\"{{recipient2}}\"],\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());

2. Template with media without 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}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                },
            "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"}, media_type : "image",
            media_url : "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
        });

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"}, media_type="image", media_url="https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg")

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',
    recipient: '91999999XXXX',
    template_id: '{{template_id}}',
    body_parameter_values: $body_parameter_values,
    media_url_type: 'image',
    media_url: 'https://d7networks.com/static/resources/css/img/favicon.d27f70e6ebd0.png'
);

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_media_image"
optParams := &OptionalParams{mediaType: "image", mediaURL: "https://25428574.fs1.hubspotusercontent-eu1.net/hubfs/25428574/D7%20Logo%20rect.webp", 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            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\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\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\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}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                }
            "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            `\`"content`\`": {`\`n                `\`"message_type`\`": `\`"TEMPLATE`\`",`\`n                `\`"media_template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"media`\`": {`\`n                        `\`"media_type`\`": `\`"image`\`",`\`n                        `\`"media_url`\`": `\`"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`\`"`\`n                    },`\`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`\`": [`\`n                        `\`"{{recipient1}}`\`",`\`n                        `\`"{{recipient2}}`\`"`\`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
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"}, media_type="image", media_url="https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg")
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                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\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\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\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());

3. Template with 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}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "quick_replies": [
                        {
                            "button_index": "0",
                            "button_payload": "ButtonText"
                        },
                        {
                            "button_index": "1",
                            "button_payload": "ButtonText"
                        }
                    ]
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
```bash
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")
const actions = [
    {
        "action_type": "url",
        "action_index": "0",
        "action_payload": "ButtonText"
    }
]

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"}, actions: actions});

console.log(response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")
actions = [
    {
        "action_type": "url",
        "action_index": "0",
        "action_payload": "ButtonText"
    }
]

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}", message_type="TEMPLATE", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, actions=actions)
composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$direct7 = new Client(api_token="Your API token");
$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];
$actions = [
    [
        "action_type" => "url",
        "action_index" => "0",
        "action_payload" => "dashboard"
    ]
];  

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator:'{{originator}}',
    recipient:'{{recipient}}',
    template_id:'{{template_id}}',
    body_parameter_values:$body_parameter_values,
    actions:$actions
);

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_media_image"
actions := []map[string]interface{}{
    {
        "action_type":    "url",
        "action_index":   "0",
        "action_payload": "ButtonText",
    },
}
optParams := &OptionalParams{mediaType: "image", mediaURL: "https://25428574.fs1.hubspotusercontent-eu1.net/hubfs/25428574/D7%20Logo%20rect.webp", bodyParameterValues: map[string]interface{}{
    "0": "Anu",
}, actions: actions}

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            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"quick_replies\": [\n                            {\n                                \"button_index\": \"0\",\n                                \"button_payload\": \"ButtonText\"\n                            },\n                            {\n                                \"button_index\": \"1\",\n                                \"button_payload\": \"ButtonText\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\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}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "quick_replies": [
                        {
                            "button_index": "0",
                            "button_payload": "ButtonText"
                        },
                        {
                            "button_index": "1",
                            "button_payload": "ButtonText"
                        }
                    ]
            }
        }
    },
    "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                `"media_template`": {`n                    `"template_id`": `"{{template_id}}`",`n                    `"media`": {`n                        `"media_type`": `"image`",`n                        `"media_url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"`n                    },`n                    `"body_parameter_values`": {`n                        `"0`": `"first_parameter_in_your_template`",`n                        `"1`": `"second_parameter_in_your_template`"`n                    },`n                    `"buttons`": {`n                        `"quick_replies`": [`n                            {`n                                `"button_index`": `"0`",`n                                `"button_payload`": `"ButtonText`"`n                            },`n                            {`n                                `"button_index`": `"1`",`n                                `"button_payload`": `"ButtonText`"`n                            }`n                        ]`n                    }`n                }`n            },`n            `"recipients`": [`n                {`n                    `"recipient`": [`n                        `"{{recipient1}}`",`n                        `"{{recipient2}}`"`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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "quick_replies": [
                        {
                            "button_index": "0",
                            "button_payload": "ButtonText"
                        },
                        {
                            "button_index": "1",
                            "button_payload": "ButtonText"
                        }
                    ]
            }
        }
    },
    "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                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"quick_replies\": [\n                            {\n                                \"button_index\": \"0\",\n                                \"button_payload\": \"ButtonText\"\n                            },\n                            {\n                                \"button_index\": \"1\",\n                                \"button_payload\": \"ButtonText\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\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());

4. Template with limited time offer

curl --location 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data '{
    "messages": [
        {
            "originator": "{{originator}}",
            "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"
                    },
                    "media": {
                        "media_type": "image",
                        "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                    },
                    "limited_time_offer": {
                        "expiration_time_ms": 1708804800000
                    },
                    "buttons": {
                        "coupon_code": [
                            {
                                "index": 0,
                                "type": "copy_code",
                                "coupon_code": "GCBTS23"
                            }
                        ]
                    }
                }
            },
                "recipients": [
                    {
                        "recipient": "{{recipient1}}",
                        "recipient_type": "individual"
                    }
                ],
                "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: "{{originator}}",
        recipient: "{{recipient}}",
        template_id: "lto_template",
        media_type: "image",
        media_url: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
        lto_expiration_time_ms: "1708804800000",
        coupon_code: "DWS44"
    });
    console.log('Templated message sent successfully. Response:', response);
pip install direct7
from direct7 import Client

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

response_send_messages = client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}",
                                                                         recipient="{{recipient}}",
                                                                         template_id="lto_template",
                                                                         media_url="https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
                                                                         lto_expiration_time_ms="1708804800000",
                                                                         coupon_code="DWS44")
composer require direct7/direct7-php
require_once 'vendor/autoload.php';
1
2
3
4
5
6
7
8
9
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$direct7 = new Client(api_token="Your API token");

$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(originator:"{{originator}}", recipient:"{{recipient}}", template_id: "lto_template", media_url: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg", lto_expiration_time_ms: "1708804800000", coupon_code: "DWS44");

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}}"
    optParams := &OptionalParams{
        mediaURL:               "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
        ltoExpirationTimeMS:    "1704272804",
        couponCode:             "DWS44",
    }
    response, err := client.whatsapp.SendWhatsAppFreeformMessage(originator, recipient, messageType, 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            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\": {\n                    },\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"limited_time_offer\": {\n                        \"expiration_time_ms\": 1708804800000\n                    },\n                    \"buttons\": {\n                        \"coupon_code\": [\n                            {\n                                \"index\": 0,\n                                \"type\": \"copy_code\",\n                                \"coupon_code\": \"GCBTS23\"\n                            }\n                        ]\n                    }\n                }\n            },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\"\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            \n        }\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("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}}",
    "content": {
        "preview_url": false,
        "message_type": "TEMPLATE",
        "template": {
        "template_id": "{{template_id}}", 
        "language" : "en",
        "body_parameter_values": {},
        "media": {
            "media_type": "image",
            "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
        },
        "limited_time_offer": {
            "expiration_time_ms": 1708804800000
        },
        "buttons": {
            "coupon_code": [
            {
                "index": 0,
                "type": "copy_code",
                "coupon_code": "GCBTS23"
            }
            ]
        }
        }
    },
    "recipients": [
        {
        "recipient": "{{recipient1}}",
        "recipient_type": "individual"
        }
    ],
    "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);
}
$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}}`",
            `"content`": {
                `"preview_url`": false,
                `"message_type`": `"TEMPLATE`",
                `"template`": {
                    `"template_id`": `"{{template_id}}`",
                    `"body_parameter_values`": {
                        `"0"`: `"first_parameter_in_your_template"`,
                        `"1"`: `"second_parameter_in_your_template"`
                    },
                    `"media`": {
                        `"media_type`": `"image`",
                        `"media_url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"
                    },
                    `"limited_time_offer`": {
                        `"expiration_time_ms`": 1708804800000
                    },
                    `"buttons`": {
                        `"coupon_code`": [
                            {
                                `"index`": 0,
                                `"type`": `"copy_code`",
                                `"coupon_code`": `"GCBTS23`"
                            }
                        ]
                    }
                }
            },
                `"recipients`": [
                    {
                        `"recipient`": `"{{recipient1}}`",
                        `"recipient_type`": `"individual`"
                    }
                ],
                `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"

        }
    ]
}

"@

$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}}",
    "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"
            },
        "media": {
            "media_type": "image",
            "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
        },
        "limited_time_offer": {
            "expiration_time_ms": 1708804800000
        },
        "buttons": {
            "coupon_code": [
            {
                "index": 0,
                "type": "copy_code",
                "coupon_code": "GCBTS23"
            }
            ]
        }
        }
    },
    "recipients": [
        {
        "recipient": "{{recipient1}}",
        "recipient_type": "individual"
        }
    ],
    "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
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            \"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                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"limited_time_offer\": {\n                        \"expiration_time_ms\": 1708804800000\n                    },\n                    \"buttons\": {\n                        \"coupon_code\": [\n                            {\n                                \"index\": 0,\n                                \"type\": \"copy_code\",\n                                \"coupon_code\": \"GCBTS23\"\n                            }\n                        ]\n                    }\n                }\n            },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\"\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            \n        }\n    ]\n}\n", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data '{
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "parameter1",
                        "1": "parameter2"
                    },
                    "carousel": {
                        "cards": [
                            {
                                "card_index": "0",
                                "components": [
                                    {
                                        "type": "header",
                                        "parameters": [
                                            {
                                                "type": "image",
                                                "image": {
                                                    "id": "1585106238959535"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        "type": "body",
                                        "parameters": [
                                            {
                                                "type": "text",
                                                "text": "parameter1"
                                            },
                                            {
                                                "type": "text",
                                                "text": "parameter2"
                                            }
                                        ]
                                    },
                                    {
                                        "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": "parameter1"
                                            },
                                            {
                                                "type": "text",
                                                "text": "parameter2"
                                            }
                                        ]
                                    },
                                    {
                                        "type": "button",
                                        "sub_type": "quick_reply",
                                        "index": "0",
                                        "parameters": [
                                            {
                                                "type": "payload",
                                                "payload": "59NqSdd"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual"
                }
            ],
            "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 cards = [
    {
        "card_index": "0",
        "components": [
            {
                "type": "header",
                "parameters": [
                    {
                        "type": "image",
                        "image": {
                            "link": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                        }
                    }
                ]
            },
            {
                "type": "body",
                "parameters": [
                    {
                        "type": "text",
                        "text": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                ]
            },
            {
                "type": "button",
                "sub_type": "quick_reply",
                "index": "0",
                "parameters": [
                    {
                        "type": "payload",
                        "payload": "2259NqSd"
                    }
                ]
            }
        ]
    }
]
response = await client.whatsapp.sendWhatsAppTemplatedMessage({originator:"+971563287051", recipient:"918086757074", message_type:"TEMPLATE", template_id:"carousel_card", carousel_cards:cards});
console.log('Templated message sent successfully. Response:', response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")
cards = [
    {
        "card_index": "0",
        "components": [
            {
                "type": "header",
                "parameters": [
                    {
                        "type": "image",
                        "image": {
                            "link": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                        }
                    }
                ]
            },
            {
                "type": "button",
                "sub_type": "quick_reply",
                "index": "0",
                "parameters": [
                    {
                        "type": "payload",
                        "payload": "2259NqSd"
                    }
                ]
            }
        ]
    }
]

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}", message_type="TEMPLATE", template_id="{{template_id}}", carousl_cards=cards)
composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$direct7 = new Client(api_token="Your API token");
$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];
$cards = [
    [
        "card_index" => "0",
        "components" => [
            [
                "type" => "header",
                "parameters" => [
                    [
                        "type" => "image",
                        "image" => [
                            "link" => "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                        ]
                    ]
                ]
            ],
            [
                "type" => "button",
                "sub_type" => "quick_reply",
                "index" => "0",
                "parameters" => [
                    [
                        "type" => "payload",
                        "payload" => "2259NqSd"
                    ]
                ]
            ]
        ]
    ]
];

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator:'{{originator}}',
    recipient:'{{recipient}}',
    template_id:'{{template_id}}',
    body_parameter_values:$body_parameter_values,
    carousel_cards: $cards
);

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_media_image"
cards := []map[string]interface{}{
    {
        "card_index": "0",
        "components": []map[string]interface{}{
            {
                "type": "header",
                "parameters": []map[string]interface{}{
                    {
                        "type": "image",
                        "image": map[string]interface{}{
                            "link": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
                        },
                    },
                },
            },
            {
                "type": "button",
                "sub_type": "quick_reply",
                "index": "0",
                "parameters": []map[string]interface{}{
                    {
                        "type": "payload",
                        "payload": "2259NqSd",
                    },
                },
            },
        },
    }
}
optParams := &OptionalParams{carousel_card: cards}

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            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\": {\n                        \"0\": \"parameter1\",\n                        \"1\": \"parameter2\"\n                    },\n                    \"carousel\": {\n                        \"cards\": [\n                            {\n                                \"card_index\": \"0\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            },\n                            {\n                                \"card_index\": \"1\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSdd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{{recipient1}}\",\n                    \"recipient_type\": \"individual\"\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\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("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}}",
    "content": {
        "preview_url": false,
        "message_type": "TEMPLATE",
        "template": {
        "template_id": "{{template_id}}",
        "language" : "en",
        "body_parameter_values": {
            "0": "parameter1",
            "1": "parameter2"
        },
        "carousel": {
            "cards": [
            {
                "card_index": "0",
                "components": [
                {
                    "type": "header",
                    "parameters": [
                    {
                        "type": "image",
                        "image": {
                        "id": "1585106238959535"
                        }
                    }
                    ]
                },
                {
                    "type": "body",
                    "parameters": [
                    {
                        "type": "text",
                        "text": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                    ]
                },
                {
                    "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": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                    ]
                },
                {
                    "type": "button",
                    "sub_type": "quick_reply",
                    "index": "0",
                    "parameters": [
                    {
                        "type": "payload",
                        "payload": "59NqSdd"
                    }
                    ]
                }
                ]
            }
            ]
        }
        }
    },
    "recipients": [
        {
        "recipient": "{{recipient1}}",
        "recipient_type": "individual"
        }
    ],
    "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);
}
$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}}`",
            `"content`": {
                `"preview_url`": false,
                `"message_type`": `"TEMPLATE`",
                `"template`": {
                    `"template_id`": `"{{template_id}}`",
                    `"body_parameter_values`": {
                        `"0`": `"parameter1`",
                        `"1`": `"parameter2`"
                    },
                    `"carousel`": {
                        `"cards`": [
                            {
                                `"card_index`": `"0`",
                                `"components`": [
                                    {
                                        `"type`": `"header`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"image`",
                                                `"image`": {
                                                    `"id`": `"1585106238959535`"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        `"type`": `"body`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"text`",
                                                `"text`": `"parameter1`"
                                            },
                                            {
                                                `"type`": `"text`",
                                                `"text`": `"parameter2`"
                                            }
                                        ]
                                    },
                                    {
                                        `"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`": `"parameter1`"
                                            },
                                            {
                                                `"type`": `"text`",
                                                `"text`": `"parameter2`"
                                            }
                                        ]
                                    },
                                    {
                                        `"type`": `"button`",
                                        `"sub_type`": `"quick_reply`",
                                        `"index`": `"0`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"payload`",
                                                `"payload`": `"59NqSdd`"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                }
            },
            `"recipients`": [
                {
                    `"recipient`": `"{{recipient1}}`",
                    `"recipient_type`": `"individual`"
                }
            ],
            `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"
        }
    ]
}

"@

$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}}",
    "content": {
        "preview_url": false,
        "message_type": "TEMPLATE",
        "template": {
        "template_id": "{{template_id}}",
        "language" : "en",
        "body_parameter_values": {
            "0": "parameter1",
            "1": "parameter2"
        },
        "carousel": {
            "cards": [
            {
                "card_index": "0",
                "components": [
                {
                    "type": "header",
                    "parameters": [
                    {
                        "type": "image",
                        "image": {
                        "id": "1585106238959535"
                        }
                    }
                    ]
                },
                {
                    "type": "body",
                    "parameters": [
                    {
                        "type": "text",
                        "text": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                    ]
                },
                {
                    "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": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                    ]
                },
                {
                    "type": "button",
                    "sub_type": "quick_reply",
                    "index": "0",
                    "parameters": [
                    {
                        "type": "payload",
                        "payload": "59NqSdd"
                    }
                    ]
                }
                ]
            }
            ]
        }
        }
    },
    "recipients": [
        {
        "recipient": "{{recipient1}}",
        "recipient_type": "individual"
        }
    ],
    "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
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            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\": {\n                        \"0\": \"parameter1\",\n                        \"1\": \"parameter2\"\n                    },\n                    \"carousel\": {\n                        \"cards\": [\n                            {\n                                \"card_index\": \"0\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            },\n                            {\n                                \"card_index\": \"1\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSdd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{{recipient1}}\",\n                    \"recipient_type\": \"individual\"\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\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
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({
                    "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"
                    }
                }); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$template =  array(
    "template_id"=> $template_id,
    "body_parameter_values"=> $body_parameter_values
);
$content = array(
    "message_type"=> "TEMPLATE",
    "template"=> $template
); // Replace it with message content
$message_obj =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);

$payload = json_encode(
    array(
        "messages"=> array($message_obj)
    )
);
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
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({
                    "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"
                    }
                }); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$template =  array(
    "template_id"=> $template_id,
    "body_parameter_values"=> $body_parameter_values
);
$content = array(
    "message_type"=> "TEMPLATE",
    "template"=> $template
); // Replace it with message content
$message_obj1 =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);
$message_obj2 =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);

$payload = json_encode(
    array(
        "messages"=> array($message_obj1, $message_obj2)
    )
);
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());