×

This API can send messages to a single number with a message content or different numbers with different message contents for each number. To send message through Exotel API, you will need to make a HTTP POST request to

POST

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/messages

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid".
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

<your_api_key> , <your_api_token> and <your_sid> are available in the API settings page of your Exotel Dashboard

The following are the POST parameters - 

Parameter Name

Parameter Type

Mandatory/Optional

Value

custom_data

String

Optional

This parameter can be used to send any custom data at the API request level. This will be passed back in the callback.

status_callback

String (URL)

Optional

Once the message reaches terminal state, Exotel will do a POST callback to your end point if the URL is set as a parameter in the API.

whatsapp

Channel Object

Optional

Information related to the messages to be sent out on whatsapp. 

* The Whatsapp parameter mentioned here will be used to send messages through Whatsapp communication channel. In future the API will be extended further to support other communication channels like SMS. Later, SMS parameter can also be passed to send SMSes.

Channel Object

Parameter Name

Parameter Type

Mandatory/Optional

Value

custom_data

String

Optional

This parameter can be used to send any custom data at the API request level. This will be passed back in the callback.

status_callback

String (URL)

Optional

Once the message reaches terminal state, Exotel will do a POST callback to your end point if the URL is set as a parameter in the API.

messages

[]Message Object

Mandatory

Array of messages to be sent out 

Message Object

Parameter Name

Parameter Type

Mandatory/Optional

Value

custom_data

String

Optional

This parameter can be used to send any custom data at the API request level. This will be passed back in the callback.

status_callback

String (URL)

Optional

Once the message reaches terminal state, Exotel will do a POST callback to your end point if the URL is set as a parameter in the API.

from

String

Mandatory

From number  from which the message has to be sent

to

String

Mandatory

Phone number of the user to whom a message needs to be sent. The number must be in e.164 format. Here are some examples of supported phone number formats:

"+10000000000"

"+919888888888"

"+919876543210"

content

Whatsapp Message Object

Mandatory

Whatsapp message body

Whatsapp Message Object

This will be similar to Whatsapp Native API contracts [Refer Here]: 

Parameter Name

Parameter Type

Mandatory/Optional

Value

template

Template Object

Mandatory/Optional

Mandatory when type is template

Template Object

Parameter

Type

Mandatory/Optional

Notes

namespace

String

Mandatory

Namespace of the template

name

String

Mandatory

Name of the template

language

Language Object

Mandatory

Specifies the language the template may be rendered in.

components

[]Component Object

Mandatory

Components of the template, containing the parameters of the message.

Language Object

Parameter

Type

Mandatory/Optional

Notes

policy

String

Mandatory

The language policy the message should follow. The only supported option is deterministic. 

code

String

Mandatory

The code of the language or locale to use. Accepts both language and language_locale formats (e.g., en and en_US).

Component Object

Parameter

Type

Mandatory/Optional

Notes

type

String

Mandatory

Type of the component. Supported types are - 

 

Header

Body

Button

For text-based templates, we only support the type=body.

text

String

Optional

Text for the component 

sub_type

String

Mandatory/Optional

Required when type=button. Not used for the other types.

Type of button to create.

quick_reply: Refers to a previously created quick reply button that allows for the customer to return a predefined message.

url: Refers to a previously created button that allows the customer to visit the URL generated by appending the text parameter to the predefined prefix URL in the template.

index

String

Mandatory/Optional

Required when type=button. Not used for the other types. Position index of the button. You can have up to 3 buttons using index values of 0 to 2.

footer

String

Optional

Footer of the component

parameters

[]Parameter Object

Mandatory/Optional

Required when type=button.

Array of parameter objects with the content of the message.

Parameter Object

Parameter

Type

Mandatory/Optional

Notes

type

String

Mandatory

Type of the parameter. Describes the parameter type. Supported values:


currency

date_time

document

image

text

video

For text-based templates, the only supported parameter types are currency, date_time, and text.

