Help Desk
  • Getting Started
    • ๐Ÿ™ŒWelcome to Whapi.Cloud
    • ๐Ÿ’ฐPricing
    • โ˜•Partners
    • ๐Ÿš€Getting started
    • ๐Ÿ‘จโ€๐Ÿ’ปAPI Docs
      • Developer hubs
      • Swagger environment
      • Postman collection
  • Sending
    • Introduction
    • Send text message
      • Whatsapp API send message PHP
      • Whatsapp API send message Python
      • Whatsapp API send message Node JS
      • Whatsapp API send message ะก#
      • Whatsapp API send message Java
      • API integration with VB6
      • Whatsapp API send message GO (Golang)
    • Send video, audio, image, document
      • How to send file from your local computer using the API
    • Send Group message
    • Send post to WhatsApp Channel
    • Send message with Buttons
    • Send Emoji
    • Overview of other methods for sending
      • Send Voice message
      • Send contact (vCard)
      • Send message reactions
  • Receiving
    • Introduction
    • Webhooks
      • Our webhooks (Tracked events)
      • Where to Find the Webhook URL?
      • Set the webhook link to the channel
      • Detailed webhook settings
      • How to check the webhook?
      • Incoming webhooks format
        • Incoming message
        • Sent message
        • Chats
          • How to Track Chat Labels via Webhook
        • Groups
        • Communities
        • Contacts
        • Account and device status
        • Other
          • Calls
          • Presences
          • Labels
          • Views of stories (statuses)
          • Story (status) from your contacts
      • Receive messages
        • Receive WhatsApp messages using PHP
        • Receive WhatsApp messages using Node js
        • Receive WhatsApp messages using Python
    • HTTP API
      • How to retrieve files
      • Retrieve a Specific User's Chat History
      • Get a full-size picture in the response
      • Get order items
      • Get a profile picture of a chat or user
    • File expiration period
  • Groups
    • Send Group message
      • Mentioning all participants in a WhatsApp group
    • Get list of group members
    • Add new member to Group
  • Channels
    • Send post to WhatsApp Channel
    • Get messages from Channels
    • Get votes from polls in the Channel
  • Communities
    • Introduction
    • Create a community
    • Add a member to a community
    • Send announcement
    • Get info on community participants
    • Add a group / Exclude a group from the community
  • Account
    • Setting "Auto Download"
    • Customizable Webhook Headers
    • How to find out the IP channel
    • How to Delete a Channel
    • Add Business Info to Invoice
  • Source code
    • WhatsApp ChatBot
      • WhatsApp Python Bot
      • WhatsApp PHP Bot
      • WhatsApp Node JS Bot
      • WhatsApp Java Bot
    • WhatsApp API Google Sheets
    • WhatsApp Phone Number Checker
    • Request Distributor (Balancer)
  • FAQ
    • Does WhatsApp API work with the phone turned off?
    • Chat ID. What is it and how to get it?
    • Why do I see status "pending" after sending message?
    • How to send a paragraph (line break)
    • Inactive Links in WhatsApp Messages
    • WhatsApp Text Formatting
    • Checking if the number has Whatsapp
    • Specifics of sending messages to numbers of different countries
    • Current status of Buttons on WhatsApp
    • Why aren't participants being added to the group?
  • Hints
    • Android Emulators
    • Virtual Numbers for WhatsApp
    • How to use polls as buttons?
    • How to check who blocked you in Whatsapp?
    • Setting up a WhatsApp proxy
  • Integrations
    • Make.com
      • Ready-Made Scenarios
        • WhatsApp & Whisper API: Voice-to-Text Integration
        • Automated WhatsApp Group Message Forwarding in Make.com
      • Request Scenario Setup
    • Pabbly Connect
    • Google Contacts
    • DialogFlow
    • n8n
  • Tools
    • WhatsApp Number Checker
    • Automatic warm-up module
    • WhatsApp Activity Safety Meter
    • Residential Proxies from Whapi.Cloud
  • Troubleshooting
    • Couldn't Link Device โ€“ WhatsApp QR Code or Pairing Code Fails
    • Channel status โ€œSYNC_ERRORโ€
    • Not getting a READ status on webhook
    • 429 (Too Many Requests) - Soft Ban
    • โ€œWaiting for this message. This may take a whileโ€ โ€“ WhatsApp Message Error
    • Missing push notifications after connecting to API
  • Blocking
    • How to not get Banned?
    • How to do mailings without the risk of being blocked?
    • If My Number Is Banned, Can It Be Restored?
    • Unlocking Your WhatsApp Number
    • Connecting a New WhatsApp Number After a Ban: Steps and Recommendations
    • Warming Up New Phone Numbers for WhatsApp API
  • Partner Documentation
    • Introduction
    • Partner Dashboard Overview
    • Partner Program Guidelines
      • Workflow: Step-by-Step
      • Billing for Partners
      • Allocating Days to Customer Channels: Best Practices & Guide
      • Interface for channel management
    • Partner Documentation
      • Channel creation
      • Changing channel mode
      • Channel extension
      • Channel deletion
      • Getting the list of channels
      • Notices of end of days on balance
