Skip to content

Send Media Message ​

Send images, documents, or audio files to a WhatsApp number.

Endpoint ​

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

Request Body ​

ParameterTypeRequiredDescription
recipientstringYesThe recipient's WhatsApp number (e.g., 254123456789).
mediatypestringYesThe type of media (image, document, or audio).
mimetypestringYesThe MIME type of the file (e.g., image/jpeg).
captionstringYesA caption for the media message.
mediastringYesThe media content (Base64 encoded string or URL).
fileNamestringYesThe name of the file (e.g., invoice.pdf).

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();