Skip to content

Whatsapp Media Messages

Media messages are the messages that include media content such as images, videos, documents, audio or sticker files.

Media Type

Image messages are messages that display a single image and an optional caption.

Image Alt Text

Image objects:

Parameter Type Description Value / Pattern
*type String Type of the attachment you want to send. For Image messages its image image
*url String URL for the image. The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URL. Supported image formates: .jpeg, .png, .webp with max size 5MB https://www.luckyshrub.com/assets/succulents/aloe.png.
caption String Caption for the image. The best succulent ever?
"attachment": {
                  "type": "image",
                  "caption": "Natural Beauty",
                  "url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
              }

Images must be 8-bit, RGB or RGBA.

Video Type Extension Max Size
3GPP .3gp 16 MB
MP4 Video .mp4 16 MB

Programing Examples:

curl --location 'https://apialpha.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc' \
--data '{
    "messages": [
        {
            "originator": "{registered phone_number}",
            "content": {
                "message_type": "ATTACHMENT",
                "attachment": {
                    "type": "image",
                    "caption": "Natural Beauty",
                    "url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                }
            },
            "recipients": [
                {
                    "recipient": "{recipient}",
                    "recipient_type": "individual"
                }
            ],
            "report_url": "https://webhook.site/4235f691-13ab-448e-b100-74a3a627927f"
        }
    ]
}'
npm i direct7
1
2
3
4
5
6
7
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({originator: "{registered_phonenumber}", recipients: [{"recipient": "{recipient}", "recipient_type": "individual"}],message_type: "ATTACHMENT", type: "image", url: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg", caption: "Natural Beauty"});

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

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

client.whatsapp.send_whatsapp_freeform_message(originator="{registered phone_number}", recipients=[{"recipient": "{recipient}", "recipient_type": "individual"}], message_type="ATTACHMENT", type="image", url="https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg" ,caption="Natural Beauty")

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

use direct7\Direct7\Client;

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

$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(
    originator:"{registered_phonenumber}", 
    recipients:[["recipient" => "{recipient}", "recipient_type" => "individual"]], 
    message_type:"ATTACHMENT", 
    type: "image", 
    url: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
    caption:"Natural Beauty"
);
var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
whatsapp := direct7.NewWhatsApp(client)
originator := "{registered_phonenumber}"
recipients := []map[string]string{
    "recipient": "{recipient}",
    "recipient_type": "individual",
}
messageType := "ATTACHMENT"
optParams := &OptionalParams{
    attachmentType:"image",
    url: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
    caption: "Natural Beauty",
}
response, err := whatsapp.SendWhatsAppFreeformMessage(originator, recipients, messageType, optParams)
  OkHttpClient client = new OkHttpClient().newBuilder().build();
  MediaType mediaType = MediaType.parse("application/json");
  RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"image\",\n                    \"caption\": \"Natural Beauty\",\n                    \"url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\"\n                }\n            ],\n            \"report_url\": \"https://webhook.site/4235f691-13ab-448e-b100-74a3a627927f\"\n        }\n    ]\n}");
  Request request = new Request.Builder()
  .url("https://apialpha.d7networks.com/whatsapp/v2/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc")
  .build();
  Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc'
};
var request = http.Request('POST', Uri.parse('https://apialpha.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
"messages": [
{
"originator": "{registered phone_number}",
"content": {
"message_type": "ATTACHMENT",
"attachment": {
"type": "image",
"caption": "Natural Beauty",
"url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
}
},
"recipients": [
{
"recipient": "{recipient}",
"recipient_type": "individual"
}
],
"report_url": "https://webhook.site/4235f691-13ab-448e-b100-74a3a627927f"
}
]
});
request.headers.addAll(headers);

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

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

