D7 WhatsApp

FREE
By Direct7 Networks | Updated 한 달 전 | Communication
Health Check

N/A

README

Get Started with D7 Whatsapp Messaging API:

  • [Signup here] (https://app.d7networks.com/signup) on the D7 platform to gain access to our Messaging APIs.
  • Upon completion of the verification process, your D7 account will be activated.
  • Navigate to the “Getting Started” page, specifically the WhatsApp section, and click the “Show Interest” button here.
  • Our team will reach out to you to assist in registering your business with WhatsApp.
  • Once registration is successful, a new template will be provided for testing the WhatsApp Messaging API.
  • To test the API, utilize the “Integrate API” section on the “Getting Started” page here.
  • Additionally, you have the option to create your own template, which can be used once approved by WhatsApp.

Features

With the D7 Whatsapp Messages API, you have the capability to:

  • Facilitate the sending and receiving of Whatsapp Messages.
  • Receive HTTP callbacks to obtain delivery notifications (receipts) when Whatsapp Messages are received, or when delivery is not successful.
  • Verify the status of messages through a dedicated endpoint.
  • Create your own Whatsapp template based on your message content.
  • Implement user-defined HTTP callbacks triggered by specific events. These events are categorized into two types:
    Delivery events: Providing status updates on the message sent to the WhatsApp channel, including Queued, Sent, Delivered, Read, or Dropped, among others.
    User-initiated events: Covering messages initiated by users to the brand, such as text, images, or documents.

Getting Started Guidelines

Prior to commencing, please be aware that WhatsApp mandates the templating and pre-registration of business-initiated Notifications from your application. This requirement excludes messages sent in response to user-initiated messages. Consequently, you must register your business account and generate a valid template.

  1. Complete the signup process. Visit the Getting Started section on WhatsApp, and follow the outlined steps. Upon expressing interest, our team will reach out to guide you through the setup of your business account and the registration of your number on the WhatsApp Business account.

  2. Upon successful onboarding, you will receive a demonstration template to test messages from your registered number. Furthermore, you have the option to create additional templates here.

Note: Please be informed that, for testing purposes, we exclusively support template-type messages.

API Supported Features

This API encompasses three distinct open conversation types within the WhatsApp platform:

  1. Marketing: Engage in promotional activities, offer informational updates, or extend invitations for customers to respond or take specific actions.

  2. Utility: Facilitate specific, agreed-upon requests or transactions, and provide updates to customers regarding ongoing transactions. This may include transaction confirmations, updates, and post-purchase notifications.

  3. Service: Resolve customer inquiries efficiently through service conversations.

The API provides support for:

Sending messages in various formats, including One-to-One, Many-to-Many, and One-to-Many to WhatsApp users.
Content compatibility for Text, Image, Audio, Video, Sticker, Document, with or without interactive elements such as buttons (Quick Reply & Calls to Action).
Location sharing functionality.
Contact information exchange.

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 userinitiated message.

POST
/whatsapp/v1/send

!!! Authentication
AUTHORIZATION: Bearer Token

Request parameters

Parameter Value / Pattern
*originator The Phone number of Sender/Header of a message. We can use your mobile number that is registered and approved.
*recipients Mobile Numbers to send Whatsapp seperated by comma in an array. The recipient’s phone number should have a country code prefix.
*content Details of the content object.
report_url 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. For information on the format of the DLR message, please refer to the “Receiving DLR” section.

Content object

Parameter Value / Pattern
preview_url Allows for URL previews in text messages. By default, the mobile WhatsApp application recognizes URLs and makes them clickable. Values: false (default), true.
*message_type Type of the message inside the content. Valid values: TEXT, ATTACHMENT, LOCATION, CONTACTS, TEMPLATE.
*message_text Text content users want to send, which can contain URLs and formatting. This field is reqiured if the message type is TEXT.
*attachment Details of the attachment object. This field is reqiured if the message type is ATTACHMENT.
*location Details of the location object. This field is reqiured if the message type is LOCATION.
*contact Details of the contact object. This field is reqiured if the message type is CONTACTS.
*interactive Details of the interactive object. This field is reqiured if the message type is INTERACTIVE.
*template Details of the template object. This field is reqiured if the message type is TEMPLATE.

Attachment object

Parameter Value / Pattern
*attachment_type Type of the attachment you want to send. You can send: image, audio, document, video.
*attachment_url URL for the attachment. The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URL.
attachment_caption Caption for the attachment.
attachment_mime_type You can send attachments without using a URL by specifying the MIME type and attachment data. For images: image/png and image/jpeg, for documents: application/pdf, and for audio: audio/mpeg and audio/wav are supported.
attachment_data String contains attachment binary data of Base64 encoded.

Location object

Parameter Value / Pattern
*longitude Longitude of the Location you wants to send.
*latitude Longitude of the Location you wants to send.
name Name of the Location you wants to send.
address Address of the Location you wants to send. Only displayed if the name is present.

Contact Object

Parameter Value / Pattern
*first_name First name of the contact you wants to send.
*last_name Last name of the contact you wants to send.
display_name Display the name of the contact you wants to send.
*phone Phone nnumber of the contact you wants to send.
email Email ID of the contact you wants to send.
url URL for the contact you wants to send.

Interactive Object

Parameter Value / Pattern
*type The type of interactive message you want to send. Supported values: button, list
*body An object with the body of the message. The body object contains text field. Its required if body is present. The content of the message. Emojis and markdown are supported. Maximum length: 1024 characters.
footer Optional. An object with the footer of the message. 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 Optional. Header content displayed on top of a message.
*action Action you want the user to perform after reading the message.

Header Object

Parameter Value / Pattern
type 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 Required if type is set to document. Contains the media object for this document- filename, link.
image Required if type is set to image. Contains the media object for this image- link.
text Required if type is set to text. Text for the header. Formatting allows emojis, but not markdown. Maximum length: 60 characters.
video Required if type is set to video. Contains the media object for this video- link

Action Object - List

Parameter Value / Pattern
button 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 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 Value / Pattern
buttons 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.

Template object

Parameter Value / Pattern
*template_id Template ID configured for WhatsApp template (HSM). This should be registed and approved by D7. You can create a new Whatsapp Template here
*body_parameter_values The Object of the body parameter values. Only required if your body text have varibles.
*media Details of the media object.
*buttons Details of the button object.

Media object

Parameter Value / Pattern
*media_type Type of the attachment you want to send through your template. Valid: image, audio, document, video
*media_url URL for the attachment. Required except the media type is location.
media_caption Caption for the attachment.
document_file_name Describes the filename for the specific document. Only required if the media type is document
*text_header_title Message content if you have a header section in your message. It is only required if the media type is Text.
*location Details of the location object.
media_mime_type You can send attachments without using a URL by specifying the MIME type and attachment data. For images: image/png and image/jpeg, for documents: application/pdf, and for audio: audio/mpeg and audio/wav are supported.
media_attachment_data String contains attachment binary data of Base64 encoded.

Button object

Parameter Value / Pattern
*quick_replies List of quick_replies button object. This is required if you wants to add quick reply buttons in your message.
*actions Tist of actions button object. This is required if you wants to add call to action buttons in your message.

Quick Reply Button object

Parameter Value / Pattern
*button_index Position index of the button. Required if you have quick reply in your template.
*button_payload Developer-defined payload that will be returned when the button is clicked.

Call to Action Button object

Parameter Value / Pattern
*action_type Type of action that whats to do while clicking the button. It includes Dial and URL.
*action_index Position index of the button. Required if you have either url or dial button in your template.
*action_payload 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.

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 ```JSON { "request_id": "d9835609-a4e0-10ea-a26a-eeafbe700fef", "status": "accepted", "created_at": "2001-08-05T12:52:38.393Z" } ```
401 - Unauthorized ```JSON { "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 ```JSON { "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”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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}}",
            "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"
    }
]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
})
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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$template =  array(
    "template_id"=> $template_id,
    "body_parameter_values"=> $body_parameter_values
);
$content = array(
    "message_type"=> "TEMPLATE",
    "template"=> $template
); // Replace it with message content
$message_obj =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);

