Send PDF

Treat PDFs as general file deliveries via the file endpoint. Require file.url and required caption.

POST
https://api.wawp.net/v2/send/pdf?access_token=YOUR_ACCESS_TOKEN&caption=Here%27s+your+requested+document.&chatId=201234567890%40c.us&file%5Bfilename%5D=document.pdf&file%5Bmimetype%5D=application%2Fpdf&file%5Burl%5D=https%3A%2F%2Fwawp.net%2Fsamples%2Ffile-sample.pdf&instance_id=123456789&reply_to=false_111...AAAA

Authentication Required

Login to swap the placeholders with your real Instance ID and Access Token.

Log In
Test /v2/send/pdf endpoint
POSTGET

No query parameters required

This endpoint doesn't expect data in the URL.

Document Integrity: Empowering the PDF Messaging Engine

In the world of business automation, PDFs are the primary vehicle for high-value data—invoices, contracts, medical reports, and technical manuals. The /v2/send/pdf endpoint is designed to bridge the gap between your cloud storage and your user's WhatsApp conversation, ensuring that critical documents arrive with their integrity and formatting intact. Unlike media messages which are often compressed, Wawp treats PDFs as authoritative documents, preserving their binary structure for professional use.

send pdf.png


🏗️ The Document Delivery Architecture

When you initiate a PDF transfer, Wawp’s document engine follows a specialized protocol:

  1. Header Inspection: Before downloading the full file, Wawp inspects the Content-Type to ensure it aligns with application/pdf. This prevents the "Mangled File" error that occurs if a server accidentally serves an HTML page instead of a PDF during a transient error.
  2. Authoritative Naming: The file[filename] parameter is crucial. Wawp injects this name into the WhatsApp metadata, ensuring that when the user saves the document, it retains the professional name you’ve assigned it (e.g., Inv_2025_001.pdf) rather than a random UUID.
  3. Caption Correlation: Wawp allows you to attach a markdown-rich caption to the document. This is ideal for providing instructions (e.g., "Please sign and return to this chat") without sending a separate, disconnected text message.

🛡️ Strategic Best Practices for Corporate Document Flow

1. The Security First Approach

Since PDFs often contain sensitive Personal Identifiable Information (PII):

  • Short-Lived URLs: Host your PDFs on URLs that expire shortly after the transfer is complete. Wawp only needs access for a few seconds to fetch and hand off the file to the WhatsApp network.
  • No-Log Policy: Wawp adheres to a Zero-Secrets Policy. We do not archive your PDF contents. Once we receive the "Sent" acknowledgement from the WhatsApp WebSocket, the binary buffer is purged from our engine's volatile memory.

2. File Size and Optimization Strategy

While WhatsApp supports documents up to 100MB (and sometimes up to 2GB in newer versions), user experience dictates a leaner approach.

  • The "Mobile Friendly" Rule: Most users are on mobile data. We recommend keeping PDFs under 5MB for instant loading. If you are sending a 50MB manual, consider compressing it or sending a link via /v2/send/link-preview instead.
  • Fast Serialization: Use linearized (web-optimized) PDFs. This allows the recipient's phone to start rendering the first page before the entire document has finished downloading.

3. Error Handling and Verification

  • Upstream Timeouts: For very large PDFs, ensure your file server has a high enough bandwidth to serve the entire file to Wawp within 15–20 seconds.
  • Webhook Monitoring: Listen for the message.ack events. For a PDF, the "Delivered" status is your confirmation that the document is safely on the user's encrypted device.

🧩 Advanced Use Cases

Automated Invoicing and Billing

Integrate this endpoint with your billing system. As soon as a payment is processed, generate a PDF and send it via Wawp. The reply_to parameter can be used to link the invoice to the customer's previous "Payment Confirmation" message, creating a professional audit trail for the user.

Legal and Contractual Workflows

Send contracts for digital review. Use the caption field to explain the terms briefly. Because Wawp supports international character sets, your captions can support legal terminology in any language while maintaining the structural integrity of the PDF attachment.


🛠️ Common Pitfalls and Solutions

  • Invalid MIME-Type: If your server sends text/html (often due to a 404 page) but you specified application/pdf, tips: [ { type: 'info', title: 'Size', content: 'WhatsApp has a file size limit (approx 100MB).' }, { type: 'positive', title: 'Preview', content: 'Shows the first page as a thumbnail on some devices.' } ], recommendations: [ "Compress large PDFs before sending to ensure delivery.", "Use descriptive filenames; users see this when downloading." ]

    Wawp will fail the request to prevent sending corrupted files to your users.

  • Complex Filenames: Avoid using emojis or non-ASCII characters in the file[filename] string. While Wawp supports them, some older Android PDF readers may fail to open files with complex filenames.

  • The "Attachment Only" UI: Remind your frontend developers that PDFs do not show a visual preview in the chat bubble (unlike images). Use a descriptive caption to tell the user what the file is before they download it.


