Skip to main content
Send a document file to a WhatsApp number or group. Supports various file formats with optional captions and disappearing messages.
Files are sent as documents in WhatsApp, displayed with file name, size, and file type icon in the chat interface.

Endpoint

POST /send/file

Headers

X-Device-Id
string
Device identifier for multi-device support. Required when multiple devices are registered.
Content-Type
string
required
Must be multipart/form-data for file uploads.

Request Body (multipart/form-data)

phone
string
required
Phone number with country code and WhatsApp suffix.Format: {country_code}{phone_number}@s.whatsapp.netExample: [email protected]
caption
string
Optional caption text for the file. Useful for providing context or description.Example: "Monthly report for June 2024"
file
file
required
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
is_forwarded
boolean
default:false
Mark the message as forwarded.
duration
integer
Disappearing message duration in seconds.Common values:
  • 86400 - 24 hours
  • 604800 - 7 days
  • 7776000 - 90 days

Response

code
string
Response status code. Returns "SUCCESS" on successful send.
message
string
Human-readable response message.
results
object
message_id
string
Unique identifier for the sent message.Example: "3EB0B430B6F8F1D0E053AC120E0A9E5C"
status
string
Detailed status message.

Code Examples

curl -X POST http://localhost:3000/send/file \
  -H "X-Device-Id: my-device" \
  -F "[email protected]" \
  -F "caption=Monthly Report - June 2024" \
  -F "file=@/path/to/report.pdf"

Response Example

{
  "code": "SUCCESS",
  "message": "Success",
  "results": {
    "message_id": "3EB0B430B6F8F1D0E053AC120E0A9E5C",
    "status": "File sent successfully"
  }
}

Supported File Types

Document Formats

Office Documents:
  • Microsoft Word: .doc, .docx
  • Microsoft Excel: .xls, .xlsx
  • Microsoft PowerPoint: .ppt, .pptx
  • PDF: .pdf
  • Text: .txt, .rtf
Open Office:
  • 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

WhatsApp enforces file size limits for document messages.
  • 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:
curl -X POST http://localhost:3000/send/file \
  -H "X-Device-Id: my-device" \
  -F "[email protected]" \
  -F "caption=Invoice #12345 - Payment Due June 30" \
  -F "file=@invoices/invoice-12345.pdf"

Educational Materials

Share study materials, assignments, and resources:
curl -X POST http://localhost:3000/send/file \
  -H "X-Device-Id: my-device" \
  -F "[email protected]" \
  -F "caption=Chapter 5 - Introduction to Programming" \
  -F "file=@courses/chapter5.pdf"

Technical Documentation

Distribute API documentation, guides, and manuals:
curl -X POST http://localhost:3000/send/file \
  -H "X-Device-Id: my-device" \
  -F "[email protected]" \
  -F "caption=API Documentation v2.0" \
  -F "file=@docs/api-docs-v2.pdf"

File Sharing & Collaboration

Share project files and collaboration documents:
curl -X POST http://localhost:3000/send/file \
  -H "X-Device-Id: my-device" \
  -F "[email protected]" \
  -F "caption=Design mockups - please review and provide feedback" \
  -F "file=@designs/mockups-v3.zip"

Data Export & Backup

Send database exports, backups, and data dumps:
curl -X POST http://localhost:3000/send/file \
  -H "X-Device-Id: my-device" \
  -F "[email protected]" \
  -F "caption=Database backup - 2024-06-15" \
  -F "file=@backups/db-backup-20240615.sql.gz"

Best Practices

  1. File Naming
    • Use descriptive, meaningful file names
    • Include version numbers or dates
    • Avoid special characters and spaces
    • Example: report-june-2024-v2.pdf
  2. Captions
    • Always provide context with captions
    • Include version information
    • Mention important details or deadlines
    • Keep captions concise but informative
  3. File Size Optimization
    • Compress large files before sending
    • Use ZIP for multiple files
    • Optimize PDFs (remove unnecessary elements)
    • Consider splitting very large files
  4. Security & Privacy
    • Use disappearing messages for sensitive documents
    • Encrypt sensitive files before sending
    • Verify recipient before sending confidential data
    • Consider using password-protected archives
  5. 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
  6. 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

Be aware of these limitations when sending files.
  1. No File Preview: Unlike images/videos, documents don’t show inline preview
  2. Download Required: Recipients must download to view content
  3. Size Restrictions: 100MB hard limit
  4. No Streaming: Files must be fully downloaded before viewing
  5. Format Support: Some file types may not open on all devices

Error Responses

400
Bad Request
Common causes:
  • Invalid phone number format
  • Missing file parameter
  • File size exceeds 100MB
  • Invalid file format (corrupted file)
500
Internal Server Error
Common causes:
  • Device not connected
  • File upload interrupted
  • Insufficient server storage
  • Network timeout during upload
  • File processing error

Troubleshooting

File Upload Fails

  1. Check file size (must be under 100MB)
  2. Verify file is not corrupted
  3. Check device connection status
  4. Ensure sufficient server disk space
  5. Try with a smaller file first

Long Upload Time

  1. Large files take time - be patient
  2. Check network connection speed
  3. Consider compressing the file
  4. Split large archives into smaller parts
  5. Use a faster network connection

Recipient Can’t Open File

  1. Verify recipient has compatible app
  2. Check file format is supported on their device
  3. Ensure file is not corrupted
  4. Try re-sending the file
  5. Convert to more common format (e.g., PDF)

Build docs developers (and LLMs) love