$payload = json_encode(
    array(
        "messages"=> array($message_obj)
    )
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

payload := strings.NewReader(`{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}`)

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"originator\": \"{{originator}}\",\n        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\":{\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n    }\n  ]\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/send'));
request.body = json.encode({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
});
request.headers.addAll(headers);

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

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}

```

=== “PowerShell”

```powershell linenums="1"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

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

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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}}",
            "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"
    }
]
})

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"originator\": \"{{originator}}\",\n        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\":{\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n    }\n  ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

2. Message type Template with media without buttons

=== “Curl”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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}}",
            "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"
    }
]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
})
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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$media = array(
    "media_type"=> "image"
    "media_url"=> "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
)
$template =  array(
    "template_id"=> $template_id,
    "media"=> $media
    "body_parameter_values"=> $body_parameter_values
);
$content = array(
    "message_type"=> "TEMPLATE",
    "template"=> $template
); // Replace it with message content
$message_obj =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);

$payload = json_encode(
    array(
        "messages"=> array($message_obj)
    )
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

payload := strings.NewReader(`{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
}`)

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/send'));
request.body = json.encode({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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);
}

```

=== “PowerShell”

```powershell linenums="1"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`\`n    `\`"messages`\`": [`\`n        {`\`n            `\`"originator`\`": `\`"{{originator}}`\`",`\`n            `\`"content`\`": {`\`n                `\`"message_type`\`": `\`"TEMPLATE`\`",`\`n                `\`"media_template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"media`\`": {`\`n                        `\`"media_type`\`": `\`"image`\`",`\`n                        `\`"media_url`\`": `\`"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`\`"`\`n                    },`\`n                    `\`"body_parameter_values`\`": {`\`n                        `\`"0`\`": `\`"first_parameter_in_your_template`\`",`\`n                        `\`"1`\`": `\`"second_parameter_in_your_template`\`"`\`n                    }`\`n                }`\`n            },`\`n            `\`"recipients`\`": [`\`n                {`\`n                    `\`"recipient`\`": [`\`n                        `\`"{{recipient1}}`\`",`\`n                        `\`"{{recipient2}}`\`"`\`n                    ]`\`n                }`\`n            ],`\`n            `\`"report_url`\`": `\`"https://the_url_to_recieve_delivery_report.com`\`"`\`n        }`\`n    ]`\`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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}}",
            "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"
    }
]
})

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

3. Message type Template with media and buttons

=== “Curl”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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}}",
            "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"
    }
]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
})
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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$media = array(
    "media_type"=> "image"
    "media_url"=> "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
)
$buttons = array(
    "quick_replies": [
                        {
                            "button_index": "0",
                            "button_payload": "ButtonText"
                        },
                        {
                            "button_index": "1",
                            "button_payload": "ButtonText"
                        }
                    ]
)
$template =  array(
    "template_id"=> $template_id,
    "media"=> $media
    "body_parameter_values"=> $body_parameter_values
    "buttons"=>$buttons
);
$content = array(
    "message_type"=> "TEMPLATE",
    "template"=> $template
); // Replace it with message content
$message_obj =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);

$payload = json_encode(
    array(
        "messages"=> array($message_obj)
    )
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

payload := strings.NewReader(`{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
}`)

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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"
    }
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"quick_replies\": [\n                            {\n                                \"button_index\": \"0\",\n                                \"button_payload\": \"ButtonText\"\n                            },\n                            {\n                                \"button_index\": \"1\",\n                                \"button_payload\": \"ButtonText\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/send'));
request.body = json.encode({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "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);
}

```

=== “PowerShell”

```powershell linenums="1"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n    `"messages`": [`n        {`n            `"originator`": `"{{originator}}`",`n            `"content`": {`n                `"message_type`": `"TEMPLATE`",`n                `"media_template`": {`n                    `"template_id`": `"{{template_id}}`",`n                    `"media`": {`n                        `"media_type`": `"image`",`n                        `"media_url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"`n                    },`n                    `"body_parameter_values`": {`n                        `"0`": `"first_parameter_in_your_template`",`n                        `"1`": `"second_parameter_in_your_template`"`n                    },`n                    `"buttons`": {`n                        `"quick_replies`": [`n                            {`n                                `"button_index`": `"0`",`n                                `"button_payload`": `"ButtonText`"`n                            },`n                            {`n                                `"button_index`": `"1`",`n                                `"button_payload`": `"ButtonText`"`n                            }`n                        ]`n                    }`n                }`n            },`n            `"recipients`": [`n                {`n                    `"recipient`": [`n                        `"{{recipient1}}`",`n                        `"{{recipient2}}`"`n                    ]`n                }`n            ],`n            `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n        }`n    ]`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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}}",
            "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

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"quick_replies\": [\n                            {\n                                \"button_index\": \"0\",\n                                \"button_payload\": \"ButtonText\"\n                            },\n                            {\n                                \"button_index\": \"1\",\n                                \"button_payload\": \"ButtonText\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

