Get a full-size picture in the response
How to get a media file via a link
When working with our API to receive messages containing images, you might notice that initially, only the preview information of the image is included in the response. This guide will help you understand how to retrieve the original, full-size images using two different methods.
Receiving Image Preview in the Response
When an image message is received, the initial response and callback include only the preview data. Here’s an example of such a response:
{
"id": "yRz1.VbdOFCdSWFGDPEYDg-gNEIDpL.CQ",
"from_me": false,
"type": "image",
"chat_id": "919984351847@s.whatsapp.net",
"timestamp": 1719323789,
"source": "mobile",
"image": {
,
"mime_type": "image/jpeg",
"file_size": 25950,
"sha256": "IKc25C+1fi7Q5+k4Pejd4+t+022TLlu94wkFQv0X5+Y=",
"caption": "Hello world",
"width": 356,
"height": 366,
"preview": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABsbGxscGx4hIR4qLSgtKj04MzM4PV1CR0JHQl2NWGdYWGdYjX2Xe3N7l33gsJycsOD/2c7Z//////////////8BGxsbGxwbHiEhHiotKC0qPTgzMzg9XUJHQkdCXY1YZ1hYZ1iNfZd7c3uXfeCwnJyw4P/Zztn////////////////CABEIAEgARQMBIgACEQEDEQH/xAAvAAADAQEBAAAAAAAAAAAAAAAAAwQFAgEBAQEBAQEAAAAAAAAAAAAAAAABAgME/9oADAMBAAIQAxAAAABnnNEqh8BR4SlT5PV0SYJp7OUn80JpZ+aeKWKVG4elKOBzf1naUwJpgqFGhK76wsTmuTQz4sfXmp118isnIU9qejRAFaIZ8iHhPQlIXqr0JrsC5//EACcQAAICAQMCBgMBAAAAAAAAAAECAAMRBBIhMVITFCIjUXEyQXIk/9oACAEBAAE/APDqC5LGYp7mntdzTNPe0zV3NM1d7TNXc0qvSroTDeX6QODQSRE0tZUHJh0teDyYteQxz+4EQDGyXKVORwDEoBUEsYaUQEkmVHiY/wAxg1tqjEGuthu2qCByTPNvDe1mcjpBrXAxieass9OJSuRFG6kfctrBdFwOZYtK7QFE8EWbyOgMXT7kJl1K0gH5EVqc85gID8N+5RwsrxsXPdLWUOhhUbx9TTqVFuR1PErGA2ZrhkJGqCkwjDKZQ2Vin2l+d01FNrkFSMS6y6vaSw+JQGNQLGNnBxNVbl1GYRliR2x81lZpz6YnKJ/UtXdWyynT7mG45hqR0EAC8TVUpsZwPVNLnBzNWPWk0/4RDsVP6hOTLNtQb5MocihIWBaak+0ZU+wMZe6v4eDKOFhO5dpifgPqX0eMwMBeupUCdIbH7ZY7OpUrxF06/EOkA52wHYSAJ//EABoRAAMBAQEBAAAAAAAAAAAAAAABESEQIEH/2gAIAQIBAT8A00033eJ51/BE3rKVlKf/xAAjEQABAwMEAgMAAAAAAAAAAAABAAIDERMhBBAxQRIgMmFy/9oACAEDAQE/AMLCwse7pGtcGk5KmkcwN8RUqKYSj7CHB21mCx3ajNx1zoCgVotlD2cH5DfWCtv9LTgWWqioFRf/2Q=="
},
"from": "919984351847",
"from_name": "Jonathan"
},
1. Automatically extract the original image or file into a link
Enable "Auto Download" Setting
By enabling the "Auto Download" setting in your channel settings, you can receive a link to the original image or file directly in the response. This link will be accessible for 30 days as we store these files in the cloud. To enable this setting, please follow the instructions provided here: Setting "Auto Download"
Example Response with Auto Download Enabled
{
"id": "YLO7_qNlFMsjIEZ1m7Lmxg-gFcIDpL.CQ",
"from_me": false,
"type": "image",
"chat_id": "919984351847@s.whatsapp.net",
"timestamp": 1719324086,
"source": "mobile",
"image": {
"id": "jpeg-60b3bbfea3652046759bb14cb232e6c6-8057080e92fe09",
"mime_type": "image/jpeg",
"file_size": 41490,
"sha256": "NYegMy3NmhxO4oKgi7qlMy/8p9zqcGU4Gtgu3l8bTAg=",
"caption": "Hello",
"width": 1050,
"height": 700,
"preview": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABsbGxscGx4hIR4qLSgtKj04MzM4PV1CR0JHQl2NWGdYWGdYjX2Xe3N7l33gsJycsOD/2c7Z//////////////8BGxsbGxwbHiEhHiotKC0qPTgzMzg9XUJHQkdCXY1YZ1hYZ1iNfZd7c3uXfeCwnJyw4P/Zztn////////////////CABEIACwAQgMBIgACEQEDEQH/xAAwAAACAwEBAAAAAAAAAAAAAAADBQACBAEGAQADAQEAAAAAAAAAAAAAAAAAAgMBBP/aAAwDAQACEAMQAAAAYhaeV5el3szm1ezgTE+9H6GddktFlxG0DVlTsHXlow8uyqGxd6WwRjJOmqO7BzZrbLVQFwLcFDdcWQb/xAAlEAACAgECBQUBAAAAAAAAAAABAgADEQQSBRAhMVETFCJBQmH/2gAIAQEAAT8AGirAyXMFemazYLjuMq0S0tkMYTyJwCY+oZ2bJ6ZnD1yWabYV3KQZqgdLfkfRlF4vqVxz1BxS8YPX37Th/SkGZj2bO4nEwuoQMgO4ThpvoJV0O2JYW/JhJmtsYIABPk5G4YErFgACg4mLvBhs8whX+WIrHJENmPMLuf0YNPbYAd8GjbyDFXaBiZaFyRPUtAwD0i22eRFvP3C5PYw/0wWMPueuwnuliEkcgOXbtFYmGMZvM//EABsRAAIDAQEBAAAAAAAAAAAAAAARAQIhURIT/9oACAECAQE/AIpXghE0UiIvo3qEXr6PnHZIwZo5NP/EAB0RAAICAgMBAAAAAAAAAAAAAAABAhESIRMiUWL/2gAIAQMBAT8AU5NPsxv0THK4stmFIZbITo5flEtjRoSRjE//2Q=="
},
"from": "919984351847",
"from_name": "Jonathan"
}
An additional link
parameter appears, which stores a link to the original file.
2. Retrieve Original Image/File via 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.
Remember that you can get information about the message not only from the webhook, but also by executing the HTTP request “Get message”.
Let's see what this Media ID looks like using the example of an incoming message webhook:
"image": {
,
Example of Using the Get Media Endpoint
First, make a GET request to the endpoint with the media ID
received in the initial response:
Endpoint: GET /media/{media-id}
In the case of our example, the media id is jpeg-60b3bbfea3652046759bb14cb232e6c6-8057080e92fe09
curl --request GET \
--url https://gate.whapi.cloud/media/jpeg-60b3bbfea3652046759bb14cb232e6c6-8057080e92fe09 \
--header 'accept: application/pdf' \
--header 'authorization: Bearer iwpVwcco2bBdvShV4sbzBNB1BDCXPmcs'
Important Notes: The response body contains the actual file, not just a URL!
What does this mean? It means that services such as Readme.io and other visual test shells will not allow you to save the file when you make a request.
Use Postman or your IDE to save the file from the response body.
Last updated
Was this helpful?