OpenWA icon

OpenWA

Interact with OpenWA WhatsApp API Gateway

Actions164

Message → Send Document

AI-generated

Summary

Send a document file (such as a PDF or spreadsheet) to a WhatsApp individual or group chat using a URL, binary property, or base64 payload. The filename provided to the recipient cannot exceed 60 characters; if left blank, it falls back to the binary item's own name, the filename from the URL path when valid, or 'document.pdf'.

Inputs

  • sessionId (required) — The ID or name of the OpenWA session from which to send the document.
  • chatId (required) — Recipient WhatsApp chat ID (e.g., 628123456789@c.us for individuals or ...@g.us for groups).
  • documentSource — Source of the document payload: URL, Binary Data, or Base64 (defaults to URL).
  • documentUrl (required) — URL of the document file to send when Document Source is set to URL.
  • documentBinaryProperty (required) — Name of the item binary property containing the file when Document Source is set to Binary Data.
  • documentBase64 (required) — Base64-encoded document file content when Document Source is set to Base64.
  • documentMimeType (required) — MIME type for base64 encoded document content (e.g., application/pdf).
  • filename — Filename displayed to the recipient. When left blank, falls back to the binary item's own name, the filename from the URL when it looks like a real file, or 'document.pdf'. The filename cannot exceed 60 characters; exceeding this limit causes the send to fail with an error.
  • caption — Optional text caption to send alongside the document.
  • sendQuotedMessageId — Optional ID of an earlier message to quote as a reply.
  • mentions — Comma-separated string, JSON array, or expression array of WhatsApp IDs to @mention in the document caption.
  • idempotencyKey — Optional 1-255 ASCII key to prevent duplicate sends on retries within 24 hours.

Output shape

a single record

Returns a JSON object containing the sent document message details and metadata. Using a repeated idempotency key within 24 hours returns the original send result.

Examples

Example 1: Send a PDF file from a URL to a individual recipient

Set Session ID to your session, Chat ID to 628123456789@c.us, Document Source to 'URL', Document URL to 'https://example.com/invoice.pdf', and Filename to 'Invoice-2024.pdf'.

Example 2: Send a downloaded binary file with a custom caption

Set Session ID, Chat ID, Document Source to 'Binary Data', Binary Property to 'data', and Caption to 'Here is the report you requested.'.

Links

Discussion