whin

FREEMIUM
Verified
โœ“
By inUtil Labs | Updated a day ago | Communication
Popularity

9.8 / 10

Latency

689ms

Service Level

98%

Health Check

100%

Back to All Tutorials (5)

Payload schemas of each type of whatsapp message (some examples)

When you are getting a 4xx response error, this is mainly due to incorrect construction of the payload. Here we show some examples so that you stop getting this kind of errors when using any of the endpoints to send a whatsapp (to a phone, or to a group).

The first thing you need to know is: the messages this API routes into the whatsapp network MUST be a JSON object. If you try to send a STRING, you will get a 4xx error and the message will not be routed. If you try to send a JSON with a wrong schema, you might or might not get an error depending on the construct, but the message will not be routed.


Here is an example: Say you want to send the text: โ€œTomy Door is openโ€ to whatsapp,

  • if you enter it as a STRING like this: "Tomy Door Open" you will get a 4xx error, and the message will NOT be delivered.
  • if you enter it as a JSON like this: {"text" : "Tomy Door Open"} the message will be delivered.
  • if you enter it as a JSON like this: {"message": "Tomy Door Open"} you will get a the string"src property must be a valid json object" and the message will NOT be delivered.

These are examples of the JSON schemas that are valid:

  • To send a simple text:
    { "text" : "this is a text sent from whin" }

  • To send a simple text with carriage returns:
    { "text" : "Hi,\nThis is a string\nwith carriage returns\r\nand line breaks." }

  • To send a vCard:
    { "contacts": { "displayName": "whin", "contacts": [ { "vcard": "BEGIN:VCARD\nVERSION:3.0\nFN:whin bot\nORG:Inutil Labs;\nTEL;type=CELL;type=VOICE;waid=34631428039:+34 631 42 80 39\nEND:VCARD" } ] }}

  • To send a Location:
    { "location": { "degreesLatitude": 40.4526941, "degreesLongitude": -3.6897589 }}

  • To send an Audio:
    { "audio": { "url": "https://www.mboxdrive.com/gundul.mp3" }}

  • To send a Video:
    { "video": { "url": "https://i.imgur.com/BYuofkh.mp4" }}

  • To send an Image:
    { "image": { "url": "https://i.imgur.com/F4sdrY4.jpeg" }}

  • To send a document:
    { "document": { "url": "https://file-examples.com/storage/feeb31b1716385276a318de/2017/10/file-sample_150kB.pdf" }}

  • To add a footer text to any media message, add a caption property:
    { "image": { "url": "https://i.imgur.com/Y6A0o7y.jpeg" }, "caption": "This is an image with text"}
    { "video": { "url": "https://i.imgur.com/vJXvxaG.mp4" }, "caption": "This is a video with text"}


You can see more examples on the RapidAPI playground when testing the API. Or write us to info@inutil.info if you need help.