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.
curl 'https://graph.facebook.com/<API_VERSION>/<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer EAAJB...' \ -d ' { "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 using hosted media (not recommended) --> "caption": "<MEDIA_CAPTION_TEXT>", "filename": "<MEDIA_FILENAME>", "caption": "<MEDIA_CAPTION_TEXT>" } }'
Placeholder | Description | Example Value |
---|---|---|
String | Required. |
|
String | Optional. Graph API version. | v23.0 |
String | Optional. Media asset caption text. Maximum 1024 characters. |
|
String | Optional. Document filename, with extension. The WhatsApp client will use an appropriate file type icon based on the extension. |
|
String | Required if using uploaded media, otherwise omit. ID of the uploaded media asset. |
|
String | Required if using hosted media, otherwise omit. URL of the media asset hosted on your public server. For better performance, we recommend using |
|
String | Required. WhatsApp business phone number ID. |
|
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/v23.0
/106540352242922/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "document",
"document": {
"id": "1376223850470843",
"filename": "order_abc123.pdf",
"caption": "Your order confirmation (PDF)"
}
}'
{ "messaging_product": "whatsapp", "contacts": [ { "input": "+16505551234", "wa_id": "16505551234" } ], "messages": [ { "id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA" } ] }