text

String

Mandatory/Optional

Required when type=text.


The message’s text. Character limit varies based on the following included component type.


For the header component type:


60 characters

For the body component type:


1024 characters if other component types are included

32768 characters if body is the only component type included

image

Image Object

Mandatory/Optional

Required when type =image 

video

Video Object

Mandatory/Optional

Required when type =video

document

Document Object

Mandatory/Optional

Required when type = document. Only PDF documents are supported for media-based message templates. Captions not supported when used in a media template.

date_time

DateTime Object

Mandatory/Optional

Required when type = date_time

currency

Currency Object

Mandatory/Optional

Required when type = currency

Image Object

Parameter Name

Parameter Type

Mandatory/Optional

Value

link

String

Mandatory

Link of the image to be sent.Use only with HTTP/HTTPS URLs.

caption

String

Optional

Caption for the image. Describes the specified image.

Audio Object

Parameter Name

Parameter Type

Mandatory/Optional

Value

link

String

Mandatory

Link of the audio to be sent.Use only with HTTP/HTTPS URLs.

Video Object

Parameter Name

Parameter Type

Mandatory/Optional

Value

link

String

Mandatory

Link of the video to be sent. Use only with HTTP/HTTPS URLs.

caption

String

Optional

Caption for the video. Describes the specified video media.

Document Object

Parameter Name

Parameter Type

Mandatory/Optional

Value

link

String

Mandatory

Link of the document to be sent. Use only with HTTP/HTTPS URLs.

caption

String

Optional

Caption for the document. Describes the specified document media.

filename

String

Optional

Describes the filename for the specific document. Use only with document media.

The extension of the filename will specify what format the document is displayed as in WhatsApp.

DateTime Object

Parameter

Type

Mandatory/Optional

Notes

fallback_value

String

Mandatory

Default text. we always use the fallback value, and we do not attempt to localize using other optional fields.

Currency Object

Parameter

Type

Mandatory/Optional

Notes

fallback_value

String

Mandatory

Fallback value of currency. Default text if localization fails.

code

String

Mandatory

Currency Code. Currency code as defined in ISO 4217.

amount_1000

Integer

Mandatory

Amount of currency. Amount multiplied by 1000.

Please refer  Exotel's sample postman collection to try out the APIs, we have also shared some examples here for your reference.

curl -XPOST "https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/messages"
-d 
'{
"custom_data": "order12",
   "status_callback": "https://webhook.site",
   "whatsapp": {
       "messages": [
           {
               "from": "9199XXXXXXXX",
               "to": "9199XXXXXXXX",
               "content": {
                   "type": "template",
                   "template": {
                       "name": "candidate_feedback_message",
                       "language": {
                           "policy": "deterministic",
                           "code": "en"
                       },
                       "components": [
                           {
                               "type": "body",
                               "parameters": [
                                   {
                                       "type": "text",
                                       "text": "Good!"
                                   }
                               ]
                           }
                       ]
                   }
               }
           }
       ]
   }
   }'