4. Message type Contact

=== “Curl”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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": "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"
    }
]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
"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"
    }
]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
"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"
    }
]
})
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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$contact =  array(
    "first_name": "FirstName",
    "last_name": "SecondName",
    "display_name": "DisplayName",
    "phone": "PhoneNumber",
    "email": "EmailAddress",
    "url": "Url"
);
$content = array(
    "message_type"=> "CONTACTS",
    "template"=> $contact
); // 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/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

payload := strings.NewReader(`{
"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"
    }
]
}`)

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
"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"
    }
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
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/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/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);
}

```

=== “PowerShell”

```powershell linenums="1"
$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/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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": "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"
    }
]
})

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/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”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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"
    }
]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
"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"
    }
]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
"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"
    }
]
})
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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$location =  array(
     "longitude": 77.1249,
    "latitude": 12.8779,
    "name": "NameOfLocation",
    "address": "AddressOfLocation"
);
$content = array(
    "message_type"=> "LOCATION",
    "location"=> $location
); // 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/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

payload := strings.NewReader(`{
"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"
    }
]
}`)

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
"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"
    }
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
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/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/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);
}

```

=== “PowerShell”

```powershell linenums="1"
$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/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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": "LOCATION",
        "location": {
                "longitude": 77.1249,
                "latitude": 12.8779,
                "name": "NameOfLocation",
                "address": "AddressOfLocation"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
})

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/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”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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": {
                "attachment_type":"video",
                "attachment_url": "AttachmnetUrl",
                "attachment_caption": "AttachmentCaption"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
                "attachment_type":"video",
                "attachment_url": "AttachmnetUrl",
                "attachment_caption": "AttachmentCaption"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
                "attachment_type":"video",
                "attachment_url": "AttachmnetUrl",
                "attachment_caption": "AttachmentCaption"
            }
    },
    "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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$attachment =  array(
    "attachment_type":"video",
    "attachment_url": "AttachmnetUrl",
    "attachment_caption": "AttachmentCaption"
);
$content = array(
    "message_type"=> "ATTACHMENT",
    "attachment"=> $attachment
); // 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/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