Summary of Capabilities:

  • Deliver professional-grade PDF documents with custom filenames and captions.
  • Support for large files (up to 100MB) with reliable fetching from HTTPS sources.
  • End-to-end markdown support for document captions and instructions.
  • Seamless integration with conversational threads via reply_to.
  • Consistent delivery tracking through unique message_id generation and Webhook support.

Request Parameters

Configure the parameters required to interact with this endpoint. All query and body arguments are listed below with their details.

Request Body

Sent as a JSON object
string

Unique ID of the WhatsApp session

Example:
string

API access token

Example:
string

Recipient's WhatsApp ID (JID). Supports Individuals (@c.us), Groups (@g.us), and Newsletters (@newsletter).

Example:
string

Publicly accessible HTTPS URL of the PDF file

Example:
string

Filename for the document

Example:
string

MIME type (e.g., application/pdf)

Example:
string

Caption for the document

Example:
string

The ID of the message you are replying to

Example:

Request Samples

Use these ready-to-go code snippets to integrate our API into your project quickly and efficiently. Choose your preferred language and library.

1const baseUrl = "https://api.wawp.net";
2const endpoint = "/v2/send/pdf";
3const params = new URLSearchParams({
4 "instance_id": "123456789",
5 "access_token": "YOUR_ACCESS_TOKEN"
6}).toString();
7const body = {
8 "chatId": "201234567890@c.us",
9 "file[url]": "https://wawp.net/samples/file-sample.pdf",
10 "file[filename]": "document.pdf",
11 "file[mimetype]": "application/pdf",
12 "caption": "Here's your requested document.",
13 "reply_to": "false_111...AAAA"
14};
15
16fetch(`${baseUrl}${endpoint}${params ? '?' + params : ''}`, {
17 method: "POST",
18 headers: { "Content-Type": "application/json" },
19 body: JSON.stringify(body)
20})
21 .then(async (response) => {
22 if (response.ok) {
23 const data = await response.json();
24 console.log("Success:", data);
25 return data;
26 }
27
28 // Error Handling
29 if (response.status === 400) {
30 console.error("Error 400: Bad Request - Missing Required Parameter(s)");
31 }
32 if (response.status === 400) {
33 console.error("Error 400: Bad Request - Invalid Number (Egypt)");
34 }
35 if (response.status === 400) {
36 console.error("Error 400: Bad Request - Invalid Number (Saudi Arabia)");
37 }
38 if (response.status === 400) {
39 console.error("Error 400: Bad Request - Invalid Number (Unknown)");
40 }
41 if (response.status === 400) {
42 console.error("Error 400: Bad Request (XML Format)");
43 }
44 if (response.status === 400) {
45 console.error("Error 400: Bad Request (Plain Text)");
46 }
47 if (response.status === 401) {
48 console.error("Error 401: Unauthorized - Invalid or Missing Access Token");
49 }
50 if (response.status === 401) {
51 console.error("Error 401: Unauthorized (XML Format)");
52 }
53 if (response.status === 404) {
54 console.error("Error 404: Not Found - Session Does Not Exist");
55 }
56 if (response.status === 404) {
57 console.error("Error 404: Not Found (XML Format)");
58 }
59 if (response.status === 429) {
60 console.error("Error 429: Too Many Requests - Rate Limit Exceeded");
61 }
62 if (response.status === 500) {
63 console.error("Error 500: Internal Server Error - Unexpected Failure");
64 }
65 if (response.status === 500) {
66 console.error("Error 500: Internal Server Error (HTML)");
67 }
68 if (response.status === 502) {
69 console.error("Error 502: Bad Gateway - Connection Failed to Upstream");
70 }
71 if (response.status === 502) {
72 console.error("Error 502: Bad Gateway (XML Format)");
73 }
74
75 const errorText = await response.text();
76 console.error(`Error ${response.status}: ${errorText}`);
77 })
78 .catch((error) => console.error("Network Error:", error));
Interactive Samples
Ln 78, Col 1javascript

Expected Responses

Explore all possible responses and outcomes from the server. We have documented each status code with data examples to make success and error handling easier.