var https = require('follow-redirects').https;
var fs = require('fs');
var qs = require('querystring');
var options = {
'method': 'POST',
'hostname': '<api_key>',
'port': <api_token><subdomain>,
'path': '/v2/accounts/<your_sid>/messages',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = qs.stringify({
'{ "custom_data": "order12",    "status_callback": "https://webhook.site",    "whatsapp": {        "messages": [            {                "from": "9199XXXXXXXX",                "to": "9199XXXXXXXX",                "content": {                    "type": "template",                    "template": {                        "name": "candidate_feedback_message",                        "language": {                            "policy": "deterministic",                            "code": "en"                        },                        "components": [                            {                                "type": "body",                                "parameters": [                                    {                                        "type": "text",                                        "text": "Good!"                                    }                                ]                            }                        ]                    }                }            }        ]    }    }': ''
});
req.write(postData);
req.end();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://%3Capi_key%3E:%3Capi_token%3E%3Csubdomain%3E/v2/accounts/%3Cyour_sid%3E/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '%7B%20%22custom_data%22%3A%20%22order12%22%2C%20%C2%A0%C2%A0%C2%A0%22status_callback%22%3A%20%22https%3A%2F%2Fwebhook.site%22%2C%20%C2%A0%C2%A0%C2%A0%22whatsapp%22%3A%20%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22messages%22%3A%20%5B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22from%22%3A%20%229199XXXXXXXX%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22to%22%3A%20%229199XXXXXXXX%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22content%22%3A%20%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22type%22%3A%20%22template%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22template%22%3A%20%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22name%22%3A%20%22candidate_feedback_message%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22language%22%3A%20%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22policy%22%3A%20%22deterministic%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%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C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%5D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%5D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%5D%20%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%7D=',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/messages"
payload='%7B%20%22custom_data%22%3A%20%22order12%22%2C%20%C2%A0%C2%A0%C2%A0%22status_callback%22%3A%20%22https%3A%2F%2Fwebhook.site%22%2C%20%C2%A0%C2%A0%C2%A0%22whatsapp%22%3A%20%7B%20%C2%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%A0%7D='
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
require "uri"
require "net/http"
require "uri"
require "net/http"
url = URI("https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/messages")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/x-www-form-urlencoded"
request.body = "%7B%20%22custom_data%22%3A%20%22order12%22%2C%20%C2%A0%C2%A0%C2%A0%22status_callback%22%3A%20%22https%3A%2F%2Fwebhook.site%22%2C%20%C2%A0%C2%A0%C2%A0%22whatsapp%22%3A%20%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22messages%22%3A%20%5B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22from%22%3A%20%229199XXXXXXXX%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22to%22%3A%20%229199XXXXXXXX%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22content%22%3A%20%7B%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%22type%22%3A%20%22template%22%2C%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%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C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%5D%20%C2%A0%C2%A0%C2%A0%7D%20%C2%A0%C2%A0%C2%A0%7D="
response = https.request(request)
puts response.read_body
curl -XPOST "https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/messages"
-d 
'{
"custom_data": "ORDER12",
   "status_callback": "https://webhook.site",
   "whatsapp": {
       "messages": [
           {
               "from": "9199XXXXXXXX",
               "to": "9199XXXXXXXX",
               "content": {
                   "type": "template",
                   "template": {
                       "name": "image_1",
                       "language": {
                           "policy": "deterministic",
                           "code": "en"
                       },
                       "components": [
                           {
                               "type": "header",
                               "parameters": [
                                   {
                                       "type": "image",
                                       "image": {
                                           "link": "https://image.jpg"
                                       }
                                   }
                               ]
                           },
                           {
                               "type": "body",
                               "parameters": [
                                   {
                                       "type": "text",
                                       "text": "Name"
                                   }
                               ]
                           }
                       ]
                   }
               }
           }
       ]
   }
   }'