Powered by GitBook
On this page
  • Method 1: Get the File by Media ID Using the Get Media Endpoint
  • Method 2: Enable Auto Download and Use the File URL
  • Conclusion

Was this helpful?

  1. Receiving
  2. HTTP API

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

If your system receives messages from users and you need to download the source files for internal processing, storage, or forwarding, you will find it useful to learn about two different ways to achieve this goal.

Whapi.Cloud provides programmatic access to media files received in WhatsApp chats or groups, regardless of whether the file is a PDF, image, audio recording, or video. You can either download the file directly via the API or set up automatic cloud storage using download links.

Method 1: Get the File by Media ID Using the Get Media Endpoint

When your webhook receives an incoming message that includes a file, you'll see a field such as document.id, image.id, or video.id. This is the Media ID โ€” a unique identifier of the file stored temporarily on the WhatsApp server.

Webhook Example (Message with PDF document)

{
  "messages": [
    {
      "id": "tGZmYoiXecvbKahzwpwKmg-gEcTwl0rVw",
      "from_me": false,
      "type": "document",
      "chat_id": "919984351847@s.whatsapp.net",
      "timestamp": 1713201784,
      "source": "mobile",
      "document": {
        
        "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:

1) Capture the webhook from an incoming message or receive a message via an HTTP call; 2) Extract the Media ID from the corresponding media object; 3) Make the GET Media request to the following endpoint: GET /media/{media-id}

Example:

curl --request GET \
     --url https://gate.whapi.cloud/media/pdf-b487668896662779cbdb29a3c29c0a9a-804713c25d2b57 \
     --header 'accept: application/pdf' \
     --header 'authorization: Bearer <YOUR_API_TOKEN>'

Important Notes: The response body contains the actual file, not just a URL!

Method 2: Enable Auto Download and Use the File URL

Whapi.Cloud provides an optional setting that enables automatic uploading of incoming media to secure cloud storage. With this setting active, each incoming file includes a direct public link.

How to Enable It:

  • Go to your channel settings;

  • Enable the toggle: "Auto Download";

What Happens Next:

How it works?

Enabling the setting will add the Link parameter to the JSON array, where you will immediately receive a direct link to the file:

The link to the media files processed by your number at the time of the enabled setting is bound to the message, which means that you will be able to get a link to the media file via API Call.

Conclusion

Whapi.Cloud offers two powerful methods to retrieve files from WhatsApp:

  • Use the Get Media endpoint when you want to control file retrieval manually.

  • Enable Auto Download for easier, automated access with public links.

PreviousHTTP APINextRetrieve a Specific User's Chat History

Last updated 2 days ago

Was this helpful?

You can find detailed instructions in the article:

When a file is received, Whapi uploads it to cloud storage. The webhook payload will include a link parameter in the media object. The file is retained in the cloud for 30 days, after which it is deleted. .

With the "Auto Download" setting enabled, you get a direct link to the file

Both approaches are developer-friendly and ensure you always get the original file in its correct format. - -

Setting Auto Download
Read more about file storage periods
Get Media API Reference
Auto Download Setup Guide
Get mediaWhapi Cloud - Whatsapp API for developers
Try this endpoint right now!
Logo