/v1/messages
Use the messages
node to send text messages, media/documents, and message templates to your customers.
See the following documentation for information regarding the specfic types of messages you can send:
You will need:
Message API calls are sent to the /messages
node regardless of message type, but the content of the JSON message body differs for each type of message (text, image, etc.).
POST /v1/messages { "recipient_type": "individual", "to": "whatsapp-id", "type": "audio" | "contact" | "document" | "hsm" | "image" | "location" | "text" | "video", "audio": { "id": "your-media-id", } "document": { "id": "your-media-id", "caption": "your-document-caption-to-be-sent", "filename": "your-document-filename" } "document": { "link": "http(s)://the-url" "provider": { "name" : "provider-name" } "caption": "your-document-caption" } "video": { "link": "http(s)://the-url" "provider": { "name" : "provider-name" } "caption": "your-video-caption" } } "text": { "body": "your-message-content" } }
The above sample shows different objects such as audio, document, and text for illustration purposes only. A valid request body contains only one of them.
The response includes a combination of following components: meta
, messages
(payload), and errors
. See WhatsApp Business API Responses for more information.
The following shows an example of payload
in a response; the meta and error objects are omitted for brevity.
{ "messages": [{ "id": "message-id" }] }
If the request is successful, you will receive a response with a message ID. If the request returns an errors
section, check the originating message and correct the errors before resending the request.
For more information about errors, see:
When a message is sent in a request, the customer will receive a message such as this:
This image displays messages of the following types, from top to bottom:
Cut-off control prevents messages from being delivered to users in certain conditions.
If a message does not meet any of these requirements an error code is sent. Please find more about error codes here.