Skip to content

Send Whatsapp Message

Our Whatsapp Messaging API designed to fulfill most of your use cases and can be easily integrate to any of the system. We can implement business-initiated and user-initiated message.

Business Initiated messages includes both free form and Templated messages.

POST
/whatsapp/v2/send

Authentication

AUTHORIZATION: Bearer Token

Request 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. +97156xxxxxxx
*recipients Array(Objects) Array of recipient object See examples
*content Object Details of the content object. See examples
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

Recipients Object

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

Content object

Parameter Type Description
*message_type String Type of the message inside the content. Supported Options: TEXT, ATTACHMENT, LOCATION, CONTACTS, TEMPLATE.
*text Object Required if the message type is TEXT.
*attachment Object Required if the message type is ATTACHMENT.
*location Object Required if the message type is LOCATION.
*contacts Object Required if the message type is CONTACTS.
*interactive Object Required if the message type is INTERACTIVE.
*reaction Object Required if the message type is REACTION.
*template Object Required if the message type is TEMPLATE.

You can use the API to send the following free-form business-initiated messages types:

Text object

Parameter Type Description
*body String Text content users want to send, which can contain URLs and formatting. Max allowed length: 4096
preview_url boolean Allows for URL previews in text messages. By default, the mobile WhatsApp application recognizes URLs and makes them clickable. Values: false (default), true.

Attachment object

Parameter Type Description
*type String Type of the attachment you want to send. Supported Values: image, audio, document, video, sticker.
*url String URL for the attachment. The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URL.
caption String Caption for the attachment. Do not use caption with audio or sticker media.
filename String Use filename only with document.

Location object

Parameter Type Description
*longitude String Longitude of the Location you wants to send.
*latitude String Longitude of the Location you wants to send.
name String Name of the Location you wants to send.
address String Address of the Location you wants to send. Only displayed if the name is present.

Contacts Object

Parameter Type Description
*name Object Full contact name formatted as a name object.
addresses Object Full contact address(es) formatted as an addresses object.
birthday Object YYYY-MM-DD formatted string.
emails Object Contact email address(es) formatted as an emails object.
org Object Contact organization information formatted as an org object.
phones Object Contact phone number(s) formatted as a phone object.
urls Object Contact URL(s) formatted as a urls object.

Name Object

Parameter Type Description
*formatted_name String Full name, as it normally appears. At least one of the optional parameters needs to be included along with the formatted_name parameter.
first_name String First name of the contact you wants to send.
last_name String Last name of the contact you wants to send.
middle_name String Middle name of the contact you wants to send.
suffix String Name suffix.
prefix String Name prefix.

Addresses Object

Parameter Type Description
street String Street number and name.
city String City name.
state String State abbreviation.
zip String Zip Code
country String Full country name.
country_code String Two-letter country abbreviation.
type String Standard values are HOME and WORK.

Emails Object

Parameter Type Description
email String Email Address.
type String Supported values are HOME and WORK.

Org Object

Parameter Type Description
company String Name of the contact's company.
department String Name of the contact's department.
title String Contact's business title.

Phones Object

Parameter Type Description
phone String Automatically populated with the wa_id value as a formatted phone number.
type String Standard Values are CELL, MAIN, IPHONE, HOME, and WORK.
wa_id String WhatsApp ID.

Urls Object

Parameter Type Description
url String URL.
type String Supported values are HOME and WORK.

Reaction Object

If the message you are reacting to is more than 30 days old, doesn't correspond to any message in the conversation, has been deleted, or is itself a reaction message, the reaction message will not be delivered

Parameter Type Description
*message_id String The WhatsApp Message ID (wamid) of the message on which the reaction should appear.
*emoji Emoji Emoji to appear on the message. All emojis supported by Android and iOS devices are supported.

Interactive Object

Parameter Type Description
*type String The type of interactive message you want to send. Supported values: button, list
*body Object The body object contains text parameter. Its required if body is present. The content of the message. Emojis and markdown are supported. Maximum length: 1024 characters.
footer Object The footer object contains text field. Required if footer is present. The footer content. Emojis, markdown, and links are supported. Maximum length: 60 characters.
header Object Optional. Header content displayed on top of a message.
*action Object Action you want the user to perform after reading the message.

Header Object

Parameter Type Description
type String The header type you would like to use. Supported values: text- Used for List Messages & Reply Buttons, video- Used for Reply Buttons, image- Used for Reply Buttons, document- Used for Reply Buttons.
document Object Required if type is set to document. Contains two parameters filename and link.
image Object Required if type is set to image. Contains only link parameter.
text String Required if type is set to text. Text for the header. Formatting allows emojis, but not markdown. Maximum length: 60 characters.
video Object Required if type is set to video. Contains only link parameter.

Action Object - list

Parameter Type Description
button String Required. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 characters.
sections Array(Object) Required. Array of section objects. Minimum of 1, maximum of 10. A section object can contain following parameters,
title - Required if the message has more than one section. Title of the section. Maximum length: 24 characters.
rows - Contains a list of rows. You can have a total of 10 rows across your sections. Each row must have a title (Maximum length: 24 characters) and an ID (Maximum length: 200 characters). You can add a description (Maximum length: 72 characters), but it is optional.

Action Object - button