payload := strings.NewReader(`{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
                "attachment_type":"video",
                "attachment_url": "AttachmnetUrl",
                "attachment_caption": "AttachmentCaption"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}`)

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
                "attachment_type":"video",
                "attachment_url": "AttachmnetUrl",
                "attachment_caption": "AttachmentCaption"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
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                    \"attachment_type\":\"video\",\n                    \"attachment_url\": \"AttachmnetUrl\",\n                    \"attachment_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/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/send'));
request.body = json.encode({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
                "attachment_type":"video",
                "attachment_url": "AttachmnetUrl",
                "attachment_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);
}

```

=== “PowerShell”

```powershell linenums="1"
$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                    `"attachment_type`":`"video`",`n                    `"attachment_url`": `"AttachmnetUrl`",`n                    `"attachment_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/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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": "ATTACHMENT",
        "attachment": {
                "attachment_type":"video",
                "attachment_url": "AttachmnetUrl",
                "attachment_caption": "AttachmentCaption"
            }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
})

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/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                    \"attachment_type\":\"video\",\n                    \"attachment_url\": \"AttachmnetUrl\",\n                    \"attachment_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”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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",
        "message_text": "Hi, How can I help you?"
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEXT",
        "message_text": "Hi, How can I help you?"
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEXT",
        "message_text": "Hi, How can I help you?"
    },
    "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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({{recipient1}},{{recipient2}}); // Replace it with real recipients
$content = array(
    "message_type"=> "TEXT",
    "template"=> 'Hi, How can I help you?'
); // 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/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

payload := strings.NewReader(`{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEXT",
        "message_text": "Hi, How can I help you?"
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}`)

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEXT",
        "message_text": "Hi, How can I help you?"
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
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            \"message_text\": \"Hi, How can I help you?\"\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/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/send'));
request.body = json.encode({
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEXT",
        "message_text": "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);
}

```

=== “PowerShell”

```powershell linenums="1"
$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            `"message_text`": `"Hi, How can I help you?`"`n        },`n        `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n        }`n    ]`n    }"

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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": "TEXT",
        "message_text": "Hi, How can I help you?"
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
})

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/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            \"message_text\": \"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”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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"
        }
    ]
}'
```

=== “Node Js”

```shell linenums="1"
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/v1/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);
});
```

=== “Python”

```python linenums="1"
import requests
import json

