Appearance
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
| Parameter | Type | Required | Description |
|---|---|---|---|
recipient | string | Yes | The recipient's WhatsApp number (e.g., 254123456789). |
mediatype | string | Yes | The type of media (image, document, or audio). |
mimetype | string | Yes | The MIME type of the file (e.g., image/jpeg). |
caption | string | Yes | A caption for the media message. |
media | string | Yes | The media content (Base64 encoded string or URL). |
fileName | string | Yes | The 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/my-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/my-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();