# Send video, audio, image, document

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 [link](https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/media#supported-media-types) you can find everything that you need to know about formatting and file sizing.<br>

Examples of supported files:

**Videos**: .3gp, .mp4 (H.264), up to 100 MB

Documents: up to 2 GB

**Images**: JPEG, PNG

Whapi Cloud supports sending **high-resolution (HD) images**.\
Such images are automatically marked with the **HD** label in the recipient’s WhatsApp interface.

This allows you to deliver images in maximum quality, similar to manually sending HD photos in the official WhatsApp application.<br>

***

\
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](https://support.whapi.cloud/help-desk/sending/send-video-audio-image-document/how-to-send-file-from-your-local-computer-using-the-api "mention");
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](https://support.whapi.cloud/help-desk/receiving/file-expiration-period "mention");

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 :)

{% hint style="info" %}
***IMPORTANT*** if you opt for a base64 before binary you will need to add the following expression **data:image/png;base64, \*&#x20;*****your base64 code*****&#x20;\***
{% endhint %}

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:&#x20;

{% embed url="<https://panel.whapi.cloud/tools/base64-encode>" %}
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.
{% endembed %}

#### How to generate Base64 in your code:

{% tabs %}
{% tab title="Python" %}

<pre class="language-python"><code class="lang-python"><strong>import base64
</strong>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}"

</code></pre>

{% endtab %}

{% tab title="PHP" %}

```php
<?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;

```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const fs = require('fs');
const base64 = fs.readFileSync('file.png', 'base64');
const media = `data:image/png;name=file.png;base64,${base64}`;

```

{% endtab %}
{% endtabs %}

***

### 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](https://support.whapi.cloud/help-desk/sending/send-video-audio-image-document/how-to-send-file-from-your-local-computer-using-the-api "mention")

***

### 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](https://support.whapi.cloud/help-desk/receiving/file-expiration-period "mention")

{% embed url="<https://youtu.be/9cV9sXsJm8w>" %}
Video manual
{% endembed %}

***

### Endpoint references:

#### Send Image (via URL / Base64 / upload to cloud) <a href="#send-image" id="send-image"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessageimage>" %}

#### Send Document (via URL / Base64 / upload to cloud) <a href="#send-document" id="send-document"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessagedocument>" %}

#### Send Audio (via URL / Base64 / upload to cloud) <a href="#send-audio" id="send-audio"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessageaudio>" %}

#### Send Voice <a href="#send-voice" id="send-voice"></a>

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 [article](https://support.whapi.cloud/help-desk/sending/overview-of-other-methods-for-sending/send-voice-message).

{% embed url="<https://whapi.readme.io/reference/sendmessagevoice>" %}

#### Send Video (via URL / Base64 / upload to cloud) <a href="#send-video" id="send-video"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessagevideo>" %}
