Send WhatsApp Media Message
This API feature will give you the ability to send WhatsApp media messages to single or multiple receivers using the same API. All API's accept GET requests.
The base URL to use for this service is https://whatsapp.libyasms.com/. The base URL cannot be used on its own; you must append a path that identifies an operation and you may have to specify some path parameters as well.
Parameters
| Parameter | Value | Required |
|---|---|---|
| accessToken | JWT Authorization header using the Bearer scheme. provided by Libya SMS | Yes |
| instanceId | The ID of the WhatsApp instance used to send the media message. | Yes |
| phoneNumber | The recipient's phone number including the country code (e.g., +14094192823, +218915063556). |
Yes |
| mediaUrl | The URL of the media file to be sent. It should be HTTPS and the media could be any Mime Type document like PDF file, Microsoft Word Document file or Image file. |
Yes |
| mediaName | The name of the media file that should include file extension, for example (name.pdf, name.png, name.doc). |
Yes |
| message | WhatsApp text message contents | No |
| previewLink | A flag indicating whether to include a preview of the media link. Defaults to true. |
No |
| asDocument | A flag indicating whether to send the media as a document instead of a previewable format. Defaults to true. |
No |
Request
curl --location 'https://whatsapp.libyasms.com//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https%3A%2F%2Ftest.erp.abu-nawas.com%2FDocuments%2FInvoices%2FCI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D'
Dim URL ="https://whatsapp.libyasms.com//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https%3A%2F%2Ftest.erp.abu-nawas.com%2FDocuments%2FInvoices%2FCI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true"
Try
Dim request as WebRequest = WebRequest.Create(URL)
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D");
Dim response As WebResponse = request.GetResponse()
Dim dataStream As Stream = response.GetResponseStream()
Dim SR As New StreamReader(dataStream)
Dim str As String
str = SR.ReadToEnd()
Console.WriteLine(str)
response.Close()
Catch ex As System.Net.WebException
Console.WriteLine(ex.Message)
End Try
var options = new RestClientOptions("https://whatsapp.libyasms.com")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https://test.erp.abu-nawas.com/Documents/Invoices/CI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true", Method.Get);
request.AddHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
var headers = {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D'
};
var dio = Dio();
var response = await dio.request(
'https://whatsapp.libyasms.com//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https://test.erp.abu-nawas.com/Documents/Invoices/CI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true',
options: Options(
method: 'GET',
headers: headers,
),
);
if (response.statusCode == 200) {
print(json.encode(response.data));
}
else {
print(response.statusMessage);
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://whatsapp.libyasms.com//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https%3A%2F%2Ftest.erp.abu-nawas.com%2FDocuments%2FInvoices%2FCI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true',
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 eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D'
),
));
$response = curl_exec($curl);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://whatsapp.libyasms.com//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https://test.erp.abu-nawas.com/Documents/Invoices/CI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true")
.method("GET", body)
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D")
.build();
Response response = client.newCall(request).execute();
import http.client
conn = http.client.HTTPSConnection("whatsapp.libyasms.com")
payload = ''
headers = {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D'
}
conn.request("GET", "//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https://test.erp.abu-nawas.com/Documents/Invoices/CI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"
url = URI("https://whatsapp.libyasms.com//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https://test.erp.abu-nawas.com/Documents/Invoices/CI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D"
response = https.request(request)
puts response.read_body
var request = URLRequest(url: URL(string: "https://whatsapp.libyasms.com//api/WhatsAppMessages/SendMessage/SendMediaMessage?instanceId=69043&message=hello&phoneNumber=218915063556&mediaUrl=https%3A%2F%2Ftest.erp.abu-nawas.com%2FDocuments%2FInvoices%2FCI202500000043.pdf&mediaName=CI202500000043.pdf&previewLink=true&asDocument=true")!,timeoutInterval: Double.infinity)
request.addValue("Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJuYW1laWQiOiI1ZWU4ZDc0Zi1jZjY3LTQ4MTktOBJhMi1kNDI5YTBkODQwYzYiLCJ1bmlxdWVfbmFtZSI6ImFidW5hd2FzIiwiVXNlckFjY291bnRJZCI6Ijg1Y2JiYzBkLTZjOTAtNGEwNy1iMGMyLWZkNjZjMjk3MTA5NCIsIm5iZiI6MTc0ODAwMjc0OSwiZXhwIjoxNzQ4MDA2MzQ5LCJpYXQiOjE3NDgwMDI3NDl9.0IjTDF6oY_uQ_skqrvfvLo4ZEbDnRJYVphCjtSxQr0D", forHTTPHeaderField: "Authorization")
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()