Document Messages
Document message using type: "document" with object document. Like images, documents can be sent via Public URL (link) or media ID (id).
Request Body
Section titled “Request Body”Via URL (link)
Section titled “Via URL (link)”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "document", "document": { "link": "https://example.com/invoice-12345.pdf", "caption": "Invoice #12345", "filename": "invoice-12345.pdf" }}Via Media ID (id)
Section titled “Via Media ID (id)”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "document", "document": { "id": "f7a816e2-8397-11f0-8e34-010203040506", "caption": "Invoice #12345", "filename": "invoice-12345.pdf" }}Field document
Section titled “Field document”| Field | Type | Required | Description |
|---|---|---|---|
link | string | Yes* | Public URL to the document file. |
id | string (UUID) | Yes* | Media ID from a previous upload. |
caption | string | No | Document description displayed below the file name. |
filename | string | No | File name displayed to the recipient. If not included, the name is taken from the URL. |
* Use one of: link or id.
Supported Formats
Section titled “Supported Formats”| Format | Extension | Max Size |
|---|---|---|
.pdf | 100 MB | |
| DOCX | .docx | 100 MB |
| XLSX | .xlsx | 100 MB |
| PPTX | .pptx | 100 MB |
| Plain Text | .txt | 100 MB |
Complete Example
Section titled “Complete Example”curl -X POST https://messaging.cpaas.id/v1/YOUR_PHONE_NUMBER_ID/messages \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "document", "document": { "link": "https://example.com/invoice-12345.pdf", "caption": "Invoice bulan Juni 2026", "filename": "invoice-juni-2026.pdf" } }'import requests
url = "https://messaging.cpaas.id/v1/YOUR_PHONE_NUMBER_ID/messages"headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}payload = { "messaging_product": "whatsapp", "to": "6281234567890", "type": "document", "document": { "link": "https://example.com/invoice-12345.pdf", "caption": "Invoice bulan Juni 2026", "filename": "invoice-juni-2026.pdf" }}
response = requests.post(url, json=payload, headers=headers)print(response.json())const response = await fetch( 'https://messaging.cpaas.id/v1/YOUR_PHONE_NUMBER_ID/messages', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ messaging_product: 'whatsapp', to: '6281234567890', type: 'document', document: { link: 'https://example.com/invoice-12345.pdf', caption: 'Invoice bulan Juni 2026', filename: 'invoice-juni-2026.pdf', }, }), });const data = await response.json();console.log(data);Response
Section titled “Response”{ "messaging_product": "whatsapp", "messages": [ { "id": "msg_f7a816e2-8397-11f0-8e34-010203040506" } ]}Webhook Statuses You Will Receive
Section titled “Webhook Statuses You Will Receive”message.status.sent— Document was successfully sent to the WhatsApp networkmessage.status.delivered— Document reached the recipient’s devicemessage.status.read— Document was opened by the recipient
If it fails, you receive message.status.failed.
See the page Webhook for details on the payload format of each event.