Document Messages

Document messages are messages that display a document icon, linked to a document, that a WhatsApp user can tap to download.

Sending Text Messages

Use the POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages endpoint to send a document message to a WhatsApp user.

Request Syntax

POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages

Post Body

{
  "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>"
  }
}

Post Body Parameters

PlaceholderDescriptionExample Value

<DOCUMENT_CAPTION>

String

Optional.

Document caption text.

Lucky Shrub Invoice

<DOCUMENT_FILENAME>

String

Optional.

Document filename, with extension. The WhatsApp client will use an appropriate file type icon based on the extension.

lucky-shrub-invoice.pdf

<MEDIA_ID>

String

Required if using an uploaded media asset (recommended).

Uploaded media asset ID.

430519053060512

<DOCUMENT_FILENAME>

String

Optional.

Document filename, with extension. The WhatsApp client will use an appropriate file type icon based on the extension.

lucky-shrub-invoice.pdf

<MEDIA_URL>

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.

https://www.luckyshrub.com/invoices/FmOzfD9cKf/lucky-shrub-invoice.pdf.png

<WHATSAPP_USER_PHONE_NUMBER>

String

Required.

WhatsApp user phone number.

+16505551234

Supported Document Types

Document TypeExtensionMIME TypeMax 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

PDF

.pdf

application/pdf

100 MB

Example Request

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/"
  }
}'

Example Response

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "+16505551234",
      "wa_id": "16505551234"
    }
  ],
  "messages": [
    {
      "id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1RjQyNUE3NEYxMzAzMzQ5MkEA"
    }
  ]
}