Sending Media Messages

/v1/messages

Use the messages endpoint to send messages containing audio, images, or documents to your customers. Sending video in messages is not supported.

When you send a message that includes media, you must provide the ID of the uploaded media in the request body. You must also specify the type of media that you are sending: audio, image, or document. When the request is received, the media is uploaded to the WhatsApp server and sent to the user indicated in the to field.

This document covers:

Prerequisites

Request

After you upload the media with an API call to the media endpoint, use the returned ID for the id field.

POST /v1/messages 
{
    "recipient_type": "individual" | "group",
    "to": "whatsapp-id" | "whatsapp_group_id",
    "type": "audio" | "document" | "image",

    "audio": {
      "id": "your-media-id",
    }

    "document": {
       "id": "your-media-id",
       "caption": "your-document-caption"
    }

    "image": {
       "id": "your-media-id",
       "caption": "your-image-caption"    
    }
}

Parameters

NameRequiredDescription

recipient_type

No

Options: individual (default), group
Determines whether the recipient is an individual or a group
Specifying recipient_type in the request is optional when the value is individual. However, recipient_type is required when using group. See the Sending Group Messages documentation for more information.

to

Yes

When recipient_type is individual, this field is the WhatsApp ID (phone number) returned from contacts endpoint. When recipient_type is group, this field is the WhatsApp group ID.

type

Yes, when type is image, audio, or document.

Options: text (default), image, audio, document, hsm
For text messages, see the Sending Text Messages documentation for more information. For Message Temaples, see the Sending Message Templates documentation for more information.

audio

Yes, when "type": "audio".

The media object containing audio

document

Yes, when "type": "document".

The media object containing a document

image

Yes, when "type": "image".

The media object containing an image

The audio, document, and image objects

NameRequiredDescription

id

Yes, when type is image, audio, or document.
Forbidden for "type:" "text".

The media object ID, which is returned when the media is successfully uploaded to the WhatsApp Business API Client with the media endpoint.

caption

No

Describes the specified image or document media. Do not use with audio media.

Response

The successful response includes a messages object with a message ID.

{
  "messages": [{
    "id": "gBEGkYiEB1VXAglK1ZEqA1YKPrU"
  }]
}  

An unsuccessful response will contain an error message. See Error and Status Codes for more information on errors.