$body = @"
{
`"messages`": [
{
`"originator`": `"{registered phone_number}`",
`"content`": {
`"message_type`": `"ATTACHMENT`",
`"attachment`": {
`"type`": `"image`",
`"caption`": `"Natural Beauty`",
`"url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"
}
},
`"recipients`": [
{
`"recipient`": `"{recipient}`",
`"recipient_type`": `"individual`"
}
],
`"report_url`": `"https://webhook.site/4235f691-13ab-448e-b100-74a3a627927f`"
}
]
}
"@

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

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

client.whatsapp.send_whatsapp_freeform_message(
    originator='{originator}',
    recipients=[{'recipient' => '{recipient}', 'recipient_type' => 'individual'}],
    message_type='ATTACHMENT',
    body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, 
    type='image', 
    url='https://t4.ftcdn.net/jpg/01/43/23/83/360_F_143238306_lh0ap42wgot36y44WybfQpvsJB5A1CHc.jpg', 
    caption='Tet'
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://apialpha.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"image\",\n                    \"caption\": \"Natural Beauty\",\n                    \"url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\"\n                }\n            ],\n            \"report_url\": \"https://webhook.site/4235f691-13ab-448e-b100-74a3a627927f\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Video messages display a thumbnail preview of a video image with an optional caption. When the WhatsApp user taps the preview, it loads the video and displays it to the user.

Image Alt Text

Video objects

Parameter Type Description Value / Pattern
*type String Type of the attachment you want to send. For Video messages its video video
*url String URL for the video. The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URL. Supported image formates: .3gp, .mp4 with max size 16MB https://www.luckyshrub.com/assets/lucky-shrub-eclipse-viewing.mp4
caption String Caption for the video. The best succulent ever?
"attachment": {
                  "type": "image",
                  "caption": "Natural Beauty",
                  "url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
              }

Only H.264 video codec and AAC audio codec supported. Single audio stream or no audio stream only.

Video Type Extension Max Size
3GPP .3gp 16 MB
MP4 Video .mp4 16 MB

Programing Examples:

curl --location 'https://apialpha.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc' \
--data-raw '{
    "messages": [
        {
            "originator": "{registered phone_number}",
            "content": {
                "message_type": "ATTACHMENT",
                "attachment": {
                    "type": "video",
                    "url": "http://www.onirikal.com/videos/mp4/nestlegold.mp4",
                    "caption": "D7 Video Test"
                }
            },
            "recipients": [
                {
                    "recipient": "{recipient}",
                    "recipient_type": "individual"
                }
            ],
            "report_url": "https://webhook.site/f2615b62-1f28-4215-963d-117280cc6c4e"
        }
    ]
}'
npm i direct7
1
2
3
4
5
6
7
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({originator="91906152XXXX", recipients=[{"recipient": "{recipient}", "recipient_type": "individual"}],message_type: "ATTACHMENT", type: "video", url: "https://www.onirikal.com/videos/mp4/nestlegold.mp4", caption="D7 Video Test"});

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

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

client.whatsapp.send_whatsapp_freeform_message(originator="{registered phone_number}", recipients=[{"recipient": "{recipient}", "recipient_type": "individual"}], message_type="ATTACHMENT", type="video", url="http://www.onirikal.com/videos/mp4/nestlegold.mp4",caption="D7 Video Test")

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

use direct7\Direct7\Client;

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

$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(
    originator:"{registered_phonenumber}", 
    recipients:[["recipient" => "{recipient}", "recipient_type" => "individual"]], 
    message_type:"ATTACHMENT", 
    type: "video", 
    url: "http://www.onirikal.com/videos/mp4/nestlegold.mp4", 
    caption: "D7 Video test"
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
whatsapp := direct7.NewWhatsApp(client)
originator := "{registered_phonenumber}"
recipients := []map[string]string{
    "recipient": "{recipient}",
    "recipient_type": "individual",
}
messageType := "ATTACHMENT"
optParams := &OptionalParams{
    attachmentType:"video",
    url: "http://www.onirikal.com/videos/mp4/nestlegold.mp4",
    caption: "D7 Video Test",
}
response, err := whatsapp.SendWhatsAppFreeformMessage(originator, recipients, messageType, optParams)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"video\",\n                    \"url\": \"http://www.onirikal.com/videos/mp4/nestlegold.mp4\",\n                    \"caption\": \"D7 Video Test\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\"],\n            \"report_url\": \"https://webhook.site/f2615b62-1f28-4215-963d-117280cc6c4e\"\n        }\n    ]\n}");
Request request = new Request.Builder()
.url("https://apialpha.d7networks.com/whatsapp/v2/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc'
};
var request = http.Request('POST', Uri.parse('https://apialpha.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
"messages": [
{
"originator": "{registered phone_number}",
"content": {
"message_type": "ATTACHMENT",
"attachment": {
"type": "video",
"url": "http://www.onirikal.com/videos/mp4/nestlegold.mp4",
"caption": "D7 Video Test"
}
},
"recipients": [
{
"recipient": "{recipient}",
"recipient_type": "individual"
}
],
"report_url": "https://webhook.site/f2615b62-1f28-4215-963d-117280cc6c4e"
}
]
});
request.headers.addAll(headers);

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

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

$body = @"
{
`"messages`": [
{
`"originator`": `"{registered phone_number}`",
`"content`": {
`"message_type`": `"ATTACHMENT`",
`"attachment`": {
`"type`": `"video`",
`"url`": `"http://www.onirikal.com/videos/mp4/nestlegold.mp4`",
`"caption`": `"D7 Video Test`"
}
},
`"recipients`": [
{
`"recipient`": `"{recipient}`",
`"recipient_type`": `"individual`"
}
],
`"report_url`": `"https://webhook.site/f2615b62-1f28-4215-963d-117280cc6c4e`"
}
]
}
"@

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

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

client.whatsapp.send_whatsapp_freeform_message(
    originator='{originator}',
    recipients=[{ "recipient" => "{recipient}", "recipient_type" => "individual"}],
    message_type='ATTACHMENT',
    body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, 
    type='video', 
    url='https://www.onirikal.com/videos/mp4/nestlegold.mp4', 
    caption='Tet'
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://apialpha.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"video\",\n                    \"url\": \"http://www.onirikal.com/videos/mp4/nestlegold.mp4\",\n                    \"caption\": \"D7 Video Test\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\"],\n            \"report_url\": \"https://webhook.site/f2615b62-1f28-4215-963d-117280cc6c4e\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Document messages are messages that display a document icon, linked to a document, that a WhatsApp user can tap to download.

Image Alt Text

Document objects

Parameter Type Description Value / Pattern
*type String Type of the attachment you want to send. For Document messages its document document
*url String URL for the document. The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URL. Supported document formates: .txt, .xls, .xlsx, .doc, .docx, .ppt, .pptx, .pdf with max size 100 MB http://www.africau.edu/images/default/sample.pdf
caption String Caption for the document. Lucky Shrub Invoice
filename String Document filename, with extension. lucky-shrub-invoice.pdf
"attachment": {
                  "type": "document",
                  "caption": "Lucky Shrub Invoice",
                  "url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
                  "filename": "lucky-shrub-invoice.pdf"
              }
Document Type Extension Max Size
Text .txt 16 MB
Microsoft Excel .xls 100 MB
Microsoft Excel .xlsx 100 MB
Microsoft Word .doc 100 MB
Microsoft Word .docx 100 MB
Microsoft PowerPoint .ppt 100 MB
Microsoft PowerPoint .pptx 100 MB
PDF .pdf 100 MB

Programing Examples:

curl --location 'https://apialpha.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc' \
--data-raw '{
    "messages": [
        {
            "originator": "{registered_phone_number}",
            "content": {
                "message_type": "ATTACHMENT",
                "attachment": {
                    "type": "document",
                    "url": "http://www.africau.edu/images/default/sample.pdf",
                    "caption": "flight-ticket.pdf"
                }
            },
            "recipients": [
                {
                    "recipient": "{recipient}",
                    "recipient_type": "individual"
                }
            ],
            "report_url": "https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e"
        }
    ]
}'
npm i direct7
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({
    originator:"{registered_phone_number}",
    recipients : [{"recipient": "{recipient}", "recipient_type": "individual"}],
    message_type: "ATTACHMENT",
    type: "document",
    url: "https://www.clickdimensions.com/links/TestPDFfile.pdf",
    caption: "Test PDF file pdf",
    filename: "TestPDFfile.pdf"
});

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

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

client.whatsapp.send_whatsapp_freeform_message(originator="{registered_phonenumber}", recipients=[{"recipient": "{recipient}", "recipient_type": "individual"}], message_type="ATTACHMENT", type="document", url="https://www.clickdimensions.com/links/TestPDFfile.pdf", caption="Test PDF file pdf", filename="TestPDFfile.pdf")

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

use direct7\Direct7\Client;

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

$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(
    originator:"{registered_phonenumber}", 
    recipients: [["recipient" => "{recipient}", "recipient_type" => "individual"]],
    message_type:"ATTACHMENT", 
    type: "document",
    url: "https://www.clickdimensions.com/links/TestPDFfile.pdf", 
    caption: "Test PDF file pdf", 
    filename: "TestPDFfile.pdf"
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
whatsapp := direct7.NewWhatsApp(client)
originator := "{registered_phonenumber}"
recipients := []map[string]string{
    "recipient": "{recipient}",
    "recipient_type": "individual",
}
messageType := "ATTACHMENT"
optParams := &OptionalParams{
    attachmentType:"document",
    url: "https://www.clickdimensions.com/links/TestPDFfile.pdf",
    caption: "Test PDF file pdf",
    fileName: "TestPDFfile.pdf",
}
response, err := whatsapp.SendWhatsAppFreeformMessage(originator, recipients, messageType, optParams)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"document\",\n                    \"url\": \"http://www.africau.edu/images/default/sample.pdf\",\n                    \"caption\": \"flight-ticket.pdf\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\"],\n            \"report_url\": \"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e\"\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("https://apialpha.d7networks.com/whatsapp/v2/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc")
  .build();
Response response = client.newCall(request).execute();
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc'
};
var request = http.Request('POST', Uri.parse('https://apialpha.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
  "messages": [
    {
      "originator": "{registered phone_number}",
      "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
          "type": "document",
          "url": "http://www.africau.edu/images/default/sample.pdf",
          "caption": "flight-ticket.pdf"
        }
      },
      "recipients": [
        {
          "recipient": "{recipient}",
          "recipient_type": "individual"
        }
      ],
      "report_url": "https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e"
    }
  ]
});
request.headers.addAll(headers);

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

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

