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
  • Sending media file by link
  • Sending media file via Base64
  • Sending media file from local
  • Sending by Media ID
  • Endpoint references:

Was this helpful?

  1. Sending

Send video, audio, image, document

Endpoint for easy send media-file as message

PreviousWhatsapp API send message GO (Golang)NextHow to send file from your local computer using the API

Last updated 12 days ago

Was this helpful?

You can work with different types of files and it makes no difference what extension the document has. WhatsApp limits the sizes of files and its politics constantly changes and because of that we always recommend that you verify directly on WhatsAppโ€™s website. In this you can find everything that you need to know about formatting and file sizing.

Your file must be provided in the required media parameter. There are four supported ways to do this:

  1. Upload from file โ€“ Send the actual file content directly (e.g., using multipart/form-data). Read more here: How to send file from your local computer using the API;

  2. Upload from URL โ€“ Provide a direct public URL to the file;

  3. Upload as Base64 โ€“ Convert the file to Base64 and send it with a data: prefix;

  4. Use media ID โ€“ Reuse a previously uploaded file by referencing its media_id . The file will be uploaded to the cloud and stored there for 30 days. Read more about it here: File expiration period;

Each method works with all media message endpoints โ€” choose the one that best fits your workflow.


Sending media file by link

If you have a direct link to an image that is posted somewhere on the internet. It is important that it is the file that is accessible via the direct link.

Example:

{
  "to": "14045648921",
  "media": "https://filesamples.com/samples/image/jpeg/sample_640%C3%97426.jpeg"
}

Sending media file via Base64

In which case you will need to have a method in your application to convert the image to Base64. To make sure the conversion is successful, copy the generated base64 and paste it into your browser's address bar, if it is a valid image the browser will be able to display it, if the browser can't, check your method :)

IMPORTANT if you opt for a base64 before binary you will need to add the following expression data:image/png;base64, * your base64 code *

You can also manually recode the file and specify the result in your application. To do this, you can use our handy tool to encode any file into Base64 format:

How to generate Base64 in your code:

import base64
with open("file.png", "rb") as f:
    encoded = base64.b64encode(f.read()).decode('utf-8')

media = f"data:image/png;name=file.png;base64,{encoded}"
<?php
$filePath = 'file.png';
$mimeType = mime_content_type($filePath); // Automatically detect MIME type
$fileName = basename($filePath);
$base64 = base64_encode(file_get_contents($filePath));

$media = "data:{$mimeType};name={$fileName};base64,{$base64}";

// Resulting $media string can now be sent in the API request body
echo $media;
const fs = require('fs');
const base64 = fs.readFileSync('file.png', 'base64');
const media = `data:image/png;name=file.png;base64,${base64}`;

Sending media file from local

Want to send a file from your local computer using the API? Learn how to properly attach and send media using multipart/form-data โ€” with ready-to-use examples in Python, PHP, Node.js, and cURL.

Read the full guide โ†’ How to send file from your local computer using the API


Sending by Media ID

Via MediaID, in this case after automatically uploading the file to the cloud, you will get a media ID that you can use in the future. Read more: File expiration period


Endpoint references:

Send Image (via URL / Base64 / upload to cloud)

Send Document (via URL / Base64 / upload to cloud)

Send Audio (via URL / Base64 / upload to cloud)

Send Voice

Send Video (via URL / Base64 / upload to cloud)

You can Send a ppt audio recording to the phone number or group, But WhatsApp is sensitive to this extension, you need to be in OGG format and the codecs should be the opus. Our API has an automatic video and audio converter for the necessary codecs compatible with WhatsApp. For more information, you can check out this .

link
article
https://panel.whapi.cloud/tools/base64-encodepanel.whapi.cloud
Allows you to convert any local file to Base64. You can copy the Base64 string to clipboard and conveniently send the file through the desired endpoint.
Video manual
๐Ÿ–ผ Send media-image messageWhapi Cloud - Whatsapp API for developers
๐Ÿ“‘ Send media-document messageWhapi Cloud - Whatsapp API for developers
๐ŸŽต Send media-audio messageWhapi Cloud - Whatsapp API for developers
๐ŸŽค Send media-voice messageWhapi Cloud - Whatsapp API for developers
๐ŸŽฅ Send media-video messageWhapi Cloud - Whatsapp API for developers
Logo
Logo
Logo
Logo
Logo