var https = require('follow-redirects').https;
var fs = require('fs');
var qs = require('querystring');
var options = {
'method': 'POST',
'hostname': '<api_key>',
'port': <api_token><subdomain>,
'path': '/v2/accounts/<your_sid>/messages',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = qs.stringify({
'{\n"custom_data": "ORDER12",\n "status_callback": "https://webhook.site",\n "whatsapp": {\n "messages": [\n {\n "from": "9199XXXXXXXX",\n "to": "9199XXXXXXXX",\n "content": {\n "type": "template",\n "template": {\n "name": "image_1",\n "language": {\n "policy": "deterministic",\n "code": "en"\n },\n "components": [\n {\n "type": "header",\n "parameters": [\n {\n "type": "image",\n "image": {\n "link": "https://image.jpg"\n }\n }\n ]\n },\n {\n "type": "body",\n "parameters": [\n {\n "type": "text",\n "text": "Name"\n }\n ]\n }\n ]\n }\n }\n }\n ]\n }\n }': ''
});
req.write(postData);
req.end();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://%3Capi_key%3E:%3Capi_token%3E%3Csubdomain%3E/v2/accounts/%3Cyour_sid%3E/messages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '%7B%0A%22custom_data%22%3A%20%22ORDER12%22%2C%0A%20%20%20%22status_callback%22%3A%20%22https%3A%2F%2Fwebhook.site%22%2C%0A%20%20%20%22whatsapp%22%3A%20%7B%0A%20%20%20%20%20%20%20%22messages%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22from%22%3A%20%229199XXXXXXXX%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%22%3A%20%229199XXXXXXXX%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22content%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22template%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22template%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22image_1%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22language%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22policy%22%3A%20%22deterministic%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22code%22%3A%20%22en%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22components%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22header%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22parameters%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22image%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22image%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22link%22%3A%20%22https%3A%2F%2Fimage.jpg%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22body%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22parameters%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22text%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22text%22%3A%20%22Name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%5D%0A%20%20%20%7D%0A%20%20%20%7D=',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/messages"
payload='%7B%0A%22custom_data%22%3A%20%22ORDER12%22%2C%0A%20%20%20%22status_callback%22%3A%20%22https%3A%2F%2Fwebhook.site%22%2C%0A%20%20%20%22whatsapp%22%3A%20%7B%0A%20%20%20%20%20%20%20%22messages%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22from%22%3A%20%229199XXXXXXXX%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%22%3A%20%229199XXXXXXXX%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22content%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22template%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22template%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22image_1%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22language%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22policy%22%3A%20%22deterministic%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22code%22%3A%20%22en%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22components%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22header%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22parameters%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22image%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22image%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22link%22%3A%20%22https%3A%2F%2Fimage.jpg%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22body%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22parameters%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22text%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22text%22%3A%20%22Name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%5D%0A%20%20%20%7D%0A%20%20%20%7D='
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
require "uri"
require "net/http"
url = URI("https://<api_key>:<api_token><subdomain>/v2/accounts/<your_sid>/messages")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/x-www-form-urlencoded"
request.body = "%7B%0A%22custom_data%22%3A%20%22ORDER12%22%2C%0A%20%20%20%22status_callback%22%3A%20%22https%3A%2F%2Fwebhook.site%22%2C%0A%20%20%20%22whatsapp%22%3A%20%7B%0A%20%20%20%20%20%20%20%22messages%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22from%22%3A%20%229199XXXXXXXX%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%22%3A%20%229199XXXXXXXX%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22content%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22template%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22template%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22image_1%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22language%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22policy%22%3A%20%22deterministic%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22code%22%3A%20%22en%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22components%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22header%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22parameters%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22image%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22image%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22link%22%3A%20%22https%3A%2F%2Fimage.jpg%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22body%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22parameters%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22text%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22text%22%3A%20%22Name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%5D%0A%20%20%20%7D%0A%20%20%20%7D="
response = https.request(request)
puts response.read_body

HTTP Response:

  • On success, the HTTP response status code will be 202
  • The Sid is the unique identifier of the message and it will be useful to log this for future debugging
  • the HTTP body will contain an JSON similar to the one below
{
   "request_id": "b434e927a5844175b23059cd96feea3d",
   "method": "POST",
   "http_code": 202,
   "metadata": {
     "failed": 0,
     "total": 1,
     "success": 1
   },
   "response": {
     "whatsapp": {
       "messages": [
         {
           "code": 202,
           "error_data": null,
           "status": "success",
           "data": {
             "sid": "2FdiiEQUosckPhpZfuVwfjxiSlc16a4",
           }
         }
       ]
     }
   }
}

The following are the response parameters - 

Parameter

Type

Mandatory/Optional

Notes

request_id

String

Mandatory

This indicates the unique id of the request. Useful for debugging and tracing purposes.

method

String

Mandatory

This indicates the HTTP method for the request such as POST

http_code

Integer

Mandatory

This indicates the HTTP code for the request such as 202, 400, 500 etc.

metadata

Metadata Object

Mandatory

Metadata pertaining to the request. Count of failed, total and success records.

response

Response Object

Mandatory

Response for the request

Metadata Object

Parameter

Type

Mandatory/Optional

Notes

total

Integer

Mandatory

Total number of the messages in the request

success

Integer

Mandatory

Number of messages successfully accepted

failed

Integer

Mandatory

Number of messages that couldn’t be accepted (failed)

Response Object

Parameter

Type

Mandatory/Optional

Notes

whatsapp

Channel Response Object

Mandatory

Response for Whatsapp messages specified in the request

Channel Response Object

Parameter

Type

Mandatory/Optional

Notes

messages

[]Create Message Response Object

Mandatory

Array of messages response for each message

Create Message Response Object

Parameter

Type

Mandatory/Optional

Notes

code

Integer

Mandatory

Response code for the individual message

error_data

ErrorResponseObject

Optional

Error related to a single message

status

String

Mandatory

Status of the single message

data

Message Response Object

Optional

Data pertaining to a single message

Error Response Object

Parameter

Type

Mandatory/Optional

Notes

code

Numeric

Mandatory

Numeric HTTP code for a Single message

message

String 

Mandatory

Brief description of the error

description

String

Mandatory

Detailed explanation of error

Message Response Object

Parameter

Type

Mandatory/Optional

Notes

sid

String

Mandatory

SID (Unique identifier) of the single message

HTTP Error codes : 

HTTP Error Codes

Error Message

202

Accepted - Request accepted.

400

Bad Request - Something in your header or request body was malformed/missing.

More than 100 messages specified in a request

401

Unauthorized - Necessary credentials were either missing or invalid.

402

Payment Required - The action is not available on your plan, or you have exceeded usage limits for your current plan.

403

Your credentials are valid, but you don’t have access to the requested resource.

404

Not Found - The object you’re requesting doesn’t exist.

5xx

Server Errors - Something went wrong at our end. Please try again.

Status Callbacks 

Status callback URL can be passed in status_callback parameter in send message/template message APIs and it can also be configured as default to receive the responses. Exotel team will help you configure the default URL while onboarding.

  • If you pass status callback URL in send message/template message APIs, status callbacks will be triggered to the respective URL 
  • If you do not pass any status callback URL in send message/template message APIs, status callbacks will be triggered to the default URL, if any.

 

*NOTE: Any callback can be received only in one status callback URL at any time

 "whatsapp": {
     "messages": [
       {
   "callback_type": "dlr",
         "sid": "1234",
         "to": "2365564965",
         "exo_status_code": 25001,
         "exo_detailed_status": "EX_MESSAGE_DELIVERED",
         "description": "Message delivered",
         "timestamp": "2022-12-07T17:00:00.000+05:30",
         "custom_data": "custom"
       }
     ]
   }
 }

