Files are sent as documents in WhatsApp, displayed with file name, size, and file type icon in the chat interface.
Endpoint
Headers
Device identifier for multi-device support. Required when multiple devices are registered.
Must be
multipart/form-data for file uploads.Request Body (multipart/form-data)
Phone number with country code and WhatsApp suffix.Format:
{country_code}{phone_number}@s.whatsapp.netExample: [email protected]Optional caption text for the file. Useful for providing context or description.Example:
"Monthly report for June 2024"File to upload and send. Supports a wide range of document formats.Supported formats:
- Documents: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, TXT, CSV
- Archives: ZIP, RAR, 7Z, TAR, GZ
- Code: JS, PY, JAVA, CPP, HTML, CSS, JSON, XML
- Other: RTF, ODT, ODS, ODP, EPUB
Mark the message as forwarded.
Disappearing message duration in seconds.Common values:
86400- 24 hours604800- 7 days7776000- 90 days
Response
Response status code. Returns
"SUCCESS" on successful send.Human-readable response message.
Code Examples
Response Example
Supported File Types
Document Formats
Office Documents:- Microsoft Word:
.doc,.docx - Microsoft Excel:
.xls,.xlsx - Microsoft PowerPoint:
.ppt,.pptx - PDF:
.pdf - Text:
.txt,.rtf
- Writer:
.odt - Calc:
.ods - Impress:
.odp
Data Formats
- CSV:
.csv - JSON:
.json - XML:
.xml - YAML:
.yml,.yaml
Archive Formats
- ZIP:
.zip - RAR:
.rar - 7-Zip:
.7z - TAR:
.tar,.tar.gz,.tgz - GZIP:
.gz
Code & Development
- Source code:
.js,.py,.java,.cpp,.c,.h - Web:
.html,.css,.php - Configuration:
.conf,.ini,.env - Database:
.sql,.db
Other Formats
- eBooks:
.epub,.mobi - Fonts:
.ttf,.otf - Vector:
.svg - Any other file type (as generic document)
File Size Limits
- Maximum file size: 100MB
- Recommended: Under 20MB for reliable delivery
- Large files: May take longer to upload and download
- Network dependent: Delivery time varies by connection speed
Use Cases
Business Documents
Send invoices, contracts, and reports:Educational Materials
Share study materials, assignments, and resources:Technical Documentation
Distribute API documentation, guides, and manuals:File Sharing & Collaboration
Share project files and collaboration documents:Data Export & Backup
Send database exports, backups, and data dumps:Best Practices
-
File Naming
- Use descriptive, meaningful file names
- Include version numbers or dates
- Avoid special characters and spaces
- Example:
report-june-2024-v2.pdf
-
Captions
- Always provide context with captions
- Include version information
- Mention important details or deadlines
- Keep captions concise but informative
-
File Size Optimization
- Compress large files before sending
- Use ZIP for multiple files
- Optimize PDFs (remove unnecessary elements)
- Consider splitting very large files
-
Security & Privacy
- Use disappearing messages for sensitive documents
- Encrypt sensitive files before sending
- Verify recipient before sending confidential data
- Consider using password-protected archives
-
Delivery Confirmation
- Store message_id for tracking
- Implement delivery receipt handling via webhooks
- Follow up with recipient to confirm receipt
- Have fallback delivery methods for critical documents
-
File Format Selection
- Use PDF for documents that shouldn’t be edited
- Use DOCX/XLSX for collaborative editing
- Use ZIP for multiple related files
- Use TXT for simple text that should be easily readable
File Metadata
WhatsApp displays the following metadata for documents:- File Name: Preserved from original file
- File Size: Displayed in KB/MB
- File Type: Icon based on extension
- Page Count: For PDF documents (if available)
- Duration: For audio/video files sent as documents
Limitations
- No File Preview: Unlike images/videos, documents don’t show inline preview
- Download Required: Recipients must download to view content
- Size Restrictions: 100MB hard limit
- No Streaming: Files must be fully downloaded before viewing
- Format Support: Some file types may not open on all devices
Error Responses
Common causes:
- Invalid phone number format
- Missing file parameter
- File size exceeds 100MB
- Invalid file format (corrupted file)
Common causes:
- Device not connected
- File upload interrupted
- Insufficient server storage
- Network timeout during upload
- File processing error
Troubleshooting
File Upload Fails
- Check file size (must be under 100MB)
- Verify file is not corrupted
- Check device connection status
- Ensure sufficient server disk space
- Try with a smaller file first
Long Upload Time
- Large files take time - be patient
- Check network connection speed
- Consider compressing the file
- Split large archives into smaller parts
- Use a faster network connection
Recipient Can’t Open File
- Verify recipient has compatible app
- Check file format is supported on their device
- Ensure file is not corrupted
- Try re-sending the file
- Convert to more common format (e.g., PDF)
Related Endpoints
- Send Image - Send image messages
- Send Video - Send video messages
- Send Audio - Send audio messages
- Download Media - Download files from messages