Message Sent Successfully
Type:
application/json
object *
string *
object *
number *
boolean *
string *
string *
number *
string *
string *
string *
boolean *
number *
boolean *
boolean *
boolean *
boolean *
boolean *
array *
array *
array *
boolean *
array *

Example

{
"_data": {
  "id": {
    "fromMe": true,
    "remote": "000000000000@c.us",
    "id": "MSG_ID_123456",
    "_serialized": "true_000000000000@c.us_MSG_ID_123456"
    },
  "viewed": false,
  "body": "BASE64_IMAGE_DATA",
  "type": "image",
  "t": 1759108866,
  "from": {
    "server": "c.us",
    "user": "111111111111",
    "_serialized": "111111111111@c.us"
    },
  "to": {
    "server": "c.us",
    "user": "000000000000",
    "_serialized": "000000000000@c.us"
    },
  "ack": 0,
  "isNewMsg": true,
  "star": false,
  "kicNotified": false,
  "caption": "Here's your requested image.",
  "deprecatedMms3Url": "https://example.com/media-url",
  "directPath": "/media/direct/path/example",
  "mimetype": "image/jpeg",
  "filehash": "FILE_HASH_PLACEHOLDER",
  "encFilehash": "ENC_FILE_HASH_PLACEHOLDER",
  "size": 192487,
  "mediaKey": "MEDIA_KEY_PLACEHOLDER",
  "mediaKeyTimestamp": 1759108865,
  "streamable": false,
  "mediaHandle": null,
  "isFromTemplate": false,
  "pollInvalidated": false,
  "isSentCagPollCreation": false,
  "latestEditMsgKey": null,
  "latestEditSenderTimestampMs": null,
  "mentionedJidList": {
    },
  "groupMentions": {
    },
  "isEventCanceled": false,
  "eventInvalidated": false,
  "isVcardOverMmsDocument": false,
  "isForwarded": false,
  "isQuestion": false,
  "questionReplyQuotedMessage": null,
  "questionResponsesCount": 0,
  "readQuestionResponsesCount": 0,
  "labels": {
    },
  "hasReaction": false,
  "disappearingModeInitiator": "chat",
  "disappearingModeTrigger": "chat_settings",
  "productHeaderImageRejected": false,
  "lastPlaybackProgress": 0,
  "isDynamicReplyButtonsMsg": false,
  "isCarouselCard": false,
  "parentMsgId": null,
  "callSilenceReason": null,
  "isVideoCall": false,
  "callDuration": null,
  "callCreator": null,
  "callParticipants": null,
  "isCallLink": null,
  "callLinkToken": null,
  "isMdHistoryMsg": false,
  "stickerSentTs": 0,
  "lastUpdateFromServerTs": 0,
  "invokedBotWid": null,
  "bizBotType": null,
  "botResponseTargetId": null,
  "botPluginType": null,
  "botPluginReferenceIndex": null,
  "botPluginSearchProvider": null,
  "botPluginSearchUrl": null,
  "botPluginSearchQuery": null,
  "botPluginMaybeParent": false,
  "botReelPluginThumbnailCdnUrl": null,
  "botMessageDisclaimerText": null,
  "botMsgBodyType": null,
  "requiresDirectConnection": false,
  "bizContentPlaceholderType": null,
  "hostedBizEncStateMismatch": false,
  "senderOrRecipientAccountTypeHosted": false,
  "placeholderCreatedWhenAccountIsHosted": false,
  "galaxyFlowDisabled": false,
  "links": {
    }
  },
"mediaKey": "MEDIA_KEY_PLACEHOLDER",
"id": {
  "fromMe": true,
  "remote": "000000000000@c.us",
  "id": "MSG_ID_123456",
  "_serialized": "true_000000000000@c.us_MSG_ID_123456"
  },
"ack": 0,
"hasMedia": true,
"body": "Here's your requested image.",
"type": "image",
"timestamp": 1759108866,
"from": "111111111111@c.us",
"to": "000000000000@c.us",
"deviceType": "android",
"isForwarded": false,
"forwardingScore": 0,
"isStatus": false,
"isStarred": false,
"fromMe": true,
"hasQuotedMsg": false,
"hasReaction": false,
"vCards": {
  },
"mentionedIds": {
  },
"groupMentions": {
  },
"isGif": false,
"links": {
  }
}
Bad Request - Missing Required Parameter(s)
Unauthorized - Invalid or Missing Access Token
Not Found - Session Does Not Exist
Too Many Requests - Rate Limit Exceeded
Internal Server Error - Unexpected Failure
Bad Gateway - Connection Failed to Upstream
Previous TopicSend Image
Next TopicSend List Message

Command Palette

Search for a command to run...