Parameter Type Description
buttons Array(Object) Required for Reply Buttons. You can have up to 3 buttons. You cannot have leading or trailing spaces when setting the ID. A button object can contain the following parameters:
type: only supported type is reply (for Reply Button)
title: Button title. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 characters.
id: Unique identifier for your button. This ID is returned in the webhook when the button is clicked by the user. Maximum length: 256 characters.

Action Object - cta_url

CTA URL buttons allow you to map any URL to a button so you don't have to include the raw URL in the interactive message body.

Parameter Type Description
parameters Array(Object) Required for Call-to-Action Buttons. You can have up to one button. Parameters Object should contain the following parameters:
display_text: Button text.
url: URL to load in the device's default web browser when tapped by the WhatsApp user.

Template object

WhatsApp message templates are specific message formats that businesses use to send out notifications or customer care messages to people that have opted in to notifications. Messages can include appointment reminders, shipping information, issue resolution or payment updates.

Before sending a template message, you need to create a template here.

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

As per the approved templates you can send text/image/video/document in the header of Marketing or Utility Template

Media object

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.

Button object

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.
Quick Reply Button
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.
Call to Action Button
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.
Coupon Code Button
Parameter Type Description
*index String Position index of the button. Required if you have copy code button in your template.
*coupon_code String The coupon code to be copied when the customer taps the button.

Limited Time Offer Template

Limited-time offer templates allow you to display expiration dates and running countdown timers for offer codes in template messages, making it easy for you to communicate time-bound offers and drive customer engagement.

Limitations:

  • Only templates categorized as MARKETING are supported.
  • Footer components are not supported.
  • Users who view a limited-time offer template message using that WhatsApp web app or desktop app will not see the offer, but will instead see a message indicating that they have received a message but that it's not supported in the client they are using.
Parameter Type Description
*expiration_time_ms number Offer code expiration time as a UNIX timestamp in milliseconds.

Limited Time Offer Template should have a coupon code button and URL Button

Carousel templates allow you to send a single text message accompanied by a set of up to 10 carousel cards in a horizontally scrollable view

Cards must have a media header (image or video), body text, and at least one button. Supports 2 buttons. Buttons can be the same or a mix of quick reply buttons, phone number buttons, or URL buttons.

The media header format and button types must be the same across all cards that make up a carousel template.

Media assets will be cropped to a wide ratio based on the customer's device.

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

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.

Examples:

One to One 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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language": "{{template_language}}",
            "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}}",
            language: "{{template_language}}",
            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}}", language= "{{template_language}}", 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}}',
    language: "{{template_language}}",
    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"
language := "{{template_language}}"
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                    \"language\": \"{{template_language}}\",\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": "{{template_language}}",
            "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        `"language`": `"{{template_language}}`",`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}}", language="{{template_language}}", 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                    \"language\": \"{{template_language}}\",\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. Message type 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": "{{template_language}}",
            "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}}", 
            language : "{{template_language}}", 
            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}}", language="{{template_language}}", 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}}',
    language: '{{template_language}}',
    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"
language := "template_language"
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                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                                        \"language\": \"{{template_language}}\",\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": "{{template_language}}",
            "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                `\`"template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"language`\`": `\`"{{template_language}}`\`",`\`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}}", language="{{template_language}}", 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                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"language\": \"{{template_language}}\",\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. Message type 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": "{{template_language}}",
            "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}}",
            language: "{{template_language}}",
            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}}", language="{{"template_language}}", 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}}',
    language: '{{template_language}}',
    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"
language := "{{template_language}}"
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                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"language\": \"{{template_language}}\",\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": "{{template_language}}",
            "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                `"template`": {`n                    `"template_id`": `"{{template_id}}`",`n                    `"language`": `"{{template_language}}`",`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": "{{template_language}}",
            "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                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"language\": \"{{template_language}}\",\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());

5. Message type 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": "{{template_language}}",
                    "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",
        language: "{{template_language}}",
        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",
                                                                          language="{{template_language}}",
                                                                         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", language: "template_language", 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                    \"language\": \"{{template_language}}\",\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": "{{template_language}}",
        "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}}`",
                    `"language`": `"{{template_language}}`",
                    `"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": "{{template_language}}",
        "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                    \"language\": \"{{template_language}}\",\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": "{{template_language}}",
                    "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                    \"language\": \"{{template_language}}\",\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": "{{template_language}}",
        "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}}`",
                    `"language`": `"{{template_language}}`",
                    `"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": "{{template_language}}",
        "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                    \"language\": \"{{template_language}}\",\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());

7. Message type Contact

curl --location 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data '{
    "messages": [
        {
            "originator": "{{originator}}",
            "recipients": ["{{recipient1}}","{{recipient2}}"],
            "content": {
                "message_type": "CONTACTS",
                "contacts": [{
                    "name": {
                        "first_name": "FirstName",
                        "last_name": "LastName",
                        "formatted_name": "FormattedName"},
                    "birthday":"YYYY-MM-DD",
                    "phones": [{"phone": "PhoneNumber1"}, {"phone": "PhoneNumber2"}],
                    "emails":[{"email": "EmailAddress"}],
                    "urls":[{"url": "Url"}]
                }]
            },
            "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.sendWhatsAppFreeformMessage({
        originator: "{{originator}}",
        recipient: "{{recipient}}",
        message_type: "CONTACTS",
        first_name: "Amal",
        last_name: "Anu",
        formatted_name: "Amal Anu",
        phones: ["9181XXXXXXXX", "9181XXXXXXXX"],
        emails: ["[email protected]", "[email protected]"]
    });

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

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

client.whatsapp.send_whatsapp_freeform_message(originator="{{originator}}",
                                                recipient="{{recipient}}",
                                                message_type="CONTACTS", first_name="Amal",
                                                last_name="Anu", formatted_name="Amal Anu",
                                                phones=["9181XXXXXXXX", "9181XXXXXXXX"],
                                                emails=["[email protected]",
                                                        "[email protected]"])
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}}", message_type:"CONTACTS", first_name:"Amal", last_name:"Anu", formatted_name:"Amal Anu", phones:["91906152XXXX", "91906152XXXX"], emails : ["[email protected]","[email protected]"]);

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}}"
messageType := "CONTACTS"
optParams := &OptionalParams{
    firstName:     "Amal",
    lastName:      "Anu",
    formattedName: "Amal Anu",
    phones:        []map[string]string{{"phone": "9181XXXXXXXX"}, {"phone": "9181XXXXXXXX"}},
    emails:        []map[string]string{{"email": "[email protected]"}, {"email": "[email protected]"}},
}
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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"CONTACTS\",\n            \"contact\": {\n                    \"first_name\": \"FirstName\",\n                    \"last_name\": \"SecondName\",\n                    \"display_name\": \"DisplayName\",\n                    \"phone\": \"PhoneNumber\",\n                    \"email\": \"EmailAddress\",\n                    \"url\": \"Url\"\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": "CONTACTS",
        "contact": {
                "first_name": "FirstName",
                "last_name": "SecondName",
                "display_name": "DisplayName",
                "phone": "PhoneNumber",
                "email": "EmailAddress",
                "url": "Url"
            }
    },
    "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            `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n            `"content`": {`n            `"message_type`": `"CONTACTS`",`n            `"contact`": {`n                    `"first_name`": `"FirstName`",`n                    `"last_name`": `"SecondName`",`n                    `"display_name`": `"DisplayName`",`n                    `"phone`": `"PhoneNumber`",`n                    `"email`": `"EmailAddress`",`n                    `"url`": `"Url`"`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_freeform_message(originator="91906152XXXX", recipient="91906152XXXX", message_type="CONTACTS", first_name="Amal", last_name="Anu", display_name="Amal Anu", phone="91906152XXXX", email = "[email protected]")
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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"CONTACTS\",\n            \"contact\": {\n                    \"first_name\": \"FirstName\",\n                    \"last_name\": \"SecondName\",\n                    \"display_name\": \"DisplayName\",\n                    \"phone\": \"PhoneNumber\",\n                    \"email\": \"EmailAddress\",\n                    \"url\": \"Url\"\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());

