Skip to main content

Send Message Document

Kirim pesan dokumen ke nomor whatsapp pribadi atau group.

tip

Kecepatan upload tergantung dari besarnya file yang anda kirimkan, semakin besar maka semakin lama.

Content-Type: multipart/form-data

Request Send to Private

API URL

POST /api/v2/message/send-document

Request Body

ParameterTypeStatusDescription
phonestringrequiredNomor whatsapp penerima pesan.
documentfilerequiredFile yang ingin anda kirimkan. Extention: .jpeg, .jpg, .png, .doc, .docx, .pdf, .csv, .ppt, .pptx, .xls, .xlsx

Request Send to Group

API URL

POST /api/v2/message/send-group-document

Request Body Group

ParameterTypeStatusDescription
phonestringrequiredNomor whatsapp penerima pesan.
groupidstringrequiredGroup ID identification.
documentfilerequiredFile yang ingin anda kirimkan. Extention: .jpeg, .jpg, .png, .doc, .docx, .pdf, .csv, .ppt, .pptx, .xls, .xlsx

Example Code

danger

Pastikan anda menyesuaikan URL POST sesuai dengan URL REST API Panel.

Curl (Private)

curl -X POST \
"https://krmpesan.com/api/v2/message/send-document" \
-H "Content-Type: multipart/form-data" \
-H "Accept: application/json" \
-H "Authorization: Bearer {your-token}" \
-F "phone=085712341234" \
-F "document=@/home/path/files/sample-file.pdf"

Curl (Group)

curl -X POST \
"https://krmpesan.com/api/v2/message/send-group-document" \
-H "Content-Type: multipart/form-data" \
-H "Accept: application/json" \
-H "Authorization: Bearer {your-token}" \
-F "phone=085712341234" \
-F "groupid=12345678" \
-F "document=@/home/path/files/sample-file.pdf"

PHP Curl

<?php

// parse file and get file information
// https://www.php.net/manual/en/function.realpath
$file = realpath('/home/path/files/sample-file.pdf');
// https://www.php.net/manual/en/function.basename
$filename = basename($file);
// https://www.php.net/manual/en/function.mime-content-type
$filemime = mime_content_type($file);

// start curl
$ch = curl_init();

// post data
// https://www.php.net/manual/en/function.curl-file-create
$post = array(
'phone' => '085712341234',
'document' => curl_file_create($file, $filemime, $filename)
);

curl_setopt($ch, CURLOPT_URL, 'https://krmpesan.com/api/v2/message/send-document');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

$headers = array();
$headers[] = 'Content-Type: multipart/form-data';
$headers[] = 'Accept: application/json';
$headers[] = 'Authorization: Bearer {your-token}';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);

var_dump($result);

Response

{
"code": 200,
"message": "Success. Messages will be sent automatically according to the queue and synchronization of contacts. At least 15 minutes for new contacts.",
"data": {
"queue_id": "644",
"uuid": "7e1415f5-3543-4dd7-8a9c-cc41d7f7c1bc",
"user_id": "607a6e33-585e-4f8f-bf5d-d45fe222ad51",
"device_id": "792f656e-4cd7-434b-bab0-bacee3976b4f",
"phone": "6285712341234",
"message": "sample-file.pdf",
"attachment_id": "d4511ed2-138c-4f92-b01f-4f6d721a174e",
"type": "Document",
"category": "Outbox",
"status": "Pending",
"updated_at": "2020-04-20 20:19:22",
"created_at": "2020-04-20 20:19:22"
}
}