url = "https://api.d7networks.com/whatsapp/v1/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”

```php linenums="1"
<?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/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

  url := "https://api.d7networks.com/whatsapp/v1/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))
}    
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
  "url": "https://api.d7networks.com/whatsapp/v1/send",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer {{api_access_token}}",
    "Content-Type": "application/json"
  },
  "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"
      }
    ]
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

=== “Java”

```java linenums="1"
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/v1/send")
  .method("POST", body)
  .addHeader("Authorization", "Bearer {{api_access_token}}")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();

```

=== “Dart”

``` dart linenums="1"
var headers = {
  'Authorization': 'Bearer {{api_access_token}}',
  'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v1/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);
}

```

=== “PowerShell”

```powershell linenums="1"
$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/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/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”

```shell linenums="1"
    curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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"
            }
        ]
    }'
```

=== “Node Js”

```shell linenums="1"
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/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

url = "https://api.d7networks.com/whatsapp/v1/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”

```php linenums="1"
<?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/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

  url := "https://api.d7networks.com/whatsapp/v1/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))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
  "url": "https://api.d7networks.com/whatsapp/v1/send",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer {{api_access_token}}",
    "Content-Type": "application/json"
  },
  "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"
      }
    ]
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

=== “Java”

```java linenums="1"
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/v1/send")
  .method("POST", body)
  .addHeader("Authorization", "Bearer {{api_access_token}}")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
```

=== “Dart”

``` dart linenums="1"
var headers = {
  'Authorization': 'Bearer {{api_access_token}}',
  'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v1/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);
}

```

=== “PowerShell”

```powershell linenums="1"
$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/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/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

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/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”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/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}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

payload = json.dumps({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "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”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$template =  array(
    "template_id"=> $template_id,
    "body_parameter_values"=> $body_parameter_values
);
$content = array(
    "message_type"=> "TEMPLATE",
    "template"=> $template
); // Replace it with message content
$message_obj =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);

$payload = json_encode(
    array(
        "messages"=> array($message_obj)
    )
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

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

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n        \"messages\": [\n            {\n                \"originator\": \"{{originator}}\",\n                \"content\": {\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/send'));
request.body = json.encode({
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "SomeMessageTag",
                        "conversationId": "ConversationId"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});
request.headers.addAll(headers);

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

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}

```

=== “PowerShell”

```powershell linenums="1"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

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

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

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

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

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

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n        \"messages\": [\n            {\n                \"originator\": \"{{originator}}\",\n                \"content\": {\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"SomeMessageTag\",\n                            \"conversationId\": \"ConversationId\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

Many to Many Message

1. Message type Template without media and buttons

=== “Curl”

```shell linenums="1"
curl --location --request POST 'https://api.d7networks.com/whatsapp/v1/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gamil.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');
var data = JSON.stringify({
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gamil.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/whatsapp/v1/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);
});

```

=== “Python”

```python linenums="1"
import requests
import json

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

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

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

print(response.text)