5. Message type Location

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": "LOCATION",
        "location": {
                "longitude": 77.1249,
                "latitude": 12.8779,
                "name": "NameOfLocation",
                "address": "AddressOfLocation"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
npm i direct7
1
2
3
4
5
6
7
8
9
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({
            originator : "{{originator}}", recipient : "{{recipient}}", message_type: "LOCATION",  longitude : "11.93803129081362", latitude:"44.61088653615994", address:"Address", name:"Name"
        });

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

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

client.whatsapp.send_whatsapp_freeform_message(
            originator = "91906152XXXX", recipient = "91999999XXXX", message_type= "LOCATION",  longitude = "11.93803129081362", latitude="44.61088653615994", address="Address", name="Name")
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}}", message_type:"LOCATION", latitude: "12.93803129081362", longitude: "77.61088653615994", name: "Pvt Ltd", address: "Bengaluru, Karnataka");

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}}"
messageType := "LOCATION"
optParams := &OptionalParams{
                "longitude": 77.1249,
                "latitude": 12.8779,
                "name": "NameOfLocation",
                "address": "AddressOfLocation"
            }
response, err := 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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"LOCATION\",\n            \"location\": {\n                    \"longitude\": 77.1249,\n                    \"latitude\": 12.8779,\n                    \"name\": \"NameOfLocation\",\n                    \"address\": \"AddressOfLocation\"\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": "LOCATION",
        "location": {
                "longitude": 77.1249,
                "latitude": 12.8779,
                "name": "NameOfLocation",
                "address": "AddressOfLocation"
            }
    },
    "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            `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n            `"content`": {`n            `"message_type`": `"LOCATION`",`n            `"location`": {`n                    `"longitude`": 77.1249,`n                    `"latitude`": 12.8779,`n                    `"name`": `"NameOfLocation`",`n                    `"address`": `"AddressOfLocation`"`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_freeform_message(originator = "91906152XXXX", recipient = "91999999XXXX", message_type= "LOCATION",  longitude = "11.93803129081362", latitude="44.61088653615994", location_address="Address", location_name="Name")
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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"LOCATION\",\n            \"location\": {\n                    \"longitude\": 77.1249,\n                    \"latitude\": 12.8779,\n                    \"name\": \"NameOfLocation\",\n                    \"address\": \"AddressOfLocation\"\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());

6. Message type Attachment

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": "ATTACHMENT",
        "attachment": {
                "type":"video",
                "url": "AttachmnetUrl",
                "caption": "AttachmentCaption"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
npm i direct7
1
2
3
4
5
6
7
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({originator: "{{originator}}", recipient: "{{recipient}}", type: "video", url: "AttachmnetUrl", caption: "caption"});

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_freeform_message(originator="{{originator}}", recipient="{{recipient}}", message_type="ATTACHMENT", type="image", url="https://picsum.photos/200/300", caption="Caption")
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}}", message_type:"ATTACHMENT", type: "image", url: "https://upload.wikimedia.org", caption: "test");

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}}"
messageType := "ATTACHMENT"
optParams := &OptionalParams{
                "attachmentType":"video",
                "attachmentURL": "AttachmnetUrl",
                "attachmentCaption": "AttachmentCaption"
            }
response, err := 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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"ATTACHMENT\",\n            \"attachment\": {\n                    \"type\":\"video\",\n                    \"url\": \"AttachmnetUrl\",\n                    \"caption\": \"AttachmentCaption\"\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": "ATTACHMENT",
        "attachment": {
                "type":"video",
                "url": "AttachmnetUrl",
                "caption": "AttachmentCaption"
            }
    },
    "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            `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n            `"content`": {`n            `"message_type`": `"ATTACHMENT`",`n            `"attachment`": {`n                    `"type`":`"video`",`n                    `"url`": `"AttachmnetUrl`",`n                    `"caption`": `"AttachmentCaption`"`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_freeform_message(type= "video", url= "AttachmnetUrl", caption= "caption")
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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"ATTACHMENT\",\n            \"attachment\": {\n                    \"type\":\"video\",\n                    \"url\": \"AttachmnetUrl\",\n                    \"caption\": \"AttachmentCaption\"\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());

7. Message type Text

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": "TEXT",
        "text": {
                "body":"Hi, How can I help you?"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
npm i direct7
1
2
3
4
5
6
7
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({originator: "{{originator}}", recipient: "{{recipient}}", message_type: "TEXT", body: "Hi, How can I help you?"});

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_freeform_message(originator="{{originator}}", recipient="{{recipient}}", message_type="TEXT", body="Hi, How can I help you?")
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}}", message_type:"TEXT", body: "Hi");

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}}"
messageType := "TEXT"
optParams := &OptionalParams{
    body: "Hi",
}
response, err := 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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"TEXT\",\n            `"text`":{`n                    `"preview_url`": true,`n                    `"body`": `"Hi, How can I help you?`"`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": "TEXT",
        "text": {
                "body":"Hi, How can I help you?"
            }
    },
    "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            `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n            `"content`": {`n            `"message_type`": `"TEXT`",`n            `"text`":{`n                    `"preview_url`": true,`n                    `"body`": `"Hi, How can I help you?`"`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_freeform_message(message_text= "Hi, How can I help you?")
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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n            \"message_type\": \"TEXT\",\n            \"text\":{\n        \"body\":\"Hi, How can I help you?\"\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());

