### HTTP Response Example for WhatsApp Message Source: https://developer.exotel.com/api/whatsapp This is an example of a successful HTTP response when sending a WhatsApp message. It includes request details, status, and message-specific SIDs. ```json { "request_id": "b434e927a5844175b23059cd96feea3d", "method": "POST", "http_code": 202, "metadata": { "failed": 0, "total": 2, "success": 2 }, "response": { "whatsapp": { "messages": [ { "code": 202, "error_data": null, "status": "success", "data": { "sid": "2FdiiEQUosckPhpZfuVwfjxiSlc16a4" } }, { "code": 202, "error_data": null, "status": "success", "data": { "sid": "2FdiiDU5hAK8tW0Atq340Ayngpx16a4" } } ] } } } ``` -------------------------------- ### Example Response for Authentication Template Message Source: https://developer.exotel.com/api/whatsapp This is an example of a successful HTTP response when sending an authentication template message. The 'sid' is a unique identifier for the message and is useful for debugging. ```json {    "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"          }        }      ]    }    } } ``` -------------------------------- ### Send Image Template Message using Node.js Source: https://developer.exotel.com/api/whatsapp This Node.js example demonstrates how to send an image template message using the 'follow-redirects' and 'querystring' modules. It requires proper setup of HTTPS request options and payload. ```javascript var https = require('follow-redirects').https; var fs = require('fs'); var qs = require('querystring'); var options = { 'method': 'POST', 'hostname': '', 'port': null, 'path': '/v2/accounts//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 "type": "body",\n "parameters": [\n {\n "type": "text",\n "text": "Name"\n } ] } ] } } } ] } }': '' }); req.write(postData); req.end(); ``` -------------------------------- ### Ruby Example for Sending WhatsApp Message Source: https://developer.exotel.com/api/whatsapp This Ruby code snippet shows how to send a WhatsApp message using the Exotel API. It makes an HTTP POST request and prints the response body. ```ruby require 'net/http' require 'uri' uri = URI.parse("https://api.exotel.com/v1/Accounts/YOUR_EXOTEL_ACCOUNT_ID/Sms/send.json") request = Net::HTTP::Post.new(uri.request_uri) request.basic_auth("YOUR_EXOTEL_ACCOUNT_ID", "YOUR_EXOTEL_API_KEY") request["Content-Type"] = "application/json" request.body = "{ \"to\": \"919876543210\", \"sender_id\": \"YOUR_SENDER_ID\", \"message\": \"Hello from Exotel!\", \"channel\": \"whatsapp\" }" response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(request) end puts response.read_body ``` -------------------------------- ### Send WhatsApp Image Message Source: https://developer.exotel.com/api/whatsapp This example shows how to send an image message via the WhatsApp API, including the image link and caption. ```APIDOC ## POST /v2/accounts//messages ### Description Sends an image message using the WhatsApp API. ### Method POST ### Endpoint /v2/accounts//messages ### Request Body - **custom_data** (string) - Optional - Custom data to be sent with the message. - **status_callback** (string) - Optional - URL to receive status updates. - **whatsapp** (object) - Required - Contains WhatsApp message details. - **messages** (array) - Required - A list of messages to send. - **from** (string) - Required - Sender's phone number. - **to** (string) - Required - Recipient's phone number. - **content** (object) - Required - Message content details. - **type** (string) - Required - Type of content ('image'). - **image** (object) - Required - Image message details. - **link** (string) - Required - URL of the image. - **caption** (string) - Optional - Caption for the image. ### Request Example ```json { "custom_data": "ORDER126", "status_callback": "https://webhook.site/", "whatsapp": { "messages": [ { "from": "9199XXXXXXXX", "to": "9199XXXXXXXX", "content": { "type": "image", "image": { "link": "https://image.587.jpg", "caption": "This is image caption" } } } ] } } ``` ``` -------------------------------- ### WhatsApp API Success Response Example Source: https://developer.exotel.com/api/whatsapp This is an example of a successful HTTP response from the WhatsApp API. It includes request details, status codes, and message-specific information. ```json { "request_id": "210bd1cda8004a2e913eac7a580eb159", "method": "POST", "http_code": 202, "metadata": { "failed": 0, "total": 1, "success": 1 }, "response": { "whatsapp": { "messages": [ { "code": 202, "error_data": null, "status": "success", "data": { "sid": "f65047444e5c782a56f76f40e06717b9" } } ] } } } ``` -------------------------------- ### Send WhatsApp Text Message Source: https://developer.exotel.com/api/whatsapp This example demonstrates how to send a text message using the WhatsApp API. It includes the request body structure and headers. ```APIDOC ## POST /v2/accounts//messages ### Description Sends a WhatsApp message to a specified recipient. ### Method POST ### Endpoint /v2/accounts//messages ### Request Body - **custom_data** (string) - Optional - Custom data to be sent with the message. - **status_callback** (string) - Optional - URL to receive status updates. - **whatsapp** (object) - Required - Contains WhatsApp message details. - **messages** (array) - Required - A list of messages to send. - **from** (string) - Required - Sender's phone number. - **to** (string) - Required - Recipient's phone number. - **content** (object) - Required - Message content details. - **recipient_type** (string) - Required - Type of recipient ('individual'). - **type** (string) - Required - Type of content ('text'). - **text** (object) - Required - Text message details. - **preview_url** (boolean) - Optional - Whether to preview URLs. - **body** (string) - Required - The message content. ### Request Example ```json { "custom_data": "Order126", "status_callback": "https://webhook.site", "whatsapp": { "messages": [ { "from": "+9199XXXXXXXX2", "to": "+9199XXXXXXXX", "content": { "recipient_type": "individual", "type": "text", "text": { "preview_url": false, "body": "MESSAGE_CONTENT" } } } ] } } ``` ``` -------------------------------- ### Send Bulk Template Image WhatsApp Messages Source: https://developer.exotel.com/api/whatsapp This example shows how to send bulk WhatsApp messages using a template that includes an image. The 'name', 'language', and 'components' fields are crucial for template messages. ```curl curl -XPOST "https://:/v2/accounts//messages" -d  '{ "custom_data": "custom12", "status_callback": "www.webhook.site", "whatsapp": {    "messages": [        {                "from": "+91XXXXXXXXXX",                "to": "_91XXXXXXXXXX_",                "content": {                    "type": "template",                    "template": {                        "name": "exotel_image_1",                        "language": {                            "policy": "deterministic",                            "code": "en"                        },                        "components": [                            {                                "type": "header",                                "parameters": [                                    {                                        "type": "image",                                   "image": {                                           "link": "https://image.shutterstock.com/image-photo/happy-puppy-dog-smiling-on-260nw-1799966587.jpg"                                        }                                    }                                ]                            },                            {                                "type": "body",                                "parameters": [                                    {                                        "type": "text",                                        "text": "ABC"                                    }                                ]                            }                        ]                }            }        },            {                "from": "+91XXXXXXXXXX",                "to": "_91XXXXXXXXXX_",                "content": {                    "type": "template",                    "template": {                        "name": "exotel_image_1",                        "language": {                            "policy": "deterministic",                            "code": "en"                        },                        "components": [                            {                                "type": "header",                                "parameters": [                                    {                                        "type": "image", ``` -------------------------------- ### Send Bulk WhatsApp Message Request Source: https://developer.exotel.com/api/whatsapp This snippet demonstrates how to construct a request to send bulk WhatsApp messages. It includes examples for sending text messages. ```json { "to": [ "+919876543210", "+919876543211" ], "type": "text", "parameters": [ { "type": "text", "text": "ABC" } ] } ``` -------------------------------- ### Send Order Details Message via Razorpay Gateway Source: https://developer.exotel.com/api/whatsapp This example demonstrates how to send an interactive order details message via the WhatsApp API, utilizing Razorpay for payment processing. It includes details for the payment amount, beneficiaries, subtotal, tax, shipping, discount, and expiration. ```APIDOC ## Send Order Details Message via Razorpay Gateway ### Description This endpoint allows you to send an interactive order details message through the WhatsApp API. It supports integration with payment gateways like Razorpay, enabling users to review and pay for orders directly. ### Method POST ### Endpoint `https://{{AuthKey}}:{{AuthToken}}@{{SubDomain}}/v2/accounts/{{AccountSid}}/messages` ### Parameters #### Request Body - **whatsapp** (object) - Required - Contains WhatsApp message details. - **messages** (array) - Required - A list of messages to send. - **from** (string) - Required - Sender's WhatsApp number. - **to** (string) - Required - Recipient's WhatsApp number. - **content** (object) - Required - Message content details. - **type** (string) - Required - Type of interactive message, must be "interactive". - **interactive** (object) - Required - Interactive message configuration. - **type** (string) - Required - Type of interactive message, must be "order_details". - **header** (object) - Optional - Message header. - **type** (string) - Required - Type of header, must be "image". - **image** (object) - Required - Image details. - **link** (string) - Required - URL of the image. - **body** (object) - Required - Message body text. - **text** (string) - Required - The main text content of the message. - **footer** (object) - Optional - Message footer text. - **text** (string) - Required - The footer text. - **action** (object) - Required - Action configuration for the interactive message. - **name** (string) - Required - Name of the action, must be "review_and_pay". - **parameters** (object) - Required - Parameters for the action. - **reference_id** (string) - Required - Unique reference ID for the order. - **type** (string) - Required - Type of order, e.g., "digital_goods". - **payment_type** (string) - Required - Payment gateway type, e.g., "payment_gateway:razorpay". - **payment_configuration** (string) - Required - Payment configuration identifier. - **currency** (string) - Required - Currency of the payment (e.g., "INR"). - **total_amount** (object) - Required - Total amount of the order. - **value** (integer) - Required - Amount value multiplied by offset. - **offset** (integer) - Required - Offset value, must be 100 for INR. - **order** (object) - Required - Order details. - **status** (string) - Required - Status of the order, e.g., "pending". ### Request Example ```json { "whatsapp": { "messages": [ { "from": "9199XXXXXXXX", "to": "9190XXXXXXXX", "content": { "type": "interactive", "interactive": { "type": "order_details", "header": { "type": "image", "image": { "link": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Home_made_sour_dough_bread.jpg/640px-Home_made_sour_dough_bread.jpg" } }, "body": { "text": "Click on the Pay Now button to complete the order" }, "footer": { "text": "Thank You!" }, "action": { "name": "review_and_pay", "parameters": { "reference_id": "57848", "type": "digital-goods", "payment_type": "payment_gateway:razorpay", "payment_configuration": "XXXXXXXX", "currency": "INR", "total_amount": { "value": 1000, "offset": 100 }, "order": { "status": "pending" } } } } } } ] } } ``` ### Response (Response details not provided in the source text) ``` -------------------------------- ### Send WhatsApp Message with Image and Text (Python) Source: https://developer.exotel.com/api/whatsapp This Python snippet demonstrates how to send a WhatsApp message that includes both an image and text. It uses the `requests` library to make a POST request to the Exotel API. Ensure you have the `requests` library installed. ```python import requests url = "" payload = { "recipient_whatsapp": "", "message_type": "whatsapp", "message_content": { "type": "template", "template": { "name": "", "language": { "code": "en" }, "components": [ { "type": "header", "parameters": [ { "type": "image", "image": { "link": "https://image.shutterstock.com/image-photo/happy-puppy-dog-smiling-on-260nw-1799966587.jpg" } } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "ABC" } ] } ] } } } headers = { 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Send Limited-Time Offer Template Message Source: https://developer.exotel.com/api/whatsapp This example demonstrates how to send a WhatsApp template message with an image header, body text variables, offer expiration details, a copy code button, and a URL button. ```APIDOC ## POST /v2/accounts/{{AccountSid}}/messages ### Description Send a WhatsApp template message with specific components like image header, body variables, offer expiration, copy code button, and URL button. ### Method POST ### Endpoint https://{{AuthKey}}:{{AuthToken}}@{{SubDomain}}/v2/accounts/{{AccountSid}}/messages ### Parameters #### Request Body - **custom_data** (string) - Optional - Custom data to be sent with the message. - **status_callback** (string) - Optional - URL to receive status updates. - **whatsapp** (object) - Required - WhatsApp specific message details. - **messages** (array) - Required - List of messages to send. - **from** (string) - Required - Sender's WhatsApp number. - **to** (string) - Required - Recipient's WhatsApp number. - **content** (object) - Required - Message content. - **type** (string) - Required - Type of content, must be 'template'. - **template** (object) - Required - Template details. - **name** (string) - Required - Name of the template. - **language** (object) - Required - Language of the template. - **code** (string) - Required - Language code (e.g., 'en'). - **components** (array) - Required - List of template components. - **type** (string) - Required - Type of component (e.g., 'header', 'body', 'limited_time_offer', 'button'). - **parameters** (array) - Required - Parameters for the component. - **type** (string) - Required - Type of parameter (e.g., 'image', 'text', 'limited_time_offer', 'coupon_code'). - **image** (object) - Optional - Image details for header. - **link** (string) - Required - URL of the image. - **limited_time_offer** (object) - Optional - Offer details. - **expiration_time_ms** (number) - Required - Offer expiration time as UNIX timestamp in milliseconds. - **coupon_code** (string) - Optional - The coupon code for the copy code button. - **text** (string) - Optional - Text for body or URL button parameters. - **sub_type** (string) - Optional - Sub-type for button components (e.g., 'copy_code', 'url'). - **index** (string) - Optional - Index for button components. ### Request Example ```json { "custom_data": "ORDER123456", "status_callback": "https://webhook.site/XXXX-61e6-4873-XXXX", "whatsapp": { "messages": [ { "from": "+918047109880", "to": "919878434250", "content": { "type": "template", "template": { "name": "lto_parleagro", "language": { "code": "en" }, "components": [ { "type": "header", "parameters": [ { "type": "image", "image": { "link": "https://www.parleproducts.com/Uploads/image/1CategoryImg_biscuits-cookie.png" } } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "Kaustubh" } ] }, { "type": "limited_time_offer", "parameters": [ { "type": "limited_time_offer", "limited_time_offer": { "expiration_time_ms": 1716261112000 } } ] }, { "type": "button", "sub_type": "copy_code", "index": "0", "parameters": [ { "type": "coupon_code", "coupon_code": "PARLE25" } ] }, { "type": "button", "sub_type": "url", "index": "1", "parameters": [ { "type": "text", "text": "biscuits" } ] } ] } } } ] } } ``` ``` -------------------------------- ### Send Bulk WhatsApp Messages Source: https://developer.exotel.com/api/whatsapp This snippet demonstrates how to send bulk WhatsApp messages using the API. It includes the necessary request body structure and an example of how to make the API call. ```APIDOC ## POST /whatsapp ### Description Send bulk WhatsApp messages to multiple recipients. ### Method POST ### Endpoint /whatsapp ### Request Body - **to** (string) - Required - The recipient's phone number in international format. - **from** (string) - Required - Your WhatsApp sender ID. - **type** (string) - Required - The type of message (e.g., 'text', 'image', 'audio', 'video', 'document'). - **message** (object) - Required - The message content, structured according to the 'type'. - **text** (string) - Required if type is 'text' - The text content of the message. - **link** (string) - Required if type is 'image' - The URL of the image. ### Request Example ```json { "to": "+1234567890", "from": "your_whatsapp_number", "type": "text", "message": { "text": "Hello, this is a bulk message!" } } ``` ### Response #### Success Response (202) - **request_id** (string) - Unique identifier for the request. - **method** (string) - The HTTP method used. - **http_code** (integer) - The HTTP status code. - **metadata** (object) - Contains information about the message sending status. - **failed** (integer) - Number of messages that failed to send. - **total** (integer) - Total number of messages sent. - **success** (integer) - Number of messages that were successfully sent. - **response** (object) - Contains the detailed response for each message. - **whatsapp** (object) - **messages** (array) - An array of message status objects. - **code** (integer) - The status code for the individual message. - **error_data** (object or null) - Error details if the message failed. - **status** (string) - The status of the message ('success' or 'failed'). - **data** (object) - Contains message-specific data. - **sid** (string) - The unique identifier for the sent message. #### Response Example ```json { "request_id": "b434e927a5844175b23059cd96feea3d", "method": "POST", "http_code": 202, "metadata": { "failed": 0, "total": 2, "success": 2 }, "response": { "whatsapp": { "messages": [ { "code": 202, "error_data": null, "status": "success", "data": { "sid": "2FdiiEQUosckPhpZfuVwfjxiSlc16a4" } }, { "code": 202, "error_data": null, "status": "success", "data": { "sid": "2FdiiDU5hAK8tW0Atq340Ayngpx16a4" } } ] } } } ``` ``` -------------------------------- ### Send Order Details Message (Payment Message) via UPI Intent Source: https://developer.exotel.com/api/whatsapp This example demonstrates how to send an interactive order details message using the WhatsApp API, which can include payment information and a call to action for completing an order. ```APIDOC ## POST /v2/accounts/{{AccountSid}}/messages ### Description Sends an interactive WhatsApp message with order details, including payment information and a "Review and Pay" action. ### Method POST ### Endpoint https://{{AuthKey}}:{{AuthToken}}@{{SubDomain}}/v2/accounts/{{AccountSid}}/messages ### Request Body - **whatsapp** (object) - Required - Contains the WhatsApp message payload. - **messages** (array) - Required - A list of messages to send. - **from** (string) - Required - The sender's WhatsApp number. - **to** (string) - Required - The recipient's WhatsApp number. - **content** (object) - Required - The content of the message. - **type** (string) - Required - Type of content, must be "interactive". - **interactive** (object) - Required - Interactive message details. - **type** (string) - Required - Type of interactive message, must be "order_details". - **header** (object) - Optional - Header for the interactive message. - **type** (string) - Required - Type of header, e.g., "image". - **image** (object) - Required if type is "image". - **link** (string) - Required - URL of the image. - **body** (object) - Required - Body of the interactive message. - **text** (string) - Required - Text content for the body. - **footer** (object) - Optional - Footer for the interactive message. - **text** (string) - Required - Text content for the footer. - **action** (object) - Required - Action to be performed. - **name** (string) - Required - Name of the action, must be "review_and_pay". - **parameters** (object) - Required - Parameters for the action. - **reference_id** (string) - Required - Unique reference ID for the order. - **type** (string) - Required - Type of digital good, e.g., "digital-goods". - **payment_type** (string) - Required - Payment gateway, e.g., "payment_gateway:razorpay". - **payment_configuration** (string) - Required - Payment configuration details. - **currency** (string) - Required - Currency of the payment. - **total_amount** (object) - Required - Total amount of the order. - **value** (integer) - Required - The amount value. - **offset** (integer) - Required - The offset for the amount. - **order** (object) - Required - Details of the order. - **status** (string) - Required - Status of the order, e.g., "pending". - **items** (array) - Required - List of items in the order. - **retailer_id** (string) - Required - Retailer's ID for the item. - **name** (string) - Required - Name of the item. - **amount** (object) - Required - Amount of the item. - **value** (integer) - Required - The amount value. - **offset** (integer) - Required - The offset for the amount. - **sale_amount** (object) - Required - Sale amount of the item. - **value** (integer) - Required - The amount value. - **offset** (integer) - Required - The offset for the amount. - **quantity** (integer) - Required - Quantity of the item. - **subtotal** (object) - Required - Subtotal of the order. - **value** (integer) - Required - The amount value. - **offset** (integer) - Required - The offset for the amount. - **tax** (object) - Optional - Tax details. - **value** (integer) - Required - The amount value. - **offset** (integer) - Required - The offset for the amount. - **description** (string) - Optional - Description of the tax. - **shipping** (object) - Optional - Shipping details. - **value** (integer) - Required - The amount value. - **offset** (integer) - Required - The offset for the amount. - **description** (string) - Optional - Description of the shipping. - **discount** (object) - Optional - Discount details. - **value** (integer) - Required - The amount value. - **offset** (integer) - Required - The offset for the amount. - **description** (string) - Optional - Description of the discount. - **discount_program_name** (string) - Optional - Name of the discount program. ### Request Example ```json { "whatsapp": { "messages": [ { "from": "9172XXXXXXXX", "to": "9190XXXXXXXX", "content": { "type": "interactive", "interactive": { "type": "order_details", "header": { "type": "image", "image": { "link": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Home_made_sour_dough_bread.jpg/640px-Home_made_sour_dough_bread.jpg" } }, "body": { "text": "Click on the Pay Now button to complete the order" }, "footer": { "text": "Thank You!" }, "action": { "name": "review_and_pay", "parameters": { "reference_id": "57848", "type": "digital-goods", "payment_type": "payment_gateway:razorpay", "payment_configuration": "Checking-paymentstest", "currency": "INR", "total_amount": { "value": 1000, "offset": 100 }, "order": { "status": "pending", "items": [ { "retailer_id": "1234567", "name": "Bread", "amount": { "value": 1400, "offset": 100 }, "sale_amount": { "value": 1000, "offset": 100 }, "quantity": 1 } ], "subtotal": { "value": 1000, "offset": 100 }, "tax": { "value": 100, "offset": 100, "description": "GST Inclusive" }, "shipping": { "value": 0, "offset": 100, "description": "Via Postal" }, "discount": { "value": 100, "offset": 100, "description": "For Premium Customers", "discount_program_name": "optional_text" } } } } } } } ] } } ``` ### Response #### Success Response (200) - **message_sid** (string) - The unique identifier for the sent message. - **status** (string) - The status of the message (e.g., "queued", "sent"). #### Response Example ```json { "message_sid": "SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "status": "queued" } ``` ``` -------------------------------- ### Send WhatsApp Message with Image Template Source: https://developer.exotel.com/api/whatsapp This example demonstrates how to send a WhatsApp message using a template that includes an image. The payload specifies the sender, recipient, message type, template name, language, and image URL. ```APIDOC ## POST /whatsapp/bulk ### Description Send bulk WhatsApp messages to multiple recipients. ### Method POST ### Endpoint /whatsapp/bulk ### Request Body - **custom_data** (string) - Optional - Custom data to be associated with the message. - **status_callback** (string) - Optional - URL to receive status updates for the message. - **whatsapp** (object) - Required - Contains WhatsApp message details. - **messages** (array) - Required - A list of messages to send. - **from** (string) - Required - The sender's WhatsApp number. - **to** (string) - Required - The recipient's WhatsApp number. - **content** (object) - Required - The content of the message. - **type** (string) - Required - Type of content, e.g., "template". - **template** (object) - Required if type is "template". - **name** (string) - Required - The name of the WhatsApp template. - **language** (object) - Required - Language configuration for the template. - **policy** (string) - Required - Language policy, e.g., "deterministic". - **code** (string) - Required - Language code, e.g., "en". - **components** (array) - Required - Components of the template. - **type** (string) - Required - Type of component, e.g., "header" or "body". - **parameters** (array) - Required - Parameters for the component. - **type** (string) - Required - Type of parameter, e.g., "image". - **image** (object) - Required if type is "image". - **link** (string) - Required - URL of the image. ### Request Example ```json { "custom_data": "custom12", "status_callback": "www.webhook.site", "whatsapp": { "messages": [ { "from": "+91XXXXXXXXXX", "to": "91XXXXXXXXXX", "content": { "type": "template", "template": { "name": "exotel_image_1", "language": { "policy": "deterministic", "code": "en" }, "components": [ { "type": "header", "parameters": [ { "type": "image", "image": { "link": "https://image.shutterstock.com/image-photo/happy-puppy-dog-smiling-on-260nw-1799966587.jpg" } } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "John Doe" } ] } ] } } } ] } } ``` ### Response #### Success Response (200) - **message_id** (string) - Unique identifier for the sent message. - **status** (string) - Status of the message (e.g., "sent", "queued"). #### Response Example ```json { "message_id": "msg_12345abcde", "status": "queued" } ``` ``` -------------------------------- ### WhatsApp Status Callback Example Source: https://developer.exotel.com/api/whatsapp This JSON structure represents a status callback for a WhatsApp message, detailing its delivery status and associated information. It is received when a message's delivery status changes. ```json { "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" } ] } } ``` -------------------------------- ### Send Image Template Message Source: https://developer.exotel.com/api/whatsapp This section provides sample requests for sending an image template message via the WhatsApp API. It includes examples for cURL, Node.js, PHP, Python, and Ruby. ```APIDOC ## POST /v2/accounts//messages ### Description Sends an image template message via WhatsApp. ### Method POST ### Endpoint `https://:/v2/accounts//messages` ### Request Body ```json { "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" } ] } ] } } } ] } } ``` ### Request Example (cURL) ```bash curl -XPOST "https://:/v2/accounts//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" } ] } ] } } } ] } }' ``` ### Request Example (Node.js - Native) ```javascript var https = require('follow-redirects').https; var fs = require('fs'); var qs = require('querystring'); var options = { 'method': 'POST', 'hostname': '', 'port': null, 'path': '/v2/accounts//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': JSON.stringify({ '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' } ] } ] } } } ] }) }); req.write(postData); req.end(); ``` ```