$body = @"
{
    `"messages`": [
        {
            `"originator`": `"{registered phone_number}`",
            `"content`": {
                `"message_type`": `"ATTACHMENT`",
                `"attachment`": {
                    `"type`": `"document`",
                    `"url`": `"http://www.africau.edu/images/default/sample.pdf`",
                    `"caption`": `"flight-ticket.pdf`"
                }
            },
            `"recipients`": [
                {
                    `"recipient`": `"{recipient}`",
                    `"recipient_type`": `"individual`"
                }
            ],
            `"report_url`": `"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e`"
        }
    ]
}
"@

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

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

client.whatsapp.send_whatsapp_freeform_message(
    originator='{originator}',
    recipients=[{ "recipient" => "{recipient}", "recipient_type" => "individual"}],
    message_type='ATTACHMENT',
    body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, 
    type='document', 
    url='https://www.clickdimensions.com/links/TestPDFfile.pdf', 
    caption= "Test PDF file pdf",
    filename= "TestPDFfile.pdf"
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://apialpha.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"document\",\n                    \"url\": \"http://www.africau.edu/images/default/sample.pdf\",\n                    \"caption\": \"flight-ticket.pdf\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\"],\n            \"report_url\": \"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Audio messages display an audio icon and a link to an audio file. When the WhatsApp user taps the icon, the WhatsApp client loads and plays the audio file.

Image Alt Text

Audio objects

Parameter Type Description Value / Pattern
*type String Type of the attachment you want to send. For Audio messages its audio audio
*url String URL for the audio. The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URL. Supported audio formates: .aac, .amr, .mp3, .m4a, .ogg with max size 16 MB https://www.luckyshrub.com/assets/lucky-track.aac
"attachment": {
                  "type": "audio",
                  "url": "https://www.luckyshrub.com/assets/lucky-track.aac",
              }
Audio Type Extension Max Size
AAC .aac 16 MB
AMR .amr 16 MB
MP3 .mp3 16 MB
MP4 Audio .m4a 16 MB
OGG Audio .ogg 16 MB

Programing Examples:

curl --location 'https://apialpha.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc' \
--data '{
    "messages": [
        {
            "originator": "{registered_phone_number}",
            "content": {
                "message_type": "ATTACHMENT",
                "attachment": {
                    "type":"audio",
                    "url":  "http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3"
                }
            },
            "recipients": [{
                "recipient": "{recipient}",
                "recipient_type": "individual"
            }],
            "report_url": "https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e"
        }
    ]
}'
npm i direct7
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({
    originator:"{registered_phone_number}",
    recipients : [{"recipient": "{recipient}", "recipient_type": "individual"}],
    message_type: "ATTACHMENT",
    type: "audio",
    url: "http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3",
});

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

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

client.whatsapp.send_whatsapp_freeform_message(originator="{registered_phone_number}", recipients=[{"recipient": "{recipient}", "recipient_type": "individual"}], message_type="ATTACHMENT", type="audio", url="http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3")

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

use direct7\Direct7\Client;

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

$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(
    originator:"{registered_phone_number}", 
    recipients: [["recipient" => "{recipient}", "recipient_type" => "individual"]],
    message_type:"ATTACHMENT", 
    type: "audio", 
    url: "http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3"
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
whatsapp := direct7.NewWhatsApp(client)
originator := "{registered_phonenumber}"
recipients := []map[string]string{
    "recipient": "{recipient}",
    "recipient_type": "individual",
}
messageType := "ATTACHMENT"
optParams := &OptionalParams{
    attachmentType:"audio",
    url: "http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3",
}
response, err := whatsapp.SendWhatsAppFreeformMessage(originator, recipients, messageType, optParams)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\":\"audio\",\n                    \"url\":  \"http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3\"\n                }\n            },\n            \"recipients\": [{\n                \"recipient\": \"{recipient}\",\n                \"recipient_type\": \"individual\",\n                \"cust_ref\":\"abc\"\n            }],\n            \"report_url\": \"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e\"\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("https://apialpha.d7networks.com/whatsapp/v2/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc")
  .build();
Response response = client.newCall(request).execute();
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc'
};
var request = http.Request('POST', Uri.parse('https://apialpha.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
  "messages": [
    {
      "originator": "{registered phone_number",
      "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
          "type": "audio",
          "url": "http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3"
        }
      },
      "recipients": [
        {
          "recipient": "{recipient}",
          "recipient_type": "individual"
        }
      ],
      "report_url": "https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e"
    }
  ]
});
request.headers.addAll(headers);

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

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

$body = @"
{
    `"messages`": [
        {
            `"originator`": `"{registered phone_number`",
            `"content`": {
                `"message_type`": `"ATTACHMENT`",
                `"attachment`": {
                    `"type`":`"audio`",
                    `"url`":  `"http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3`"
                }
            },
            `"recipients`": [{
                `"recipient`": `"{recipient}`",
                `"recipient_type`": `"individual`"
            }],
            `"report_url`": `"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e`"
        }
    ]
}
"@

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

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

client.whatsapp.send_whatsapp_freeform_message(
        originator='{originator}',
        recipients=[{'recipient' => '{recipient}', 'recipient_type' => 'individual'}],
        message_type='ATTACHMENT',
        body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, 
        type='audio', 
        url='http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3'
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://apialpha.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\":\"audio\",\n                    \"url\":  \"http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3\"\n                }\n            },\n            \"recipients\": [{\n                \"recipient\": \"{recipient}\",\n                \"recipient_type\": \"individual\",\n                \"cust_ref\":\"abc\"\n            }],\n            \"report_url\": \"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Sticker messages display animated or static sticker images in a WhatsApp message.

Image Alt Text

Sticker objects

Parameter Type Description Value / Pattern
*type String Type of the attachment you want to send. For Sticker messages its sticker sticker
*url String URL for the sticker. The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URL. Supported sticker formates: Animated and Static with extension .webp https://www.luckyshrub.com/assets/animated-smiling-plant.webp
"attachment": {
                  "type": "sticker",
                  "url": "https://www.luckyshrub.com/assets/animated-smiling-plant.webp",
              }
Sticker Type Extension Max Size
Animated sticker .webp 500 KB
Static sticker .webp 100 KB

Programing Examples:

curl --location 'https://apialpha.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc' \
--data-raw '{
    "messages": [
        {
            "originator": "{registered_phone_number}",
            "content": {
                "message_type": "ATTACHMENT",
                "attachment": {
                    "type": "sticker",
                    "url": "https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp"
                }
            },
            "recipients": [
                {
                    "recipient": "{recipient}",
                    "recipient_type": "individual"
                }
            ],
            "report_url": "https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e"
        }
    ]
}'
npm i direct7
const Client = require('direct7')

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

const response = await client.whatsapp.sendWhatsAppFreeformMessage({
    originator:"{registered_phone_number}",
    recipients : [{"recipient": "{recipient}", "recipient_type": "individual"}],
    message_type: "ATTACHMENT",
    type: "sticker",
    url: "https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp"
});
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_freeform_message(originator="{registered_phonenumber}", recipients=[{"recipient": "{recipient}", "recipient_type": "individual"}], message_type="ATTACHMENT", type="sticker", url="https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp")

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

use direct7\Direct7\Client;

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

$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(
    originator:"{registered_phonenumber}", 
    recipients: [["recipient" => "{recipient}", "recipient_type" => "individual"]],
    message_type:"ATTACHMENT", 
    type: "sticker", 
    url: "https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp"
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
whatsapp := direct7.NewWhatsApp(client)
originator := "{registered_phonenumber}"
recipients := []map[string]string{
    "recipient": "{recipient}",
    "recipient_type": "individual",
}
messageType := "ATTACHMENT"
optParams := &OptionalParams{
    attachmentType:"sticker",
    url: "https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp",
}
response, err := whatsapp.SendWhatsAppFreeformMessage(originator, recipients, messageType, optParams)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"sticker\",\n                    \"url\": \"https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\",\n                    \"cust_ref\": \"[email protected]\",\n                    \"message_tag1\": \"chatbot1234\",\n                    \"conversation_id\": \"conv1234\"\n                }\n            ],\n            \"report_url\": \"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e\"\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("https://apialpha.d7networks.com/whatsapp/v2/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc")
  .build();
Response response = client.newCall(request).execute(); 
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc'
};
var request = http.Request('POST', Uri.parse('https://apialpha.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
  "messages": [
    {
      "originator": "{registered phone_number}",
      "content": {
        "message_type": "ATTACHMENT",
        "attachment": {
          "type": "sticker",
          "url": "https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp"
        }
      },
      "recipients": [
        {
          "recipient": "{recipient}",
          "recipient_type": "individual"
        }
      ],
      "report_url": "https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e"
    }
  ]
});
request.headers.addAll(headers);

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

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

$body = @"
{
    `"messages`": [
        {
            `"originator`": `"{registered phone_number}`",
            `"content`": {
                `"message_type`": `"ATTACHMENT`",
                `"attachment`": {
                    `"type`": `"sticker`",
                    `"url`": `"https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp`"
                }
            },
            `"recipients`": [
                {
                    `"recipient`": `"{recipient}`",
                    `"recipient_type`": `"individual`"
                }
            ],
            `"report_url`": `"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e`"
        }
    ]
}
"@

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

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

client.whatsapp.send_whatsapp_freeform_message(
    originator='{originator}',
    recipients=[{'recipient' => '{recipient}', 'recipient_type' => 'individual'}],
    message_type='ATTACHMENT',
    body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, 
    type='sticker', 
    url='https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp'
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://apialpha.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"ATTACHMENT\",\n                \"attachment\": {\n                    \"type\": \"sticker\",\n                    \"url\": \"https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp\"\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{recipient}\",\n                    \"recipient_type\": \"individual\",\n                    \"cust_ref\": \"[email protected]\",\n                    \"message_tag1\": \"chatbot1234\",\n                    \"conversation_id\": \"conv1234\"\n                }\n            ],\n            \"report_url\": \"https://webhook.site/804c7071-fefc-4887-a252-a9b73da7a60e\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());