Message with parameters header body footer and with buttons Estimated reading: 3 minutes 69 views PingtoChat’s Utility Category enables businesses to send pre-approved WhatsApp template messages through the WhatsApp Business API. The supported message types include:Messages Without Parameters Messages With Parameters Messages With Parameters and Attachments Messages With Buttons (Quick Reply, URL, Phone Number)For URL and Phone Number buttons, they do not need to be included in the response.Endpoint:POST http://{{your_domain}}/api/v1.0/{{phone_number_id}}/{{key}}/messagesReplace placeholders:{{key}}: Your API key for authentication.How to create key{{your_domain}}: Your domain URL where the API is hosted.{{phone_number_id}}: The unique identifier of the phone number used for sending messages.Headers:Content-Type: application/json Authorization: Bearer <your_access_token>Example Payload:{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "91xxxxxxxxxx", "type": "template", "template": { "name": "utility_ab", "language": { "code": "en_us" }, "components": [ { "type": "header", "parameters": [ { "type": "text", "text": "p2c" } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "12CR007" } ] }, { "type": "button", "sub_type": "quick_reply", "index": 0, "parameters": [ { "type": "text", "text": "Unsubscribe from Promos" } ] } ] } }Key Components1. HeaderType: Text Content: "p2c" Purpose: Displays a short heading or key identifier.2. BodyType: Text Content: "12CR007" Purpose: Contains the main message content.3. ButtonsType: Quick Reply Text: "Unsubscribe from Promos" Purpose: Allows users to quickly opt out of promotional messages.Response StructureA successful request will return an HTTP status code of 200 OK along with the following response:{ "messaging_product": "whatsapp", "contacts": [ { "input": "91xxxxxxxxxx", "wa_id": "91xxxxxxxxxx", "status_id": "MTA0NDI4" } ], "messages": [ { "id": "8Eb8pQg0Xl", "message_status": "accepted" } ] }Field Descriptionsmessaging_productType: String Description: Indicates the messaging platform. Always returns "whatsapp".contactsType: Array Description: Contains information about the message recipient.Fields:input:Type: String Description: The phone number used in the API request. wa_id:Type: String Description: The WhatsApp ID associated with the phone number. status_id:Type: String Description: A unique identifier for the status of the message.messagesType: Array Description: Contains details about the sent message.Fields:id:Type: String Description: A unique identifier for the message sent. message_status:Type: String Description: The status of the message at the time of the response. Example values include: "accepted" – The message was successfully processed. Sample codes CURL PHP Java Ruby Python C# Node JS curl –location ‘https://example.com/api/v1.0/phone_number_id/key/messages’ \ –header ‘Content-Type: application/json’ \ –header ‘Authorization: Bearer xxxxxxxxxxxx…………..’ \ –header ‘Cookie: XSRF-TOKEN=xxxxxxxxxxxx…………..’ \ –data ‘{ “messaging_product”: “whatsapp”, “recipient_type”: “individual”, “to”: “91xxxxxxxxxx”, “type”: “template”, “template”: { “name”: “utility_ab”, “language”: { “code”: “en_us” }, “components”: [ { “type”: “header”, “parameters”: [ { “type”: “text”, “text”: “p2c” } ] }, { “type”: “body”, “parameters”: [ { “type”: “text”, “text”: “12CR007” } ] }, { “type”: “button”, “sub_type”: “quick_reply”, “index”: 0, “parameters”: [ { “type”: “text”, “text”: “Unsubscribe from Promos” } ] } ] } }’ ‘<'+'?'+'php'+ ` $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => ‘https://example.com/api/v1.0/phone_number_id/key/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 =>'{ “messaging_product”: “whatsapp”, “recipient_type”: “individual”, “to”: “91xxxxxxxxxx”, “type”: “template”, “template”: { “name”: “utility_ab”, “language”: { “code”: “en_us” }, “components”: [ { “type”: “header”, “parameters”: [ { “type”: “text”, “text”: “p2c” } ] }, { “type”: “body”, “parameters”: [ { “type”: “text”, “text”: “12CR007” } ] }, { “type”: “button”, “sub_type”: “quick_reply”, “index”: 0, “parameters”: [ { “type”: “text”, “text”: “Unsubscribe from Promos” } ] } ] } }’, CURLOPT_HTTPHEADER => array( ‘Content-Type: application/json’, ‘Authorization: Bearer xxxxxxxxxxxx…………..’, ‘Cookie: XSRF-TOKEN=xxxxxxxxxxxx…………..’ ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ?>;`; OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse(“application/json”); RequestBody body = RequestBody.create(mediaType, “{\r\n \”messaging_product\”: \”whatsapp\”,\r\n \”recipient_type\”: \”individual\”,\r\n \”to\”: \”91xxxxxxxxxx\”,\r\n \”type\”: \”template\”,\r\n \”template\”: {\r\n \”name\”: \”utility_ab\”,\r\n \”language\”: {\r\n \”code\”: \”en_us\”\r\n },\r\n \”components\”: [\r\n {\r\n \”type\”: \”header\”,\r\n \”parameters\”: [\r\n {\r\n \”type\”: \”text\”,\r\n \”text\”: \”p2c\”\r\n }\r\n ]\r\n },\r\n {\r\n \”type\”: \”body\”,\r\n \”parameters\”: [\r\n {\r\n \”type\”: \”text\”,\r\n \”text\”: \”12CR007\”\r\n }\r\n ]\r\n },\r\n {\r\n \”type\”: \”button\”,\r\n \”sub_type\”: \”quick_reply\”,\r\n \”index\”: 0,\r\n \”parameters\”: [\r\n {\r\n \”type\”: \”text\”,\r\n \”text\”: \”Unsubscribe from Promos\”\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}”); Request request = new Request.Builder() .url(“https://example.com/api/v1.0/phone_number_id/key/messages”) .method(“POST”, body) .addHeader(“Content-Type”, “application/json”) .addHeader(“Authorization”, “Bearer xxxxxxxxxxxx…………..”) .addHeader(“Cookie”, “XSRF-TOKEN=xxxxxxxxxxxx…………..”) .build(); Response response = client.newCall(request).execute(); require “uri” require “json” require “net/http” url = URI(“https://example.com/api/v1.0/phone_number_id/key/messages”) https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request[“Content-Type”] = “application/json” request[“Authorization”] = “Bearer xxxxxxxxxxxx…………..” request[“Cookie”] = “XSRF-TOKEN=xxxxxxxxxxxx…………..” request.body = JSON.dump({ “messaging_product”: “whatsapp”, “recipient_type”: “individual”, “to”: “91xxxxxxxxxx”, “type”: “template”, “template”: { “name”: “utility_ab”, “language”: { “code”: “en_us” }, “components”: [ { “type”: “header”, “parameters”: [ { “type”: “text”, “text”: “p2c” } ] }, { “type”: “body”, “parameters”: [ { “type”: “text”, “text”: “12CR007” } ] }, { “type”: “button”, “sub_type”: “quick_reply”, “index”: 0, “parameters”: [ { “type”: “text”, “text”: “Unsubscribe from Promos” } ] } ] } }) response = https.request(request) puts response.read_body import requests import json url = “https://example.com/api/v1.0/phone_number_id/key/messages” payload = json.dumps({ “messaging_product”: “whatsapp”, “recipient_type”: “individual”, “to”: “91xxxxxxxxxx”, “type”: “template”, “template”: { “name”: “utility_ab”, “language”: { “code”: “en_us” }, “components”: [ { “type”: “header”, “parameters”: [ { “type”: “text”, “text”: “p2c” } ] }, { “type”: “body”, “parameters”: [ { “type”: “text”, “text”: “12CR007” } ] }, { “type”: “button”, “sub_type”: “quick_reply”, “index”: 0, “parameters”: [ { “type”: “text”, “text”: “Unsubscribe from Promos” } ] } ] } }) headers = { ‘Content-Type’: ‘application/json’, ‘Authorization’: ‘Bearer xxxxxxxxxxxx…………..’, ‘Cookie’: ‘XSRF-TOKEN=xxxxxxxxxxxx…………..’ } response = requests.request(“POST”, url, headers=headers, data=payload) print(response.text) var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, “https://example.com/api/v1.0/phone_number_id/key/messages”); request.Headers.Add(“Authorization”, “Bearer xxxxxxxxxxxx…………..”); request.Headers.Add(“Cookie”, “XSRF-TOKEN=xxxxxxxxxxxx…………..”); var content = new StringContent(“{\r\n \”messaging_product\”: \”whatsapp\”,\r\n \”recipient_type\”: \”individual\”,\r\n \”to\”: \”91xxxxxxxxxx\”,\r\n \”type\”: \”template\”,\r\n \”template\”: {\r\n \”name\”: \”utility_ab\”,\r\n \”language\”: {\r\n \”code\”: \”en_us\”\r\n },\r\n \”components\”: [\r\n {\r\n \”type\”: \”header\”,\r\n \”parameters\”: [\r\n {\r\n \”type\”: \”text\”,\r\n \”text\”: \”p2c\”\r\n }\r\n ]\r\n },\r\n {\r\n \”type\”: \”body\”,\r\n \”parameters\”: [\r\n {\r\n \”type\”: \”text\”,\r\n \”text\”: \”12CR007\”\r\n }\r\n ]\r\n },\r\n {\r\n \”type\”: \”button\”,\r\n \”sub_type\”: \”quick_reply\”,\r\n \”index\”: 0,\r\n \”parameters\”: [\r\n {\r\n \”type\”: \”text\”,\r\n \”text\”: \”Unsubscribe from Promos\”\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}”, null, “application/json”); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); var request = require(‘request’); var options = { ‘method’: ‘POST’, ‘url’: ‘https://example.com/api/v1.0/phone_number_id/key/messages’, ‘headers’: { ‘Content-Type’: ‘application/json’, ‘Authorization’: ‘Bearer xxxxxxxxxxxx…………..’, ‘Cookie’: ‘XSRF-TOKEN=xxxxxxxxxxxx…………..’ }, body: JSON.stringify({ “messaging_product”: “whatsapp”, “recipient_type”: “individual”, “to”: “91xxxxxxxxxx”, “type”: “template”, “template”: { “name”: “utility_ab”, “language”: { “code”: “en_us” }, “components”: [ { “type”: “header”, “parameters”: [ { “type”: “text”, “text”: “p2c” } ] }, { “type”: “body”, “parameters”: [ { “type”: “text”, “text”: “12CR007” } ] }, { “type”: “button”, “sub_type”: “quick_reply”, “index”: 0, “parameters”: [ { “type”: “text”, “text”: “Unsubscribe from Promos” } ] } ] } }) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });