Skip to content

Send Media Message ​

Send images, videos, documents, or audio files to a WhatsApp recipient. The file is fetched from the public HTTPS URL you provide and delivered to that recipient.

Endpoint ​

http
POST /whatsapp/send-media/:instance
  • :instance: The name of your WhatsApp instance.

Request Body ​

ParameterTypeRequiredDescription
recipientstringYesThe recipient's WhatsApp number with country code (e.g., 254123456789) or the full sender address from a webhook (e.g., 123456789012345@lid or [email protected]). Send @lid addresses exactly as received; do not format them or remove the suffix.
mediatypestringYesThe type of media: image, video, document, or audio.
mimetypestringYesThe MIME type of the file (e.g., image/jpeg, video/mp4, application/pdf).
captionstringNoAn optional caption to display with the media message.
mediastringYesA public HTTPS URL to the media file.
fileNamestringNoA file name shown to the recipient (e.g., invoice.pdf). Recommended for documents.

The media URL must use HTTPS

media must be a publicly accessible URL that starts with https://. Local files, Base64 strings, and plain http:// URLs are not accepted.

Supported Media Types ​

mediatypeTypical useExample mimetype
imagePhotosimage/jpeg, image/png
videoVideosvideo/mp4
documentFiles such as PDFsapplication/pdf
audioAudio filesaudio/mpeg, audio/ogg

Sending voice notes

To send a native WhatsApp voice note instead of an audio file, use the Send Audio Message endpoint with voiceNote: true.

Example Payload ​

json
{
  "recipient": "254123456789",
  "mediatype": "image",
  "mimetype": "image/jpeg",
  "caption": "Check out this beautiful photo!",
  "media": "https://example.com/image.jpg",
  "fileName": "photo.jpg"
}

Examples ​

bash
curl -X POST https://api.chatbreez.com/whatsapp/send-media/{instance} \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "recipient": "254123456789",
    "mediatype": "image",
    "mimetype": "image/jpeg",
    "caption": "Hello with an image!",
    "media": "https://example.com/image.jpg",
    "fileName": "image.jpg"
  }'
javascript
const axios = require('axios');

const sendMedia = async () => {
  try {
    const response = await axios.post('https://api.chatbreez.com/whatsapp/send-media/{instance}', {
      recipient: '254123456789',
      mediatype: 'image',
      mimetype: 'image/jpeg',
      caption: 'Hello with an image!',
      media: 'https://example.com/image.jpg',
      fileName: 'image.jpg'
    }, {
      headers: {
        'X-API-Key': 'your_api_key'
      }
    });
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
};

sendMedia();
python
import requests

url = "https://api.chatbreez.com/whatsapp/send-media/{instance}"

payload = {
    "recipient": "254123456789",
    "mediatype": "image",
    "mimetype": "image/jpeg",
    "caption": "Hello with an image!",
    "media": "https://example.com/image.jpg",
    "fileName": "image.jpg"
}

headers = {
    "Content-Type": "application/json",
    "X-API-Key": "your_api_key"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.chatbreez.com/whatsapp/send-media/{instance}"

	payload := map[string]interface{}{
		"recipient":  "254123456789",
		"mediatype":  "image",
		"mimetype":   "image/jpeg",
		"caption":    "Hello with an image!",
		"media":      "https://example.com/image.jpg",
		"fileName":   "image.jpg",
	}
	body, _ := json.Marshal(payload)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("X-API-Key", "your_api_key")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer resp.Body.Close()

	respBody, _ := io.ReadAll(resp.Body)
	fmt.Println(string(respBody))
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://api.chatbreez.com/whatsapp/send-media/{instance}";
        String json = """
            {
              "recipient": "254123456789",
              "mediatype": "image",
              "mimetype": "image/jpeg",
              "caption": "Hello with an image!",
              "media": "https://example.com/image.jpg",
              "fileName": "image.jpg"
            }
            """;

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .header("Content-Type", "application/json")
            .header("X-API-Key", "your_api_key")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpClient client = HttpClient.newHttpClient();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
php
<?php

$url = 'https://api.chatbreez.com/whatsapp/send-media/{instance}';

$payload = json_encode([
    'recipient' => '254123456789',
    'mediatype' => 'image',
    'mimetype' => 'image/jpeg',
    'caption' => 'Hello with an image!',
    'media' => 'https://example.com/image.jpg',
    'fileName' => 'image.jpg',
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-API-Key: your_api_key',
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Response ​

json
{
  "message": "Media message queued for delivery.",
  "messageId": "3EB0C767D097B7C7C030"
}

Keep the messageId if you need to reference the message later when investigating a delivery.

Common Errors ​

Errors are returned as JSON in this shape:

json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "media: Media URL must use HTTPS",
    "correlationId": "abc123-def456-ghi789"
  }
}
StatusCodeMeaning
400VALIDATION_ERRORThe request body is invalid, the media URL is not HTTPS, or the recipient is not registered on WhatsApp.
401UNAUTHORIZEDMissing or invalid API key.
403FORBIDDENYour account is deactivated. Contact support to reactivate it.
404NOT_FOUNDThe instance does not exist.
409CONFLICTThe instance is not connected to WhatsApp. Reconnect it and try again.
502UPSTREAM_ERRORWhatsApp did not acknowledge the message. Try again shortly.
500INTERNAL_SERVER_ERRORAn unexpected error occurred on our side. Try again shortly.

Next Steps ​