```

=== “PHP”

```php linenums="1"
<?php
$curl = curl_init();
$token = {{api_access_token}}; // Replace it with your API Token
$originator = {{originator}}; // Replace it with your Sender ID
$template_id = {{template_id}}
$recipients = array({
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gamil.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }); // Replace it with real recipients
$body_parameter_values = array("0": "first_parameter_in_your_template","1": "second_parameter_in_your_template")
$template =  array(
    "template_id"=> $template_id,
    "body_parameter_values"=> $body_parameter_values
);
$content = array(
    "message_type"=> "TEMPLATE",
    "template"=> $template
); // Replace it with message content
$message_obj1 =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);
$message_obj2 =  array(
    "originator"=> $originator,
    "recipients"=> $recipients,
    "content"=> $content,
    "report_url"=> "https://the_url_to_recieve_delivery_report.com"
);

$payload = json_encode(
    array(
        "messages"=> array($message_obj1, $message_obj2)
    )
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v1/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
?>

```

=== “Go”

``` go linenums="1"
package main

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

func main() {

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

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

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

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

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gamil.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"messages\": [\n            {\n                \"originator\": \"{{originator1}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gamil.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            },\n            {\n                \"originator\": \"{{originator2}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v1/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();

```

=== “Dart”

``` dart linenums="1"
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/v1/send'));
request.body = json.encode({
    "messages": [
        {
            "originator": "{{originator1}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gamil.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        },
        {
            "originator": "{{originator2}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    }
                }
            },
            "recipients": [
                {
                    "recipient": "{{recipient1}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                },
                {
                    "recipient": "{{recipient2}}",
                    "recipient_type": "individual",
                    "reference": {
                        "cust_ref": "cust_ref@gmail.com",
                        "messageTag1": "d7id00001",
                        "conversationId": "d7id00001"
                    }
                }
            ],
            "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
});
request.headers.addAll(headers);

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

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}

```

=== “PowerShell”

```powershell linenums="1"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

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

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "json"
require "net/http"

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

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

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

response = https.request(request)
puts response.read_body

```

=== “C#”

```C# linenums="1"
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n        \"messages\": [\n            {\n                \"originator\": \"{{originator1}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gamil.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            },\n            {\n                \"originator\": \"{{originator2}}\",\n                \"content\": {\n                    \"preview_url\": false,\n                    \"message_type\": \"TEMPLATE\",\n                    \"template\": {\n                        \"template_id\": \"{{template_id}}\",\n                        \"body_parameter_values\": {\n                            \"0\": \"first_parameter_in_your_template\",\n                            \"1\": \"second_parameter_in_your_template\"\n                        }\n                    }\n                },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    },\n                    {\n                        \"recipient\": \"{{recipient2}}\",\n                        \"recipient_type\": \"individual\",\n                        \"reference\": {\n                            \"cust_ref\": \"cust_ref@gmail.com\",\n                            \"messageTag1\": \"d7id00001\",\n                            \"conversationId\": \"d7id00001\"\n                        }\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            }\n        ]\n    }", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```

title: Receiving Whatsapp DLR | Direct7 Networks

Receiving Whatsapp DLR

Configure Report URL

In order to receive message status reports via a URL, two options are available.

  1. You should include Report URL in the message body parameter report_url.
{
    "messages": [
        {
            "originator": "{{originator}}",
            "originator_name": "originator_name",
            "recipients": ["{{recipient1}}","{{recipient2}}"],
            "content": {
            "message_type": "TEMPLATE",
            "template": {
                "template_id": "{{template_id}}",
                "body_parameter_values": {
                    "0": "first_parameter_in_your_template",
                    "1": "second_parameter_in_your_template"
                }
            }
        },
        "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
    ]
    }
  1. Set Callback URL in dashboard settings
    Image title{ align=left }

Additionally, it’s important to note that this status postback is sent as json in the POST method.

Delivery Events

Receiving Attributes

On the configured URL, you will receive the following details:

Parameter Value / Pattern Example(s)
channel Messaging channel Whatsapp
event_type Type of the callback data. It includes DELIVERY_EVENTS DELIVERY_EVENTS
timestamp The time in which the event occurred 1695645887348
date The date in which the event occurred 2023-September-25
request_id Request identification number d9835609-a4e0-10ea-a26a-eeafbe700fef
msg_id The message id for each messages in the request 7053a678-75fe-11ed-9e31-0242ac14001c
conversation_type Type of your conversation. It includes marketing, service, utility marketing
message_type Type of the message inside the content. Valid values: TEXT, ATTACHMENT, LOCATION, CONTACTS, TEMPLATE. TEMPLATE
waConvId whatsapp conversation id db311b5709a13ac72c1bd9f293c68625
recipient Destination numbers +971509752xxx
cust_ref A unique id send by the customer for every message
message_tag1-message_tag5 To Specify the message tag
conversation_id Some Optional Conversation ID
originator Sender/Header numbers +971509752xxx
status This is the status of the message, and we have the following statuses: [delivered - Delivered to destination and confirmed], [sent - Was sent to telecom and is awaiting acknowledgement], [scheduled - Message scheduled], [un_delivered - Failed delivery], [processed - message is processed], [rejected - Rejected the message], [insufficient_credit - User does not have enough credit], [read - Read by the user] read
reason Description of your status Read by the user

Example

{
  "channel": "whatsapp",
  "event": {
    "event_type": "DELIVERY_EVENTS",
    "timestamp": "1695711356760",
    "date": "2023-September-26"
  },
  "event_content": {
    "message_status": {
      "request_id": "ca40e2bd-640d-4dd6-bd88-513f316ee2e0",
      "msg_id": "ba7eb2f2-5c39-11ee-a0b5-0242ac190005",
      "conversation_type": "service",
      "message_type": "INTERACTIVE",
      "waConvId": "13c2eb731df8097d20a5141b9612be7e",
      "recipient": "+971xx96xx5x3",
      "reference": {
        "cust_ref": "whatsapp_demo@d7networks.com",
        "message_tag1": null,
        "message_tag2": null,
        "message_tag3": null,
        "message_tag4": null,
        "message_tag5": null,
        "conversation_id": null
      },
      "originator": "9190xx52xxx4",
      "status": "read",
      "reason": "Read by the user"
    }
  }
}

User Initiated

Receiving Attributes

On the configured URL, you will receive the following details:

Parameter Value / Pattern Example(s)
channel Messaging channel Whatsapp
event_type Type of the callback data. It includes USER_INITIATED DELIVERY_EVENTS
timestamp The time in which the event occurred 1695645887348
date The date in which the event occurred 2023-September-25
recipient Destination numbers +971509752xxx
originator Sender number +971509752xxx
message_type Type of the message inside the content. Valid values: TEXT, ATTACHMENT, LOCATION, CONTACTS, INTERACTIVE. INTERACTIVE
profile_name Whatsapp profile name of sender SMT
text body of whatsapp text message Hi
attachment_type Type of attachment inside the content. Valid values: image, video, sticker, document image
image Image details include caption, mime_type, sha256 and fileLink
video Video details include caption, mime_type, sha256 and fileLink
document Document details include filename, mime_type, sha256 and fileLink
contact List of Contact details include emails, name, org, phones and urls
image Image details includes caption, mime_type, sha256 and fileLink
location Location details includes latitude, longitude

Example

{
  "channel": "whatsapp",
  "event": {
    "event_type": "USER_INITIATED",
    "timestamp": "1695625167",
    "date": "2023-September-25"
  },
  "event_content": {
    "message": {
      "originator": "9715xxxx8xx3",
      "recipient": "919xx1xxx5x4",
      "message_type": "TEXT",
      "profile_name": "SMT",
      "text": {
        "body": "Hi"
      }
    }
  }
}

title: Know the status of whatsapp message you sent | D7 Networks
description: Get the status of whatsapp message you send

Get Status

The status of the whatsapp message can be requested by specifying the request_id that was returned from Send Message endpoint.

GET
/whatsapp/v1/report/{request_id}

!!! Authentication
AUTHORIZATIONS: Bearer Token

Request parameters

Parameter Value / Pattern Example(s)
*request_id request_id that was returned from Send Message endpoint ceba9fac-838c-44c7-b67d-03a4a6352058

Request

=== “Curl”

```shell linenums="1"
curl --location -g --request GET 'https://api.d7networks.com/whatsapp/v1/report/{{request_id}}' \
--header 'Authorization: Bearer {{api_access_token}}'
```

=== “Node.Js”

```js linenums="1"
var axios = require('axios');

var config = {
method: 'get',
url: 'https://api.d7networks.com/whatsapp/v1/report/{{request_id}}',
headers: { 
    'Authorization': 'Bearer {{api_access_token}}'
}
};

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

```

=== “Python”

```python linenums="1"
    import requests

    url = "https://api.d7networks.com/whatsapp/v1/report/{{request_id}}"

    payload={}
    headers = {
    'Authorization': 'Bearer {{api_access_token}}'
    }

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

    print(response.text)

```

=== “PHP”

```php linenums="1"
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/whatsapp/v1/report/{{request_id}}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer {{api_access_token}}'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

=== “Go”

``` go linenums="1" 
package main

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

func main() {

url := "https://api.d7networks.com/whatsapp/v1/report/{{request_id}}"
method := "GET"

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

if err != nil {
    fmt.Println(err)
    return
}
req.Header.Add("Authorization", "Bearer {{api_access_token}}")

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

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
```  

=== “JavaScript”

```javascript linenums="1"
var settings = {
"url": "https://api.d7networks.com/whatsapp/v1/report/{{request_id}}",
"method": "GET",
"timeout": 0,
"headers": {
    "Authorization": "Bearer {{api_access_token}}"
},
};

$.ajax(settings).done(function (response) {
console.log(response);
});
```

=== “Java”

```java linenums="1"
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v1/report/{{request_id}}")
.method("GET", body)
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
```

=== “Dart”

``` dart linenums="1" 
var headers = {
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('GET', Uri.parse('https://api.d7networks.com/whatsapp/v1/report/{{request_id}}'));

request.headers.addAll(headers);

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

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}

```

=== “PowerShell”

```powershell linenums="1"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v1/report/{{request_id}}' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```

=== “Ruby”

```ruby linenums="1"
require "uri"
require "net/http"

url = URI("https://api.d7networks.com/whatsapp/v1/report/{{request_id}}")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer {{api_access_token}}"

response = https.request(request)
puts response.read_body

```

Response:

200 - Success ```JSON { "request_id": "f44e3f43-6d4e-4e46-becd-21993f3dcb8e", "messages": [ { "msg_id": "6d29d646-4e09-11ee-84f4-0242ac190006", "originator": "9190615xxxx", "recipient": "+9190617xxxx", "reference": { "cust_ref": "customerRef", "message_tag1": "...", "message_tag2": "...", "message_tag3": "...", "message_tag4": "...", "message_tag5": "...", "conversation_id": "..." }, "conversation_type": "marketing", "message_type": "TEMPLATE", "template_id": "marketing", "waConvId": "db311b5709a13ac72c1bd9f293c68625", "status": "read", "reason": "Read by the user" } ], "request_stage": "processed", "schedule_time": null } ```
404 - Not Found ```JSON { "detail": { "code": "WHATSAPP_LOG_NOT_EXISTS", "message": "Given whatsapp message request id not exists in the system. Please Try Again!" } } ```

Response Parameters

Parameter Value / Pattern Example(s)
msg_id The message id for each message in the request 5c8d9ed8-590b-11ed-93d2-0242ac140018
originator Sender/Header numbers +971509752655
recipient Destination numbers +971509752655
cust_ref A unique id send by the customer for every message
message_tag1-message_tag5 To Specify the message tag
conversation_id Some Optional Conversation ID
conversation_type Type of your conversation. It includes marketing, service, utility marketing
message_type Type of the message inside the content. Valid values: TEXT, ATTACHMENT, LOCATION, CONTACTS, TEMPLATE. TEMPLATE
template_id ID of your template marketing
waConvId whatsapp conversation id db311b5709a13ac72c1bd9f293c68625
reason Description of your status Read by the user
status This is the status of the message, and we have the following statuses: [delivered - Delivered to destination and confirmed], [sent - Was sent to telecom and is awaiting acknowledgement], [scheduled - Message scheduled], [un_delivered - Failed delivery], [processed - message is processed], [rejected - Rejected the message], [insufficient_credit - User does not have enough credit], [read - Read by the user] read
Followers: 0
Resources:
Product Website Terms of use
API Creator:
Rapid account: Direct 7 Networks
Direct7 Networks
direct7-networks
Log In to Rate API
Rating: 1 - Votes: 1