Send Media Message via WhatsApp Instance
POST
/v1/instance/{{INSTANCE_ID}}/message/send/mediaThis API allows sending a media message (e.g., images, videos, documents) through a specific WhatsApp instance. You can use either a base64
encoded media string or a media_url
to specify the media to be sent. Only one of these two fields is required, not both.
Request Parameters
Path Parameters
instance_id
(string) - The unique identifier of the WhatsApp instance. Replace61d747a3
with your actual instance ID.
Headers
Authorization
(string, required) - Bearer token for authentication. Replace{{ZAPLY_AUTH_TOKEN}}
with your API token.Content-Type
(string, required) - Specifies that the request body is in JSON format. Useapplication/json
.
Request Body
The body should be in JSON format and include the following parameters:
number
(string, required) - The phone number of the recipient, including the country code.- Example:
"918367875645"
- Example:
media_caption
(string, optional) - Caption text to be included with the media file.- Example:
"Check out this image!"
- Example:
media_name
(string, required) - The file name of the media being sent.- Example:
"Filename.png"
- Example:
base64
(string, optional) - Base64 encoded string of the media file. If provided,media_url
is not required.- Example:
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
- Example:
media_url
(string, optional) - Direct URL to the media file. If provided,base64
is not required.- Example:
"https://example.com/images/sample.png"
- Example:
Note: Either base64
or media_url
is required. If both are provided, base64
takes precedence.
Error Codes
400 Bad Request
- Invalid input parameters (e.g., missing required fields).401 Unauthorized
- Invalid or missingAuthorization
token.404 Not Found
- Instance ID does not exist.500 Internal Server Error
- Server encountered an unexpected condition.
Request
{
"number": "918147069203",
"media_caption": "Check out this image!",
"media_name": "Filename.png",
"media_url": "https://fastly.picsum.photos/id/195/536/354.jpg?hmac=8JxyDR_BWRmceDkbJHlE2tw93E2AQ96jI-Qpv40-ZXc"
}
Request samples
Responses
{}