The following are the status callback parameters - 

Parameter

Type

Mandatory

Notes

whatsapp

Message DLR Object

Optional

Delivery report (DLR) of the Whatsapp channel

Message DLR Object

Parameter

Type

Mandatory

Notes

messages

[]Whatsapp Message DLR Object

Mandatory

Information relating to the messages for DLR

Whatsapp Message DLR Object

Parameter

Type

Mandatory

Notes

callback_type

String

Mandatory

Type of the callback. Possible values: dlr, icm

sid

String

Mandatory

SID (Unique Identifier) of the message

to

String

Mandatory

Phone Number of the user to whom the message was sent.

exo_status_code

Integer

Mandatory

ExoStatusCode for the message

exo_detailed_status

String

Mandatory

Detailed status of ExoStatus code

description

String

Mandatory

Description of the ExoStatus code

timestamp

String

Mandatory

Timestamp at which the event occurred

custom_data

String

Optional

It will return the custom data, if the same was passed in the API request

ExoStatus Codes

Detailed Status Code

Detailed Status

Description

30001

EX_MESSAGE_SENT

The message has been sent to the user

30002

EX_MESSAGE_DELIVERED

The message has been successfully delivered to the user

30003

EX_MESSAGE_SEEN

The message has been seen by the user

30004

EX_SYSTEM_ERROR

