Updated on November 24, 2026
To send a PDF via the WhatsApp API, make a POST /<PHONE_NUMBER_ID>/messages request with "type": "document" and, inside the document object, either the id of previously uploaded media or a public link, plus a filename field with the name and extension the customer will see (for example, invoice-order-4821.pdf). Meta accepts PDF, TXT, Word, Excel and PowerPoint files up to 100 MB, with an optional caption of up to 1,024 characters.
This guide goes deeper than our general article on sending images, PDFs, audio and video via the WhatsApp API: how the file name is displayed, which MIME types to use, when to choose a link or a media_id, and how Brazilian companies send payment slips and invoices as PDFs without getting category, cost or privacy wrong.
The minimal document payload
Inside the 24-hour window opened by the customer, a document is a free-form message. The JSON below uses a file already uploaded to the media endpoint:
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "5584999999999",
"type": "document",
"document": {
"id": "1037543291543636",
"filename": "invoice-order-4821.pdf",
"caption": "Here is the invoice for order #4821, due on Nov 28."
}
}
The fields of the document object, according to the document messages documentation:
| Field | Required | What it does |
|---|---|---|
id | One of the two | ID of the media uploaded to the /media endpoint (recommended) |
link | One of the two | HTTPS URL where the file is hosted (Meta marks it as “not recommended”) |
filename | No | File name with extension. The app uses the extension to pick the icon |
caption | No | Text under the document, up to 1,024 characters |
Use id or link, never both. The response returns the message wamid; delivery, read and failure events arrive later through the status webhook.
The file name: why filename matters
Without filename, the customer gets a document with a generic name that is hard to find later in the chat or in the downloads folder. With it, the file shows the name you chose and the right icon, because WhatsApp reads the extension.
Good practices for generating the name:
- Always include the extension.
invoice-1520.pdf, notinvoice-1520. The docs ask for the “filename, with extension”. - Make the extension match the real file. A
.pdfthat is actually HTML (an error page from your server) will fail or open incorrectly. - Use an identifier that helps the customer. Order number, invoice number or billing month:
statement-2026-11.pdf. - Keep sensitive data out of the name. Avoid tax IDs, full names or amounts in
filename. The name is visible in notifications and file lists. - Avoid accents and spaces. This is not a documented requirement, but it prevents encoding issues in other systems that handle the file later.
A simple Node.js function to build the name:
function fileName(prefix, reference, extension = 'pdf') {
const base = `${prefix}-${reference}`
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.toLowerCase()
.replace(/[^a-z0-9-]+/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '');
return `${base}.${extension}`;
}
console.log(fileName('Invoice order', 4821)); // invoice-order-4821.pdf
Want to try it while you read? Create a Vectalk account and send your first message through the official API. Create free account →
Supported document types and MIME types
The Cloud API media page lists the supported documents, all with a 100 MB limit:
| Format | Extension | MIME type |
|---|---|---|
.pdf | application/pdf | |
| Text | .txt | text/plain |
| Word | .doc | application/msword |
| Word | .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| Excel | .xls | application/vnd.ms-excel |
| Excel | .xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| PowerPoint | .ppt | application/vnd.ms-powerpoint |
| PowerPoint | .pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
Meta warns that other file types may be sent via the API, but they are not supported and may not be handled as expected. If you need to send a CSV, an invoice XML or a ZIP, test with an internal number first and consider converting it (CSV to XLSX, for example) or putting a download link in the text.
When uploading, the type field must be the MIME type from the table, and it has to match the actual content. A mismatched MIME type is a common cause of error 131053 (“Unable to upload the media used in the message”). On Linux or macOS, file -I file.pdf shows the real type. More troubleshooting in WhatsApp API error 131053.
Link or media_id: how to decide
Meta recommends id (prior upload) and labels link as not recommended. That doesn’t forbid links, but it changes the risk: with link, the send depends on your server delivering the file at the moment Meta fetches it.
| Situation | Best option | Why |
|---|---|---|
| Same PDF for many customers (catalog, price list, standard contract) | Upload once and reuse the id | The file is already at Meta; the ID is valid for 30 days |
| One file per customer (payment slip, invoice, lab report) | Upload right before sending | The file is never exposed at a public URL |
| One file per customer, without uploading | link with a signed, short-lived URL | Shrinks the window in which the document is reachable |
| File generated on demand by a slow service | Upload once the PDF is ready | Avoids timeouts while Meta tries to download it |
An uploaded media ID expires after 30 days. If you reuse files, store the upload date and renew before then. Details in WhatsApp media ID expiration and reuse.
The upload is a multipart/form-data request to POST /<PHONE_NUMBER_ID>/media with file, type (application/pdf) and messaging_product=whatsapp; the response returns the id that goes into document.id. Upload examples in cURL, Node.js and Python are in the media sending guide.
Payment slips and invoices as PDF: the Brazilian context
In Brazil, two documents dominate this kind of message:
- Boleto bancário: a bank payment slip with a barcode that the customer pays at a bank, in a banking app or at lottery outlets. Many companies also offer PIX, the Central Bank’s instant payment system, as an alternative.
- Nota fiscal eletrônica (NF-e): the electronic tax invoice for the sale. Customers usually receive the DANFE, the PDF representation of that invoice.
The same logic applies to invoices and statements anywhere. Three rules to get it right:
- Inside the 24-hour window (the customer messaged you in the last 24 hours), the PDF goes as a free-form message, as shown above. Since October 1, 2026, each number gets 1,000 free service messages per month, and billing starts at the 1,001st.
- Outside the window, templates only. To send the slip or invoice to someone who hasn’t messaged you, create a template with a document header. A reminder about the customer’s own bill or invoice is a utility message: for Brazilian recipients, BRL 0.0350 per delivered message since October 1, 2026. Also since October 1, 2026, utility templates sent inside the customer service window are charged.
- Collecting third-party debt is prohibited by the WhatsApp Commerce Policy.
Example of a template with the payment slip in the header (the boleto_disponivel template must be approved with a document-type header):
{
"messaging_product": "whatsapp",
"to": "5584999999999",
"type": "template",
"template": {
"name": "boleto_disponivel",
"language": { "code": "pt_BR" },
"components": [
{
"type": "header",
"parameters": [
{
"type": "document",
"document": { "id": "1037543291543636", "filename": "boleto-pedido-4821.pdf" }
}
]
},
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Maria" },
{ "type": "text", "text": "28/11/2026" }
]
}
]
}
}
The full component and parameter structure is in how to send a WhatsApp template message via API. For reminder sequences about pending payment slips and PIX, see recovering PIX, boleto and abandoned carts, and to pull the invoice from an ERP, the Bling + WhatsApp example.
Privacy: documents contain personal data
Payment slips, invoices, contracts and lab reports carry names, tax IDs (CPF for individuals, CNPJ for companies), addresses and amounts. Brazil’s General Data Protection Law, the LGPD (Law 13,709/2018), requires, among other principles, that data processing have a defined purpose, be limited to what is necessary and come with security measures. In practice, when sending PDFs:
- Confirm the destination number belongs to the data subject before sending the document.
- Prefer uploads over permanent public URLs. If you use
link, use a signed URL with a short expiration. - Don’t put personal data in
filenameorcaptionbeyond what is necessary. - Delete PDFs generated only for sending from your temporary storage, according to your retention policy.
This is a general explanation of the law and does not replace advice from a lawyer.
Common errors when sending documents
| Symptom | Likely cause | What to do |
|---|---|---|
Error 131053 | Declared MIME type differs from content, or unsupported type | Check with file -I and use a type from the table |
| File arrives with a generic name | Missing filename | Always send filename with an extension |
| Wrong icon in the app | filename extension doesn’t match the file | Fix the extension to match the real type |
Sending by link fails | URL requires login, expired or returns an HTML page | Test the URL from outside your network or upload it |
Sending by id fails | ID older than 30 days or from another number | Upload again from the same number |
Error 131047 | More than 24 hours since the customer’s last message | Send a template with a document header |
How to do it with Vectalk
With Vectalk, the document JSON is the same as in the Cloud API. Only the base URL and the token change:
- Send:
POST https://apis.vectalk.com.br/api/messageswithtype: "document"anddocument.linkordocument.id, plusfilenameand an optionalcaption. - Upload:
POST https://apis.vectalk.com.br/api/mediaasmultipart/form-datawithfile,typeandmessaging_product, using an instance token. The response returns theidto use indocument.id.
curl -X POST https://apis.vectalk.com.br/api/messages \
-H "Authorization: Bearer $VECTALK_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "5584999999999",
"type": "document",
"document": {
"link": "https://files.yourcompany.com/invoices/1520.pdf",
"filename": "invoice-1520.pdf",
"caption": "Your invoice for order #4821"
}
}'
The routes are documented under Send document and Media upload. Each delivered message is deducted from the platform’s prepaid balance, with no credit card registered with Meta. For the big picture, read the official WhatsApp API guide and create your account at apps.vectalk.com.br/register.
Frequently asked questions
What is the maximum PDF size on the WhatsApp API?
100 MB, the same limit as every supported document: PDF, TXT, Word, Excel and PowerPoint.
Is the filename field required?
No, but it is recommended. Without it, the customer sees a generic name. With it, the file shows the right name and icon, because the app uses the extension to pick the icon.
Can I send a PDF to a customer who hasn’t messaged me in days?
Only with an approved template that has a document header. A free-form document message requires the 24-hour window opened by the customer.
Can I send CSV, XML or ZIP files?
The API may accept other types, but Meta says they are not supported and may not be displayed as expected. Test first or convert to a format from the table.
Does sending a PDF cost more than sending text?
No. Meta charges per delivered message based on category, not content type. Inside the window, a PDF is a service message; outside it, you pay for the template (utility, for the customer’s own bill or invoice).
Official sources consulted on November 24, 2026: Document messages, Media (Cloud API), Error codes, Law 13,709/2018 (LGPD), Vectalk: send document, Vectalk: media upload.
Put your business on the official WhatsApp
Create your account, connect your number to the official API (you can keep the app with coexistence) and start serving customers and sending messages.
