How to retrieve files
How developers can retrieve any type of file (document, image, audio, video, etc.) from WhatsApp messages using Whapi.Cloud's API
Method 1: Get the File by Media ID Using the Get Media Endpoint
Webhook Example (Message with PDF document)
{
"messages": [
{
"id": "tGZmYoiXecvbKahzwpwKmg-gEcTwl0rVw",
"from_me": false,
"type": "document",
"chat_id": "[email protected]",
"timestamp": 1713201784,
"source": "mobile",
"document": {
"id": "pdf-b487668896662779cbdb29a3c29c0a9a-804713c25d2b57",
"mime_type": "application/pdf",
"file_size": 1438781,
"sha256": "TdxdgX8lBzV6/SYW96F/BEh19ob0eFAn4wKAWhWpUyk=",
"file_name": "File_example.pdf",
"link": "https://s3.eu-central-1.wasabisys.com/in-files/61371989950/pdf-b487668896662779cbdb29a3c29c0a9a-804713c25d2b57.pdf",
"caption": "This is text with file",
"filename": "File_example.pdf",
"page_count": 14,
"preview": "data:image/jpeg;base64,/9j/4AAQSkZJ.........."
},
"from": "919984351847",
"from_name": "Gerald"
}
],
"event": {
"type": "messages",
"event": "post"
},
"channel_id": "MANTIS-M72HC"
}Step-by-step instructions to obtain this file:
Method 2: Enable Auto Download and Use the File URL
How to Enable It:
1

2

What Happens Next:
How it works?
Conclusion
Last updated