Messaging

This documentation describes how to start sending messages to your users.

Introduction

Message API calls are sent to the /messages endpoint regardless of message type, but the content of the JSON message body differs for each type of message (text, image, etc.). See the following documentation for information regarding the type of messages you want to send:

Check out the Best practices on how to approach customers.

Check contacts

Before sending a message, make sure you meet the prerequisites and query the /v1/contacts endpoint for each number. Otherwise, you may receive a "Resource not found - unknown contact" error.

Before sending a message to a number, you must check the contact availability. With this procedure, you validate the number and verify the user's identity. More information on this process can be found in the official Documentation.

post
/v1/contacts

https://waba.360dialog.io/v1/contacts
Request
Response
Request
Body Parameters
blocking
optional
string
no_wait (default), wait
contacts
required
array
+4912345678910
force_check
optional
boolean
false (default), true
Response
200: OK
{
"contacts": [ {
"input": "+55123456789",
"wa_id": "55123456789",
"status": "valid" <- we can send messages to valid contacts only
}]
}

Example Request:

POST https://waba.360dialog.io/v1/contacts
{
"blocking": "wait",
"contacts": [
"+55123456789"
],
"force_check": true
}

post
/v1/messages

https://waba.360dialog.io/v1/messages
Remember to use your WhatsApp Business API key to authorize requests. To send a message, just use the above request URL and the following body parameters.
Request
Response
Request
Body Parameters
recipient_type
optional
string
individual
to
required
string
wa_id from /v1/contacts request
type
optional
string
text (default)
text
required
object
contains body field
Response
201: Created
{
"messages": [
{
"id": "gBGHSRUUIXKJTwIJVQgXRR0rdXiv"
}
],
"meta": {
"api_status": "stable",
"version": "2.31.5"
}
}

Example Request:

POST https://waba.360dialog.io/v1/messages
{
"recipient_type": "individual",
"to": "55123456789", <- wa_id from /v1/contacts request
"type": "text",
"text": {
"body": "Hello, dear customer!"
}
}

Message Templates

Please refer to our documentation on Message Templates, which includes the steps required to get your Templates approved, and the process for creating and deleting them.

  • Each WhatsApp Business Account can have up to 250 message templates (how many is determined by your plan). That means 250 message template names, and each of them can have multiple language translations. For example, a message template called hello_world translated into two languages counts as a single message template in regards to this limit.

  • The message template name field is limited to 512 characters.

  • The message template content field is limited to 1024 characters.

  • There is no limit to the number of parameters allowed in a Message Template.

360dialog stores media files for 14 days after upload. Media files older than 14 days may be deleted by 360dialog without prior notice.

Error scenarios:

  • 400: Bad Request Check that you are using the correct data type for Booleans and Strings, and that the JSON-payload is well-formed. Use an online tool (ex. JSON formatter and validator) to validate the payload if you are not sure.

Booleans don't need double quotes!
  • 408: Message failed to send because it was pending for too long There are no further details provided by WhatsApp. The recommendation is to resend the message.

  • 470: Message failed to send because more than 24 hours have passed since the customer last replied to this number Free-form text messages and media messages will result in a failure callback with error 470 when sent outside of the 24h-window. Please find a way to restrict message sending if there was no incoming message for the given user/phone number within 24h.

  • 1000: Failed to generate processed file path This could occur when the file storage is full and files cannot be stored. Please reach out to Help and Support.

  • 1000: Image file format (audio/mpeg) is not supported Make sure that the message type matches the MIME-type of the file (ex. audio files should be sent using "audio", not "image"; audio/mpeg is an unsupported combination). Another reason could be that the video file doesn't have an audio track: then the error message contains something like video/mp4/h264/NONE where NONE is an indicator that the audio track is missing.

  • 1009: Invalid latitude The valid range is from -90 to 90.

  • 1014: Request for .... failed You have provided a URL that seems to be double URL-encoded and the file cannot be delivered because of that, or the file behind the URL doesn't exist.

  • 2001: Template name does not exist in the translation The template needs to be set up by our Support team.

  • 500: structure unavailable: Client could not display the highly structured message (hsm) The Template was not understood by the WhatsApp consumer client. Check the format.