The message failed due to an issue with the system. For eg: Authentication/Access Token/Permission related issue, service not available issue etc.

30005

EX_NUMBER_ERROR

The message failed due to an issue with the phone number

30006

EX_SETUP_ERROR

The message failed due to set-up error

30007

EX_RATE_LIMIT_HIT

The message failed due to a breach in rate limit

30008

EX_SPAM_RATE_LIMIT_HIT

The message failed as spam rate limit has been breached

30009

EX_TOO_MANY_REQUEST

The message failed as too many request has been made in short span

30010

EX_INVALID_REQUEST

The message failed as the request is invalid

30011

EX_UNKNOWN_ERROR

The message failed due to an unknown error

30012

EX_INVALID_RECIPIENT

The message failed as the recipient was invalid

30013

EX_INCAPABLE_RECIPIENT

The message failed as the recipient is unable to receive the message

30014

EX_RECIPIENT_BLOCKED

The message failed as the recipient is not in allowed list

30015

EX_UNSUPPORTED_MESSAGE

The message failed as unsupported message type has been passed in the request body

30016

EX_MEDIA_DOWNLOAD_ERROR

The message failed as Whatsapp is unable to download the sender media

30017

EX_MEDIA_UPLOAD_ERROR

The message failed as unsupported media type has been passed in the request body

30018

EX_REENGAGEMENT_ERROR

The message failed as 24 hours window of the conversation is over

30019

EX_INVALID_PARAM

The message failed as invalid parameters has been passed in the request body

30020

EX_MISSING_PARAM

The message has failed as mandatory parameter is missing from the request body

30021

EX_INVALID_PARAM_VALUE

The message failed as invalid parameter value has been passed in the request body

30022

EX_TEMPLATE_ERROR

The message failed as the template format char policy has been violated

30023

EX_TEMPLATE_PARAM_ERROR

The message failed due to mismatch in count of template parameters

30024

EX_TEMPLATE_NOT_FOUND

The message failed as the passed message template does not exist

30025

EX_TEMPLATE_TEXT_TOO_LONG

The message failed as the translated text from template message is too long

30026

EX_INVALID_TEMPLATE_NAMESPACE

The message failed as invalid template namespace has been passed

30027

EX_MESSAGE_PENDING_TOO_LONG

The message failed as the message was pending for too long

30028

EX_MESSAGE_EXPIRED

The message failed as the message got expired

30029

EX_MESSAGE_TOO_LONG

The message failed as the number of characters in the message was more than 4096 characters

30030

EX_WEBHOOK_ERROR

Webhook is not configured

30031

EX_SECTION_COUNT_ERROR

The message failed due to invalid no. of sections

30032

EX_ROWS_COUNT_ERROR

The message failed due to invalid no. of rows

30033

EX_PRODUCT_COUNT_ERROR

The message failed due to invalid no. of product

30034

EX_CATALOGUE_NOT_FOUND

The message failed as the catalog ID has not been found

30035

EX_CATALOGUE_NOT_LINKED

The message failed as the catalog ID has not been linked to the API number

30036

EX_MISSING_PRODUCT

The message failed as the product is missing in the catalog

30037

EX_PRODUCT_NOT_FOUND

The message failed as all the products in the request body has not been found in the product catalog

30038

EX_PRODUCT_COMPLIANCE_ERROR

The message failed as the listed products failed compliance

30039

EX_INVALID_HEADER

The message failed due to invalid header structure

30040

EX_MISSING_COMPLIANCE

The message failed as compliance information was missing

30041

EX_CHAR_POLICY_VIOLATION

The message failed as character policy got violated