Seamlessly send messages through WhatsApp with our API. Compose the text that needs to be sent out through WhatsApp and the message with images, audio & documents and delivers to the number.
1. Create your message
2. Trigger the API below with mandatory parameters
3. Your message will be sent to the WhatsApp number(s)
This section explains the supported formats of the message. The following formats are only supported:
Maximum characters allowed are 4096 on a single trigger
The maximum file upload size is 64 MB
Type | Format |
---|---|
template | Text message only |
text | Maximum text message length of 4096 characters |
image | JPG, JPEG, PNG |
document | PDF, DOC(X), PPT(X), XLS(X) ,TXT |
audio | AAC, M4A, AMR, MP3, OGG, OPUS |
contacts | List of contacts |
location | Current or Map location |
video | .mp4 |
Name | Specification | Expected Value |
---|---|---|
body | Template for a single number | { "to": "wa-number", "type": "template", "template": { "namespace": "unique namespace id", "template_name": "order_delivered", "policy":"deterministic fallback", "lang_code": "en", "params": ["{{value1}}", "{{value2}}"], "ttl": "1" }, "callback":"http://example.com/callback?" } |
Name | Specification | Expected Value |
---|---|---|
method | Predefined method | wa |
api_key | API key generated from your account | Alphanumeric Authentication key from your GMP account. This will be configured to validate account |
from | Valid registered WhatsApp number which is used for registration of the WhatsApp business account | WhatsApp number |
Parameters | Description |
---|---|
callback | http://example.com/callback?&id={id}&error={error} |
id | message id that you get upon sending the message |
status | failed, sent, delivered, read read status can be attained only if the recipient enabled read receipts on WhatsApp |
timestamp | timeline of message status |
Name | Specification | Expected Value |
---|---|---|
caption | While sending image or Document, should be able to add a caption to the file | For images, the caption will be added as description. The caption text appears in full length for images on both Android and iPhone While sending image or Document, should be able to add a caption to the file For documents, the caption replaces the filename. It is not meant to be displayed on the user's device as description text but instead to show the name of the file i Phones show the full text while Androids truncate the filename; this is technical limitation of the current implementation of WhatsApp on both devices |
preview_url | Url information will be previewed in the message | Only for type : text |
format | Output response format | json by default it will return json format Can be changed to xml |
ttl | If the message is not delivered to the customer before the expiration period the message will expire and will not be delivered | Min 86400 & Max 2592000 |
callback | Callback response with status and timestamp | http://example.com/callback?&status=READ&mobile=919xxxxxxxxx×tamp=1542006912 Status types : SENT READ DELIVERED Timestamp: Unix time format Mobile: Subscriber Mobile Number |
WhatsApp requires the Business to obtain explicit opt-ins from their customers to deliver any message over WhatsApp to that customer.
Opt-ins could be as simple as the customer initiating a conversation with the business on WhatsApp or by explicitly agreeing to be messaged by the Business.
Sending any messages to the customer without their opt-in may result in suspension of the Whatsapp Business account.
NOTE: Text, Image, Audio, Video, Documents, Contacts & Location will be sent only if the customer initiates the first message to the business.
Name | Specification | Expected Value |
---|---|---|
body | Text Message for a Single Number | { "to": "wa-number" , "type": "text", "text": { "message": "your-text-content" }, "preview_url": true , "callback":"http://example.com/callback?" } |
Name | Specification | Expected Value |
---|---|---|
body | Send document to a single number | { "to": "wa-number", "type": "document", "document": { "caption": "caption_name" }, "callback":"http://example.com/callback?" } |
Name | Specification | Expected Value |
---|---|---|
body | Send Image to a single number | { "to": "wa-number", "type": "image", "image": { "caption": "caption_name" }, "callback":"http://example.com/callback?" } |
Name | Specification | Expected Value |
---|---|---|
body | sending a audio file to the WhatsApp number with the following formats AAC, M4A, AMR, MP3, OGG, OPUS |
{ "to": "wa-number" , "type": "audio", "audio": { }, "callback":"http://example.com/callback?" } |
PHP Curl Snippet | Description |
---|---|
File Upload | File has to uploaded along with media messages (documents, images and audio) For Example, $cfile = new CURLFile(realpath('file path/What-is-an-API-1.0.pdf')); $postdata = array( 'file' => $cfile, 'method' => 'wa', 'api_key' => 'Ab0b12xxxxxxxxxxxxxxxxxxxxx', 'body' => '{"to":"91xxxxxxxxx", "type": "document", "document" : {"caption" : "Ok boss"},"callback":""}', 'from' => '91xxxxxxxxxx', 'format' => 'json' ); |
Name | Specification | Expected Value |
---|---|---|
body | Contact | { "to": "["wa-number1"]" "type": "contacts", "contacts": [ { "addresses": [ { "city": "MessageContactAddressCity", "country": "MessageContactAddressCountry", "country_code": "MessageContactAddressCountryCode", "state": "MessageContactAddressState", "street": "MessageContactAddressStreet", "type": "MessageContactAddressType", "zip": "MessageContactAddressZip" } ], "birthday": "MessageContactBirthday", "emails": [ { "email":"MessageContactEmail", "type": "MessageContactEmailType" } ], "ims": [], "name": { "first_name": "MessageContactFirstName", "formatted_name": "MessageContactFormattedName", "last_name": "MessageContactLastName" }, "org": { "company": "MessageContactCompany" }, "phones": [ { "phone": "MessageContactPhone", "type": "MessageContactPhoneType" } ], "urls": [] } ], |
"callback":"http://example.com/callback?" } |
Name | Specification | Expected Value |
---|---|---|
to | Whatsapp registered mobile number with country code | Mobile number with country codes, multiple numbers in an array separated by a comma Number formats: 1. +919880X90XXX 2. 919880X90XXX |
type | type of message | contact |
street (optional) | Street number and name | ex: Menlo Park |
city (optional) | city name | e.g: SanJose |
state | state abbreviation | e.g: CA |
zip | zipcode | e.g:94025 |
country | Full country name | e.g:United States |
country_code | Two-letter country abbreviation | e.g: US |
birthday | Birthday ex:YYYY-MM-DD formatted string |
2012-08-18 |
Email address | test@domain.com Standard Email Validation |
|
type | Standard Values: HOME, WORKStandard Values: HOME, WORK | WORK |
first_name | First name | John |
last_name | Last name | ex:Smith |
formatted_name | Full name as it normally appears | ex:John Smith |
company | Name of the contact's company | ex:WhatsApp |
department | Name of the contact's department | ex:Design |
title | Contact's customer title | ex:Manager |
phone | Automatically populated with the wa_id value as a formatted phone number | EX:+1 (940) 555-1234 |
type | Standard Values: CELL, MAIN, IPHONE, HOME, WORK | HOME |
wa_id | WhatsApp ID | 16505551234 |
url | URL | https://www.domain.com |
type | Standard Values: HOME, WORK | WORK |
Status | Specification | Expected Value |
---|---|---|
status | It indicates the success or failure of your API request. “OK” is success & others are error codes | 1."OK" 2."A404" 3."A402" 4."E603" |
message | message based on the status code response | 1.Submitted successfully 2.Your api account got suspended 3.Api Key not found" 3.Missing message 4.Insufficient credits |
id | Message sent id, after successful message sent for the given number | Auto generated Alphanumeric id for the successful request |
mobile | Mobile number to which message has to be sent | Subscriber Number to which message has to sent |
Name | Specification | Expected Value |
---|---|---|
body | location | { "to": ["wa-number1"], "type": "location", "location": { "longitude": "MessageLocationLongitude", "latitude": "MessageLocationLatitude", "name": "MessageLocationName", "address": "MessageLocationAddress" }, "callback":"http://example.com/callback?" } |
Name | Specification | Expected Value |
---|---|---|
to | Whatsapp registered mobile number with country code | Mobile number with country codes, multiple numbers in an array separated by a comma Number formats 1. +919880XXXXXX 2. +919880XXXXXX |
type | Type of message | location |
longitude | Location longitude | Valid Location longitude geographical values ex:-9.669120 |
latitude | Location latitude | Location latitude geographical values ex:26.906270 |
name (optional) | Location name | Location name to be shown to the user |
address (optional) | Location address | Location address |
Code | Description |
---|---|
E616 | Latitude missing |
E617 | Longitude missing |
Name | Specification | Response Value |
---|---|---|
to | WhatsApp registered mobile number with country code | Mobile number with country codes, multiple numbers in an array separated by comma 1. +919880390XXX 2. 919880390XXX |
type | type of message | text,audio,document,image |
message | Message content to deliver to the given WhatsApp number | text message |
file | File type is supported for the message types document, audio and image.WhatsApp registered mobile number with country code | Upload file which need be sent to given whatsapp number |
preview_url | Url information will be previewed in the message | Only for type : text |
namespace | Unique id from the facebook business manager account | Only for template message Unique id (e.g.,cdXXXdf51_XX16_c754_XXa4_64cdaXXXXd3e) |
template | Template name generated in Whatsapps Manager | Template name (e.g.,order_status) |
policy | The language policy the message should follow | Options: fallback, deterministic |
lang_code | The code of the language or locale to use — Accepts | (e.g., en, and en_US) |
Params | This field is an array of values to apply to variables in the template.Created in the Whatsapps Manager | (e.g., ["1", "2"]) |
Error Code | Description |
---|---|
E504 | File size exceeds 64 MB |
E603 | Missing template name |
The following are the notification formats for text and multimedia messages for incoming WhatsApp Business API.
[{
"from": "919880XXXXXX",
"id": "ABEGkZiAOQVVAhBWtt8x7Pi8qEZ7KVtbxxxxx",
"profile": {
"name": "John+Doe"
},
"text": {
"body": "Hello+world"
},
"timestamp": "155XXX4769",
"type": "text",
"wa_number": "91998XXXXXX"
}]
[{ "from": "919880XXXXXX", "id": "ABEGkZiAOQVVAhBWtt8x7Pi8qEZ7KVtbxxxxx", "profile": { "name": "John+Doe" }, "text": { "body": "Hello+world" }, "timestamp": "155XXX4769", "type": "text", "wa_number": "91998XXXXXX" }]
[{ "from": "919880XXXXXX", "id": "ABEGkZiAOQVVAhBMT0kkDkjOnLXXXXXXXXXX", "location": { "latitude": 12.9038507, "longitude": 77.6012386 }, "profile": { "name": "John+Doe" }, "timestamp": "155XXX5728", "type": "location", }]
[{ "contacts": [{ "addresses": [{ "city": "Menlo Park", "country": "United States", "country_code": "us", "state": "CA", "street": "1 Hacker Way", "type": "WORK", "zip": "94025" }], "birthday": "2012-08-18", "emails": [{ "email": "kfish@fb.com", "type": "WORK" }], "name": { "first_name": "Kerry", "formatted_name": "Kerry Fisher", "last_name": "Fisher" }, "org": { "company": "Facebook" }, "phones": [{ "phone": "+1 (940) 555-1234", "type": "CELL" }, { "phone": "+1 (650) 555-1234", "type": "WORK", "wa_id": "16505551234" } ], "urls": [{ "url": "https://www.facebook.com", "type": "WORK" }] }], "from": "16505551234", "id": "ABGGFlA4dSRvAgo6C4Z53hXXXXXX", "timestamp": "1537248012", "type": "contacts" }]
[{ "contacts": [{ "addresses": [{ "city": "Menlo Park", "country": "United States", "country_code": "us", "state": "CA", "street": "1 Hacker Way", "type": "WORK", "zip": "94025" }], "birthday": "2012-08-18", "emails": [{ "email": "kfish@fb.com", "type": "WORK" }], "name": { "first_name": "Kerry", "formatted_name": "Kerry Fisher", "last_name": "Fisher" }, "org": { "company": "Facebook" }, "phones": [{ "phone": "+1 (940) 555-1234", "type": "CELL" }, { "phone": "+1 (650) 555-1234", "type": "WORK", "wa_id": "16505551234" } ], "urls": [{ "url": "https://www.facebook.com", "type": "WORK" }] }], "from": "16505551234", "id": "ABGGFlA4dSRvAgo6C4Z53hXXXXXX", "timestamp": "1537248012", "type": "contacts" }]
[{ "from": "919880XXXXXX", "id": "ABEGkZiAOQVVAhA9eaq6tnV1VW0FmNbcyXSs", "profile": { "name": "John+Doe" }, "timestamp": "1551165144", "type": "image", "wa_number": "91998XXXXXXX", "url": "https:\/\/global.kaleyra.com\/wa\/downloadlink?id=EBf9zV+01MC\/TdqATWxcRGc0uTxKXuoH\/Lvs5Du0P\/+veQsUdVf8acLGC9jNGtW2tPo\/GD\/vRLIUH7eU963mEtoLwIhNcp9DNX8pC5EsdqlbArnR5USKDuxqpeXcPa+9sa2nhz0Z2vRUHnIgk\/i5d\/s0V86wjpAjCrl9vV6jRAXDsmiAV25D7tASW+pLamZ5" }]
[{ "from": "919880XXXXXX", "id": "ABEGkZiAOQVVAhBp5LSHh4axOvA2PqC0EEkX", "profile": { "name": "John+Doe" }, "timestamp": "1551165771", "type": "document", "wa_number": "919986XXXXXX", "url": "https:\/\/global.kaleyra.com\/wa\/downloadlink?id=EBf9zV+01MC\/TdqATWxcRGc0uTxKXuoH\/Lvs5Du0P\/+veQsUdVf8acLGC9jNGtW2tPo\/GD\/vRLIUH7eU963mEtoLwIhNcp9DNX8pC5EsdqlbArnR5USKDuxqpeXcPa+9tZqhGH0BQWCxze" }]
[{ "from": "919880390555", "id": "ABEGkZiAOQVVAhCIibgCFeEWIQ54XO56u_rH", "profile": { "name": "JOhn+Doe" }, "timestamp": "1551165748", "type": "audio", "wa_number": "919986XXXXXX", "url": "https:\/\/global.kaleyra.com\/wa\/downloadlink?id=EBf9zV+01MC\/TdqATWxcRGc0uTxKXuoH\/Lvs5Du0P\/+veQsUdVf8acLGC9jNGtW2tPo\/GD\/vRLIUH7eU963mEtoLwIhNcp9DNX8pC5EsdqlbArnR5USKDuxqpeXcPa+9OkwH9CHw3eH5heb9xli6GHqkS\/GPT7t4q4yg7sx1wBAD5UTddCmaUv\/hWoXEue38" }]
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | { "to": customer number, "type": "template", "template": { "namespace": "XXXX5086_XXX8_c216_cd8d_166XXXXXXe6d", "template_name": "text_template", "policy": "deterministic", "lang_code": "en", "params": ["1"], "ttl": "86400" }, "callback": "http://example.com/callback?" } mandatory |
from | wa business number mandatory |
format | json optional |
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | {"to": "customer number", "type": "mediatemplate", "template": { "namespace": "XXXX5086_XXX8_c216_cd8d_166XXXXXXe6d", "template_name": "media", "lang_code": "en", "params":{ "header": ["1"] "body" : ["1"] }, "ttl": 86400 }, "callback": "http://example.com/callback?" }
If you have any dynamic value in the header or body, pass it under the header or body variable respectively. |
from | wa business number mandatory |
file | @filepath mandatory (format: ".pdf, .jpeg and .png") |
format | json optional |
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | { "to": customer number, "type": "text", "preview_url": true, "callback": "http://example.com/callback?", "text": { "message": "new tezt, https://www.google.com" } }
If you have any dynamic value in the header or body, pass it under the header or body variable respectively. |
from | wa business number |
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | { "to":"customer number", "type": "image", "image" : {"caption" : "Welcome to Kaleyra"}, "callback":"http://example.com/callback?" }
If you have any dynamic value in the header or body, pass it under the header or body variable respectively. |
from | wa business number |
format | json optional |
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | { "to":"customer number", "type": "document", "document" : {"caption" : ""}, "callback":"http://example.com/callback?" }
mandatory |
file | mandatory |
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | {"to": customer number,"type": "audio","audio" : {}, "callback":"http://example.com/callback?"}
mandatory |
file | mandatory |
format | json optional |
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | { "to": customer number, "type": "contacts", "contacts": [ { "addresses": [ { "city": "bangalore", "country": "India", "country_code": "91", "state": "Karnataka", "street": "5th Main", "type": "Home", "zip": "560061" } ], "birthday": "08-09-19xx", "emails": [ { "email": "johndoe@gmail.com", "type": "Email" } ], "ims": [], "name": { "first_name": "John", "formatted_name": "l", "last_name": "Doe" }, "org": { "company": "Kaleyra" }, "phones": [ { "phone": "890464xxxx", "type": "Work" } ], "urls": [] } ] } |
format | json optional |
PARAMS
BODY | Format |
---|---|
method | wa mandatory |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX mandatory |
body | { "to":customer number, "type": "location", "location": { "longitude": "77.601237", "latitude": "12.903911", "name": "Test location", "address": "world" } } |
format | json optional |
multiple | { "to":["customer number", "918892174341"], "type": "location", "location": { "longitude": "77.601237", "latitude": "12.903911", "name": "Test location", "address": "world" } } |
What can you do with this API?
Seamlessly send messages with videos through WhatsApp with our API. Compose the text that needs to be sent out through WhatsApp and the message with videos gets delivered to the number.
How can I use this API?
1. Create your message with the video file
2. Trigger the API below with mandatory parameters
3. Your message will be sent to the WhatsApp number(s)
Supported Formats
This section explains the supported formats of the message. The following formats are only supported :
Pre-requisites
1. Registered WhatsApp Business Number
2. "To" Mobile Number who has already opted in/regsitered
3. Global API Key
4. Message and a video file
Parameter Name | Mandatory / Optional | Description | Expected Values |
---|---|---|---|
method | Mandatory | Predefined method | wa |
api_key | Mandatory | API key generated from your account | Alphanumeric Authentication key from your GMP account. This will be configured to validate the account. |
from | Mandatory | Valid registered WhatsApp number which is used for registration of the customer account. | WhatsApp number |
format | Optional | Output response format | XML/JSON by default, it should return JSON format Can be changed to XML |
video | { "to": "wa-number", "type": "video", "video": { "caption": "caption_name" }, "callback":"http://example.com/callback?" } |
POST BODY PARAMETERS FOR VIDEO API
Parameter Name | Mandatory / Optional | Description | Expected Values / Validation |
---|---|---|---|
to | Mandatory | Whatsapp registered mobile number with country code | Mobile number with country codes, multiple numbers in an array separated by a comma. Number formats 1. +919880390XXX 2. 919880390XXX |
type | Mandatory | Type of message | video |
caption | Optional | Video message caption | Caption the video where users should be able to know what this video for. Ex: Welcome to Kaleyra |
callback | Optional | Callback API to get the status of the request | Callback URL with parameters |
File format | Mandatory | File format | Format: MP4 |
File size | Mandatory | File size | The maximum filesize 64 MB. |
Content-Type : - application/x-www-form-urlencoded
BODY | formdata |
---|---|
method | wa |
api_key | AXXXXXXX71b8cef13c491656bXXXXXXX |
body | { "to": customer number, "type": "video", "video": { "caption": "Welcome to Kaleyra" }, "callback":"http://example.com/callback?" } |
file | @filepath Video Format .mp4 (Video Codec H.264 and Audio Codec AAC) |
from | wa business number |
format | json |