Document messages are messages that display a document icon, linked to a document, that a WhatsApp user can tap to download.
Use the POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages endpoint to send a document message to a WhatsApp user.
POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages
{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "<WHATSAPP_USER_PHONE_NUMBER>", "type": "document", "document": { "id" : "<MEDIA_ID>", /* Only if using uploaded media */ "link": "<MEDIA_URL>", /* Only if linking to your media */ "caption": "<DOCUMENT_CAPTION>", "filename": "<DOCUMENT_FILENAME>" } }
Placeholder | Description | Example Value |
---|---|---|
String | Optional. Document caption text. |
|
String | Optional. Document filename, with extension. The WhatsApp client will use an appropriate file type icon based on the extension. |
|
String | Required if using an uploaded media asset (recommended). Uploaded media asset ID. |
|
String | Optional. Document filename, with extension. The WhatsApp client will use an appropriate file type icon based on the extension. |
|
String | Required if linking to your media asset (not recommended). URL of image asset on your public server. For better performance, we recommend that you upload your media asset instead. |
|
String | Required. WhatsApp user phone number. |
|
Document Type | Extension | MIME Type | Max Size |
---|---|---|---|
Text | .txt | text/plain | 100 MB |
Microsoft Excel | .xls | application/vnd.ms-excel | 100 MB |
Microsoft Excel | .xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | 100 MB |
Microsoft Word | .doc | application/msword | 100 MB |
Microsoft Word | .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | 100 MB |
Microsoft PowerPoint | .ppt | application/vnd.ms-powerpoint | 100 MB |
Microsoft PowerPoint | .pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation | 100 MB |
application/pdf | 100 MB |
Example request to send a PDF in a document message with a caption to a WhatsApp user.
curl 'https://graph.facebook.com/v21.0
/106540352242922/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "text",
"text": {
"preview_url": true,
"body": "As requested, here'\''s the link to our latest product: https://www.meta.com/quest/quest-3/"
}
}'
{ "messaging_product": "whatsapp", "contacts": [ { "input": "+16505551234", "wa_id": "16505551234" } ], "messages": [ { "id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA" } ] }