Zaply
HomeWebsite
HomeWebsite
  1. Send Messages
  • Overview
  • Send Messages
    • Send Message via WhatsApp Instance
      POST
    • Send Media Message via WhatsApp Instance
      POST
    • Send Location Message via WhatsApp Instance
      POST
    • Send Contact Message via WhatsApp Instance
      POST
  • Instance Settings
    • Set Settings
      POST
    • Get Settings
      GET
  • Connection
    • Get QR Code for WhatsApp Connection
      GET
  • Manage Instance
    • Create Instance
      POST
    • Get Instance
      GET
    • Delete Instance
      DELETE
  1. Send Messages

Send Media Message via WhatsApp Instance

POST
https://api.zaply.dev/v1/instance/{{INSTANCE_ID}}/message/send/media
This 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. Replace 61d747a3 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. Use application/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"
media_caption (string, optional) - Caption text to be included with the media file.
Example: "Check out this image!"
media_name (string, required) - The file name of the media being sent.
Example: "Filename.png"
base64 (string, optional) - Base64 encoded string of the media file. If provided, media_url is not required.
Example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
media_url (string, optional) - Direct URL to the media file. If provided, base64 is not required.
Example: "https://example.com/images/sample.png"
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 missing Authorization token.
404 Not Found - Instance ID does not exist.
500 Internal Server Error - Server encountered an unexpected condition.

Request

Header Params
Authorization
string 
required
Example:
Bearer {{ZAPLY_AUTH_TOKEN}}
Body Params application/json
number
string 
required
media_caption
string 
required
media_name
string 
required
base64
string 
required
media_url
string 
required
Example
{
    "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

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location -g --request POST 'https://api.zaply.dev/v1/instance/{{instance_id}}/message/send/media' \
--header 'Authorization: Bearer {{ZAPLY_AUTH_TOKEN}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "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"
}'

Responses

🟢200Success
application/json
Body
object {0}
Example
{}
Modified at 2024-10-15 07:02:22
Previous
Send Message via WhatsApp Instance
Next
Send Location Message via WhatsApp Instance
Built with