Messaging
This documentation describes how to start sending messages to your users.
#
IntroductionMessage 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 contactsMethod
POST
Important
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.
- Request
- Response
blocking | string | no_wait (default), wait |
contacts* | array | +91 7042446696 |
force_check | boolean | false (default), true |
#
Example RequestPOST https://waba.whizardapi.com/v1/contacts{ "blocking": "wait", "contacts": [ "+91 7042446696" ], "force_check": true}
```json title="200 ok" { "contacts": [ { "input": "+917042446696", "wa_id": "917042446696", "status": "valid" <- we can send messages to valid contacts only -> }] }```
#
Check contactsSend Template Message
POST https://waba.whizardapi.com/v1/messages{ "to": "wa_id", "type": "template", "template": { "namespace": "c8ae5f90_307a_ca4c_b8f6_d1e2a2573574", "language": { "policy": "deterministic", "code": "en" }, "name": "template_name" }}
#
Message TemplatesPlease 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.
info
WhizardAPI stores media files for 14 days after upload. Media files older than 14 days may be deleted by WhizardAPI 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 to validate the payload if you are not sure. - 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 (no open session)
Free-form text messages and media messages will result in a failure callback with error 470 when sent outside of the 24h-window. In other words, if it has been more than 24 hours since you last received a user initiated message - the session is closed and you can no longer use free-form messages. Please find a way to restrict message sending if there was no incoming message for the given user/phone number within 24h. Alternatively, you can contact the user using a Template Message. - 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 support in this case. - 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. - 1006 - Unknown contact
You did not use the v1/contacts endpoint to get a valid wa_id before sending the message. See the above guide on how to use the v1/contacts endpoint. - 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.