8. Message Type Interactive with action list

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Authorization: Bearer {{api_access_token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "messages": [
        {
            "originator": "91xx615xx5x4",
            "content": {
                "preview_url": false,
                "message_type": "INTERACTIVE",
            "interactive": {
                "type": "list",
                "header": {
                    "type": "text",
                    "text": "Direct7 Networks"
                },
                "body": {
                    "text": "Choose one of our service"
                },
                "footer": {
                    "text": "Thank you"
                },
                "action": {
                    "button": "Choose Service",
                    "sections": [
                        {
                            "title": "SMS Messaging",
                            "rows": [
                                {
                                    "id": "1",
                                    "title": "Normal SMS",
                                    "description": "Signup for free at the D7 platform to use our Messaging APIs."
                                },
                                {
                                    "id": "2",
                                    "title": "Verify",
                                    "description": "D7 Verify API is to applications requires SMS based OTP authentications."
                                }
                            ]
                        },
                        {
                            "title": "Whatsapp",
                            "rows": [
                                {
                                    "id": "3",
                                    "title": "WhatsApp Messages",
                                    "description": "D7 Whatsapp API is to applications requires pre-registration."
                                }
                            ]
                        }
                    ]
                }
            }
            },
            "recipients": [{
                "recipient": "+9715xx6xx543",
                "recipient_type": "individual"
            }],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}'
var axios = require('axios');
var data = JSON.stringify({
  "messages": [
    {
      "originator": "91xx615xx5x4",
      "content": {
        "preview_url": false,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "list",
          "header": {
            "type": "text",
            "text": "Direct7 Networks"
          },
          "body": {
            "text": "Choose one of our service"
          },
          "footer": {
            "text": "Thank you"
          },
          "action": {
            "button": "Choose Service",
            "sections": [
              {
                "title": "SMS Messaging",
                "rows": [
                  {
                    "id": "1",
                    "title": "Normal SMS",
                    "description": "Signup for free at the D7 platform to use our Messaging APIs."
                  },
                  {
                    "id": "2",
                    "title": "Verify",
                    "description": "D7 Verify API is to applications requires SMS based OTP authentications."
                  }
                ]
              },
              {
                "title": "Whatsapp",
                "rows": [
                  {
                    "id": "3",
                    "title": "WhatsApp Messages",
                    "description": "D7 Whatsapp API is to applications requires pre-registration."
                  }
                ]
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx543",
          "recipient_type": "individual"
        }
      ],
      "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
  ]
});

var config = {
  method: 'post',
  url: 'https://api.d7networks.com/whatsapp/v2/send',
  headers: {
    'Authorization': 'Bearer {{api_access_token}}',
    'Content-Type': 'application/json'
  },
  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": "91xx615xx5x4",
      "content": {
        "preview_url": False,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "list",
          "header": {
            "type": "text",
            "text": "Direct7 Networks"
          },
          "body": {
            "text": "Choose one of our service"
          },
          "footer": {
            "text": "Thank you"
          },
          "action": {
            "button": "Choose Service",
            "sections": [
              {
                "title": "SMS Messaging",
                "rows": [
                  {
                    "id": "1",
                    "title": "Normal SMS",
                    "description": "Signup for free at the D7 platform to use our Messaging APIs."
                  },
                  {
                    "id": "2",
                    "title": "Verify",
                    "description": "D7 Verify API is to applications requires SMS based OTP authentications."
                  }
                ]
              },
              {
                "title": "Whatsapp",
                "rows": [
                  {
                    "id": "3",
                    "title": "WhatsApp Messages",
                    "description": "D7 Whatsapp API is to applications requires pre-registration."
                  }
                ]
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx543",
          "recipient_type": "individual"
        }
      ],
      "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
  ]
})
headers = {
  'Authorization': 'Bearer {{api_access_token}}',
  'Content-Type': 'application/json'
}

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
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$header = array("type"=> "text","text"=> "Direct7 Networks")
$sections1 =   array("title"=> "SMS Messaging", "rows"=> [array("id"=> "1", "title"=> "Normal SMS", "description"=> "Signup for free at the D7 platform to use our Messaging APIs."),
                            array("id"=> "2", "title"=> "Verify", "description"=> "D7 Verify API is to applications requires SMS based OTP authentications.")])
$sections2 =   array("title"=> "Whatsapp", "rows"=> [array("id"=> "3", "title"=> "WhatsApp Messages", "description"=> "D7 Whatsapp API is to applications requires pre-registration.")])
$interactive = array("type"=> "list",
            "header"=> $header,
            "body"=> array("text"=> "Choose one of our service"),
            "footer"=> array("text"=> "Thank you"),
            "action"=> array("button"=> "Choose one of our service", "sections"=> [$sections1, $sections2])
            )
$content = array(
    "message_type"=> "INTERACTIVE",
    "interactive"=> $interactive
); // 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": "91xx615xx5x4",
            "content": {
                "preview_url": false,
                "message_type": "INTERACTIVE",
            "interactive": {
                "type": "list",
                "header": {
                    "type": "text",
                    "text": "Direct7 Networks"
                },
                "body": {
                    "text": "Choose one of our service"
                },
                "footer": {
                    "text": "Thank you"
                },
                "action": {
                    "button": "Choose Service",
                    "sections": [
                        {
                            "title": "SMS Messaging",
                            "rows": [
                                {
                                    "id": "1",
                                    "title": "Normal SMS",
                                    "description": "Signup for free at the D7 platform to use our Messaging APIs."
                                },
                                {
                                    "id": "2",
                                    "title": "Verify",
                                    "description": "D7 Verify API is to applications requires SMS based OTP authentications."
                                }
                            ]
                        },
                        {
                            "title": "Whatsapp",
                            "rows": [
                                {
                                    "id": "3",
                                    "title": "WhatsApp Messages",
                                    "description": "D7 Whatsapp API is to applications requires pre-registration."
                                }
                            ]
                        }
                    ]
                }
            }
            },
            "recipients": [{
                "recipient": "+9715xx6xx543",
                "recipient_type": "individual"
            }],
            "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("Authorization", "Bearer {{api_access_token}}")
  req.Header.Add("Content-Type", "application/json")

  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\": \"91xx615xx5x4\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"INTERACTIVE\",\n            \"interactive\": {\n                \"type\": \"list\",\n                \"header\": {\n                    \"type\": \"text\",\n                    \"text\": \"Direct7 Networks\"\n                },\n                \"body\": {\n                    \"text\": \"Choose one of our service\"\n                },\n                \"footer\": {\n                    \"text\": \"Thank you\"\n                },\n                \"action\": {\n                    \"button\": \"Choose Service\",\n                    \"sections\": [\n                        {\n                            \"title\": \"SMS Messaging\",\n                            \"rows\": [\n                                {\n                                    \"id\": \"1\",\n                                    \"title\": \"Normal SMS\",\n                                    \"description\": \"Signup for free at the D7 platform to use our Messaging APIs.\"\n                                },\n                                {\n                                    \"id\": \"2\",\n                                    \"title\": \"Verify\",\n                                    \"description\": \"D7 Verify API is to applications requires SMS based OTP authentications.\"\n                                }\n                            ]\n                        },\n                        {\n                            \"title\": \"Whatsapp\",\n                            \"rows\": [\n                                {\n                                    \"id\": \"3\",\n                                    \"title\": \"WhatsApp Messages\",\n                                    \"description\": \"D7 Whatsapp API is to applications requires pre-registration.\"\n                                }\n                            ]\n                        }\n                    ]\n                }\n            }\n            },\n            \"recipients\": [{\n                \"recipient\": \"+9715xx6xx543\",\n                \"recipient_type\": \"individual\"\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("Authorization", "Bearer {{api_access_token}}")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
var headers = {
  'Authorization': 'Bearer {{api_access_token}}',
  'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
  "messages": [
    {
      "originator": "91xx615xx5x4",
      "content": {
        "preview_url": false,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "list",
          "header": {
            "type": "text",
            "text": "Direct7 Networks"
          },
          "body": {
            "text": "Choose one of our service"
          },
          "footer": {
            "text": "Thank you"
          },
          "action": {
            "button": "Choose Service",
            "sections": [
              {
                "title": "SMS Messaging",
                "rows": [
                  {
                    "id": "1",
                    "title": "Normal SMS",
                    "description": "Signup for free at the D7 platform to use our Messaging APIs."
                  },
                  {
                    "id": "2",
                    "title": "Verify",
                    "description": "D7 Verify API is to applications requires SMS based OTP authentications."
                  }
                ]
              },
              {
                "title": "Whatsapp",
                "rows": [
                  {
                    "id": "3",
                    "title": "WhatsApp Messages",
                    "description": "D7 Whatsapp API is to applications requires pre-registration."
                  }
                ]
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx543",
          "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);
}
1
2
3
4
5
6
7
8
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer {{api_access_token}}")
$headers.Add("Content-Type", "application/json")

$body = "{`n    `"messages`": [`n        {`n            `"originator`": `"91xx615xx5x4`",`n            `"content`": {`n                `"preview_url`": false,`n                `"message_type`": `"INTERACTIVE`",`n            `"interactive`": {`n                `"type`": `"list`",`n                `"header`": {`n                    `"type`": `"text`",`n                    `"text`": `"Direct7 Networks`"`n                },`n                `"body`": {`n                    `"text`": `"Choose one of our service`"`n                },`n                `"footer`": {`n                    `"text`": `"Thank you`"`n                },`n                `"action`": {`n                    `"button`": `"Choose Service`",`n                    `"sections`": [`n                        {`n                            `"title`": `"SMS Messaging`",`n                            `"rows`": [`n                                {`n                                    `"id`": `"1`",`n                                    `"title`": `"Normal SMS`",`n                                    `"description`": `"Signup for free at the D7 platform to use our Messaging APIs.`"`n                                },`n                                {`n                                    `"id`": `"2`",`n                                    `"title`": `"Verify`",`n                                    `"description`": `"D7 Verify API is to applications requires SMS based OTP authentications.`"`n                                }`n                            ]`n                        },`n                        {`n                            `"title`": `"Whatsapp`",`n                            `"rows`": [`n                                {`n                                    `"id`": `"3`",`n                                    `"title`": `"WhatsApp Messages`",`n                                    `"description`": `"D7 Whatsapp API is to applications requires pre-registration.`"`n                                }`n                            ]`n                        }`n                    ]`n                }`n            }`n            },`n            `"recipients`": [{`n                `"recipient`": `"+9715xx6xx543`",`n                `"recipient_type`": `"individual`"`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["Authorization"] = "Bearer {{api_access_token}}"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "messages": [
    {
      "originator": "91xx615xx5x4",
      "content": {
        "preview_url": false,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "list",
          "header": {
            "type": "text",
            "text": "Direct7 Networks"
          },
          "body": {
            "text": "Choose one of our service"
          },
          "footer": {
            "text": "Thank you"
          },
          "action": {
            "button": "Choose Service",
            "sections": [
              {
                "title": "SMS Messaging",
                "rows": [
                  {
                    "id": "1",
                    "title": "Normal SMS",
                    "description": "Signup for free at the D7 platform to use our Messaging APIs."
                  },
                  {
                    "id": "2",
                    "title": "Verify",
                    "description": "D7 Verify API is to applications requires SMS based OTP authentications."
                  }
                ]
              },
              {
                "title": "Whatsapp",
                "rows": [
                  {
                    "id": "3",
                    "title": "WhatsApp Messages",
                    "description": "D7 Whatsapp API is to applications requires pre-registration."
                  }
                ]
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx543",
          "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
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\": \"91xx615xx5x4\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"INTERACTIVE\",\n            \"interactive\": {\n                \"type\": \"list\",\n                \"header\": {\n                    \"type\": \"text\",\n                    \"text\": \"Direct7 Networks\"\n                },\n                \"body\": {\n                    \"text\": \"Choose one of our service\"\n                },\n                \"footer\": {\n                    \"text\": \"Thank you\"\n                },\n                \"action\": {\n                    \"button\": \"Choose Service\",\n                    \"sections\": [\n                        {\n                            \"title\": \"SMS Messaging\",\n                            \"rows\": [\n                                {\n                                    \"id\": \"1\",\n                                    \"title\": \"Normal SMS\",\n                                    \"description\": \"Signup for free at the D7 platform to use our Messaging APIs.\"\n                                },\n                                {\n                                    \"id\": \"2\",\n                                    \"title\": \"Verify\",\n                                    \"description\": \"D7 Verify API is to applications requires SMS based OTP authentications.\"\n                                }\n                            ]\n                        },\n                        {\n                            \"title\": \"Whatsapp\",\n                            \"rows\": [\n                                {\n                                    \"id\": \"3\",\n                                    \"title\": \"WhatsApp Messages\",\n                                    \"description\": \"D7 Whatsapp API is to applications requires pre-registration.\"\n                                }\n                            ]\n                        }\n                    ]\n                }\n            }\n            },\n            \"recipients\": [{\n                \"recipient\": \"+9715xx6xx543\",\n                \"recipient_type\": \"individual\"\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());

9. Message Type Interactive with action button

    curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
    --header 'Authorization: Bearer {{api_access_token}}' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "messages": [
            {
                "originator": "919xx15xxx74",
                "content": {
                    "preview_url": false,
                    "message_type": "INTERACTIVE",
                "interactive": {
                    "type": "button",
                    "header": {
                        "type": "text",
                        "text": "Payment$ for D7 Whatsapp Service"
                    },
                    "body": {
                        "text": "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers."
                    },
                    "footer": {
                        "text": "Thank You"
                    },
                    "action": {
                        "buttons": [
                            {
                                "type": "reply",
                                "reply": {
                                    "id": "1",
                                    "title": "Debit Card"
                                }
                            },
                            {
                                "type": "reply",
                                "reply": {
                                    "id": "2",
                                    "title": "Credit Card"
                                }
                            },
                                                    {
                                "type": "reply",
                                "reply": {
                                    "id": "3",
                                    "title": "Cash"
                                }
                            }
                        ]
                    }
                }
                },
                "recipients": [{
                    "recipient": "+9715xx6xx5x3",
                    "recipient_type": "individual"
                }],
                "report_url": "https://the_url_to_recieve_delivery_report.com"
            }
        ]
    }'
var axios = require('axios');
var data = JSON.stringify({
  "messages": [
    {
      "originator": "919xx15xxx74",
      "content": {
        "preview_url": false,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "button",
          "header": {
            "type": "text",
            "text": "Payment$ for D7 Whatsapp Service"
          },
          "body": {
            "text": "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers."
          },
          "footer": {
            "text": "Thank You"
          },
          "action": {
            "buttons": [
              {
                "type": "reply",
                "reply": {
                  "id": "1",
                  "title": "Debit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "2",
                  "title": "Credit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "3",
                  "title": "Cash"
                }
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx5x3",
          "recipient_type": "individual"
        }
      ],
      "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
  ]
});

var config = {
  method: 'post',
  url: 'https://api.d7networks.com/whatsapp/v2/send',
  headers: {
    'Authorization': 'Bearer {{api_access_token}}',
    'Content-Type': 'application/json'
  },
  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": "919xx15xxx74",
      "content": {
        "preview_url": False,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "button",
          "header": {
            "type": "text",
            "text": "Payment$ for D7 Whatsapp Service"
          },
          "body": {
            "text": "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers."
          },
          "footer": {
            "text": "Thank You"
          },
          "action": {
            "buttons": [
              {
                "type": "reply",
                "reply": {
                  "id": "1",
                  "title": "Debit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "2",
                  "title": "Credit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "3",
                  "title": "Cash"
                }
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx5x3",
          "recipient_type": "individual"
        }
      ],
      "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
  ]
})
headers = {
  'Authorization': 'Bearer {{api_access_token}}',
  'Content-Type': 'application/json'
}

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
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$header = array("type"=> "text","text"=> "Payment$ for D7 Whatsapp Service")
$button1 =   array("type"=> "reply", "reply"=> [array("id"=> "1", "title"=> "Debit Card")])
$button2 =   array("type"=> "reply", "reply"=> [array("id"=> "2", "title"=> "Credit Card")])
$button3 =   array("type"=> "reply", "reply"=> [array("id"=> "3", "title"=> "Cash")])
$interactive = array("type"=> "button",
            "header"=> $header,
            "body"=> array("text"=> "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers."),
            "footer"=> array("text"=> "Thank you"),
            "action"=> array("buttons"=> [$button1, $button2, $button3])
            )
$content = array(
    "message_type"=> "INTERACTIVE",
    "interactive"=> $interactive
); // 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": "919xx15xxx74",
            "content": {
                "preview_url": false,
                "message_type": "INTERACTIVE",
            "interactive": {
                "type": "button",
                "header": {
                    "type": "text",
                    "text": "Payment$ for D7 Whatsapp Service"
                },
                "body": {
                    "text": "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers."
                },
                "footer": {
                    "text": "Thank You"
                },
                "action": {
                    "buttons": [
                        {
                            "type": "reply",
                            "reply": {
                                "id": "1",
                                "title": "Debit Card"
                            }
                        },
                        {
                            "type": "reply",
                            "reply": {
                                "id": "2",
                                "title": "Credit Card"
                            }
                        },
                                                {
                            "type": "reply",
                            "reply": {
                                "id": "3",
                                "title": "Cash"
                            }
                        }
                    ]
                }
            }
            },
            "recipients": [{
                "recipient": "+9715xx6xx5x3",
                "recipient_type": "individual"
            }],
            "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("Authorization", "Bearer {{api_access_token}}")
  req.Header.Add("Content-Type", "application/json")

  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\": \"919xx15xxx74\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"INTERACTIVE\",\n            \"interactive\": {\n                \"type\": \"button\",\n                \"header\": {\n                    \"type\": \"text\",\n                    \"text\": \"Payment$ for D7 Whatsapp Service\"\n                },\n                \"body\": {\n                    \"text\": \"Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.\"\n                },\n                \"footer\": {\n                    \"text\": \"Thank You\"\n                },\n                \"action\": {\n                    \"buttons\": [\n                        {\n                            \"type\": \"reply\",\n                            \"reply\": {\n                                \"id\": \"1\",\n                                \"title\": \"Debit Card\"\n                            }\n                        },\n                        {\n                            \"type\": \"reply\",\n                            \"reply\": {\n                                \"id\": \"2\",\n                                \"title\": \"Credit Card\"\n                            }\n                        },\n                                                {\n                            \"type\": \"reply\",\n                            \"reply\": {\n                                \"id\": \"3\",\n                                \"title\": \"Cash\"\n                            }\n                        }\n                    ]\n                }\n            }\n            },\n            \"recipients\": [{\n                \"recipient\": \"+9715xx6xx5x3\",\n                \"recipient_type\": \"individual\"\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("Authorization", "Bearer {{api_access_token}}")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
var headers = {
  'Authorization': 'Bearer {{api_access_token}}',
  'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
  "messages": [
    {
      "originator": "919xx15xxx74",
      "content": {
        "preview_url": false,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "button",
          "header": {
            "type": "text",
            "text": "Payment$ for D7 Whatsapp Service"
          },
          "body": {
            "text": "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers."
          },
          "footer": {
            "text": "Thank You"
          },
          "action": {
            "buttons": [
              {
                "type": "reply",
                "reply": {
                  "id": "1",
                  "title": "Debit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "2",
                  "title": "Credit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "3",
                  "title": "Cash"
                }
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx5x3",
          "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);
}
1
2
3
4
5
6
7
8
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer {{api_access_token}}")
$headers.Add("Content-Type", "application/json")

$body = "{`n    `"messages`": [`n        {`n            `"originator`": `"919xx15xxx74`",`n            `"content`": {`n                `"preview_url`": false,`n                `"message_type`": `"INTERACTIVE`",`n            `"interactive`": {`n                `"type`": `"button`",`n                `"header`": {`n                    `"type`": `"text`",`n                    `"text`": `"Payment`$ for D7 Whatsapp Service`"`n                },`n                `"body`": {`n                    `"text`": `"Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.`"`n                },`n                `"footer`": {`n                    `"text`": `"Thank You`"`n                },`n                `"action`": {`n                    `"buttons`": [`n                        {`n                            `"type`": `"reply`",`n                            `"reply`": {`n                                `"id`": `"1`",`n                                `"title`": `"Debit Card`"`n                            }`n                        },`n                        {`n                            `"type`": `"reply`",`n                            `"reply`": {`n                                `"id`": `"2`",`n                                `"title`": `"Credit Card`"`n                            }`n                        },`n                                                {`n                            `"type`": `"reply`",`n                            `"reply`": {`n                                `"id`": `"3`",`n                                `"title`": `"Cash`"`n                            }`n                        }`n                    ]`n                }`n            }`n            },`n            `"recipients`": [{`n                `"recipient`": `"+9715xx6xx5x3`",`n                `"recipient_type`": `"individual`"`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["Authorization"] = "Bearer {{api_access_token}}"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "messages": [
    {
      "originator": "919xx15xxx74",
      "content": {
        "preview_url": false,
        "message_type": "INTERACTIVE",
        "interactive": {
          "type": "button",
          "header": {
            "type": "text",
            "text": "Payment$ for D7 Whatsapp Service"
          },
          "body": {
            "text": "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers."
          },
          "footer": {
            "text": "Thank You"
          },
          "action": {
            "buttons": [
              {
                "type": "reply",
                "reply": {
                  "id": "1",
                  "title": "Debit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "2",
                  "title": "Credit Card"
                }
              },
              {
                "type": "reply",
                "reply": {
                  "id": "3",
                  "title": "Cash"
                }
              }
            ]
          }
        }
      },
      "recipients": [
        {
          "recipient": "+9715xx6xx5x3",
          "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
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\": \"919xx15xxx74\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"INTERACTIVE\",\n            \"interactive\": {\n                \"type\": \"button\",\n                \"header\": {\n                    \"type\": \"text\",\n                    \"text\": \"Payment$ for D7 Whatsapp Service\"\n                },\n                \"body\": {\n                    \"text\": \"Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.\"\n                },\n                \"footer\": {\n                    \"text\": \"Thank You\"\n                },\n                \"action\": {\n                    \"buttons\": [\n                        {\n                            \"type\": \"reply\",\n                            \"reply\": {\n                                \"id\": \"1\",\n                                \"title\": \"Debit Card\"\n                            }\n                        },\n                        {\n                            \"type\": \"reply\",\n                            \"reply\": {\n                                \"id\": \"2\",\n                                \"title\": \"Credit Card\"\n                            }\n                        },\n                                                {\n                            \"type\": \"reply\",\n                            \"reply\": {\n                                \"id\": \"3\",\n                                \"title\": \"Cash\"\n                            }\n                        }\n                    ]\n                }\n            }\n            },\n            \"recipients\": [{\n                \"recipient\": \"+9715xx6xx5x3\",\n                \"recipient_type\": \"individual\"\n            }],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

One to Many Message

1. Message type Template without media and buttons

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language": "{{template_language}}",
                    "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": "{{template_language}}",
                    "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": "{{template_language}}",
                    "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}}
$language = {{template_language}}
$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,
    "language"=> $language,
); // 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": "{{template_language}}",
                    "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