WhatsApp Template Message API Library

This page provides a comprehensive library of WhatsApp template API payloads for both creating and sending templates.

Template Type API Payloads

Authentication (OTP)

WhatsApp Authentication OTP Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates an AUTHENTICATION template with a COPY_CODE button.

View JSON

{
"language":"en_US",
"name":"authentication_template_demo",
"category":"AUTHENTICATION",
"components":[
{
"type":"BODY",
"add_security_recommendation":true
},
{
"type":"FOOTER",
"code_expiration_minutes":5
},
{
"type":"BUTTONS",
"buttons":[
{
"type":"OTP",
"text":"Copy Code",
"otp_type":"COPY_CODE"
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template, populating the body parameter and the copyCode parameter with the OTP.

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"authentication_template_demo",
"components":[
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"123456"
}
]
},
{
"type":"Button",
"subType":1,
"index":0,
"parameters":[
{
"type":"text",
"text":"123456"
}
]
}
]
}
}
}

Media Header (Image)

WhatsApp Image Header Template Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates a MARKETING template with an IMAGE header and a dynamic URL button.

View JSON

{
"language":"en_US",
"name":"marketing_template_demo",
"category":"MARKETING",
"components":[
{
"type":"HEADER",
"format":"image",
"examples":[
"https://iili.io/KtDO5BV.jpg"
]
},
{
"type":"BODY",
"text":"Hi {{1}}, ready to elevate your customer communications? Discover the power of 8x8 CPaaS.",
"examples":[
"Tony"
]
},
{
"type":"FOOTER",
"text":"Powered by 8x8"
},
{
"type":"BUTTONS",
"buttons":[
{
"type":"URL",
"text":"Discover all channels",
"url":"https://cpaas.8x8.com/en/products/{{1}}",
"examples":[
"omnichannel-messaging"
]
},
{
"type":"quick_reply",
"text":"Talk to Sales"
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template, providing the url for the image, the text for the body, and the dynamic part of the url button.

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"marketing_template_demo",
"components":[
{
"type":"header",
"parameters":[
{
"type":"image",
"url":"https://iili.io/KtDO5BV.jpg"
}
]
},
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"Tony"
}
]
},
{
"type":"button",
"index":"0",
"subType":"url",
"parameters":[
{
"type":"text",
"text":"omnichannel-messaging"
}
]
}
]
}
}
}

Media Header (Video)

WhatsApp Video Header Template Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates a UTILITY template with a VIDEO header.

View JSON

{
"language":"en_US",
"name":"video_template_demo",
"category":"UTILITY",
"components":[
{
"type":"HEADER",
"format":"Video",
"examples":[
"https://samplelib.com/lib/preview/mp4/sample-5s.mp4"
]
},
{
"type":"BODY",
"text":"Hi {{1}}, this is the video.",
"examples":[
"Alex"
]
},
{
"type":"FOOTER",
"text":"Powered by 8x8"
},
{
"type":"BUTTONS",
"buttons":[
{
"type":"URL",
"text":"Download",
"url":"https://cpaas.8x8.com/en/products/{{1}}",
"examples":[
"omnichannel-messaging"
]
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template, providing the url for the video and the text for the body parameter.

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"video_template_demo",
"components":[
{
"type":"header",
"parameters":[
{
"type":"video",
"url":"https://samplelib.com/lib/preview/mp4/sample-5s.mp4"
}
]
},
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"Alex"
}
]
},
{
"type":"button",
"index":"0",
"subType":"url",
"parameters":[
{
"type":"text",
"text":"omnichannel-messaging"
}
]
}
]
}
}
}

Media Header (Document)

WhatsApp Document Header Template Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates a UTILITY template with a DOCUMENT header.

View JSON

{
"language":"en_US",
"name":"document_template_demo",
"category":"UTILITY",
"components":[
{
"type":"HEADER",
"format":"Document",
"examples":[
"https://pdfobject.com/pdf/sample.pdf"
]
},
{
"type":"BODY",
"text":"Hi {{1}}, this is the document.",
"examples":[
"Alex"
]
},
{
"type":"FOOTER",
"text":"Powered by 8x8"
},
{
"type":"BUTTONS",
"buttons":[
{
"type":"URL",
"text":"Download",
"url":"https://cpaas.8x8.com/en/products/{{1}}",
"examples":[
"omnichannel-messaging"
]
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template, providing the url for the document and the text for the body parameter.

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"document_template_demo",
"components":[
{
"type":"header",
"parameters":[
{
"type":"document",
"url":"https://pdfobject.com/pdf/sample.pdf"
}
]
},
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"Alex"
}
]
},
{
"type":"button",
"index":"0",
"subType":"url",
"parameters":[
{
"type":"text",
"text":"omnichannel-messaging"
}
]
}
]
}
}
}

Location Header

WhatsApp Location Header Template Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates a UTILITY template with a LOCATION header. Note: No example is needed at creation.

View JSON

{
"language":"en_US",
"name":"order_tracking_template_demo",
"category":"UTILITY",
"components":[
{
"type":"HEADER",
"format":"Location"
},
{
"type":"BODY",
"text":"Hi {{1}}, your delivery is on the way, you can track your delivery effectively.",
"examples":[
"Alex"
]
},
{
"type":"FOOTER",
"text":"Powered by 8x8"
},
{
"type":"BUTTONS",
"buttons":[
{
"type":"URL",
"text":"Track delivery",
"url":"https://cpaas.8x8.com/en/products/{{1}}",
"examples":[
"omnichannel-messaging"
]
},
{
"type":"PHONE_NUMBER",
"text":"Request address change",
"phoneNumber":"62211521",
"country":"SG"
},
{
"type":"quick_reply",
"text":"Change delivery time"
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template, providing the full location object (lat, lon, name, address) in the header parameters.

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"order_tracking_template_demo",
"components":[
{
"type":"header",
"parameters":[
{
"type":"location",
"location":{
"latitude":"1.2857",
"longitude":"103.8479",
"name":"8x8 Singapore Office",
"address":"1 George St, #22-03/04 One George Street, Singapore 049145"
}
}
]
},
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"Alex"
}
]
},
{
"type":"button",
"index":"0",
"subType":"url",
"parameters":[
{
"type":"text",
"text":"omnichannel-messaging"
}
]
}
]
}
}
}

Carousel Template

WhatsApp Carousel Template Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates a MARKETING template with a CAROUSEL component containing multiple cards.

View JSON

{
"language":"en_US",
"name":"cpaas_features_carousel_demo",
"category":"MARKETING",
"components":[
{
"type":"body",
"text":"Hi {{1}}, swipe through to discover the power of 8x8 CPaaS. Book a demo and get {{2}} in free API credits!",
"examples":[
"Alex",
"$100"
]
},
{
"type":"carousel",
"cards":[
{
"components":[
{
"type":"header",
"format":"image",
"examples":[
"https://iili.io/KtDO5BV.jpg"
]
},
{
"type":"body",
"text":"Engage on every channel your customers love."
},
{
"type":"buttons",
"buttons":[
{
"type":"url",
"text":"See All Channels",
"url":"https://www.8x8.com/cpaas/{{1}}",
"examples":[
"channels"
]
},
{
"type":"quick_reply",
"text":"Talk to Sales"
}
]
}
]
},
{
"components":[
{
"type":"header",
"format":"image",
"examples":[
"https://iili.io/KtDO5BV.jpg"
]
},
{
"type":"body",
"text":"Connect globally, instantly with 99.99% uptime."
},
{
"type":"buttons",
"buttons":[
{
"type":"url",
"text":"Explore Our Network",
"url":"https://www.8x8.com/cpaas/{{1}}",
"examples":[
"global-network"
]
},
{
"type":"quick_reply",
"text":"Talk to Sales"
}
]
}
]
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template, populating the main body parameters and the dynamic parameters for each card's header (image) and button (url).

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"cpaas_features_carousel_demo",
"components":[
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"Alex"
},
{
"type":"text",
"text":"$100"
}
]
},
{
"type":"carousel",
"cards":[
{
"cardIndex":0,
"components":[
{
"type":"header",
"parameters":[
{
"type":"image",
"url":"https://iili.io/KtDO5BV.jpg"
}
]
},
{
"type":"button",
"index":0,
"subType":"url",
"parameters":[
{
"type":"text",
"text":"channels"
}
]
}
]
},
{
"cardIndex":1,
"components":[
{
"type":"header",
"parameters":[
{
"type":"image",
"url":"https://iili.io/KtDO5BV.jpg"
}
]
},
{
"type":"button",
"index":0,
"subType":"url",
"parameters":[
{
"type":"text",
"text":"global-network"
}
]
}
]
}
]
}
]
}
}
}

Flow Template

WhatsApp Flow Template Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates a UTILITY template with a FLOW button. The Flow must be published before creating the template.

View JSON

{
"name":"appointment_booking_template_190126",
"language":"en_US",
"category":"MARKETING",
"components":[
{
"type":"HEADER",
"format":"image",
"examples":[
"https://iili.io/KtDO5BV.jpg"
]
},
{
"type":"BODY",
"text":"Hello! Ready to transform your customer engagement? Schedule a demo with our 8x8 sales team to explore our SMS, Voice, and Video APIs."
},
{
"type":"FOOTER",
"text":"Empowering global communications."
},
{
"type":"BUTTONS",
"buttons":[
{
"type":"FLOW",
"text":"Schedule now",
"flowId":"1633450807827276"
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template with the Flow button. When users tap the button, the WhatsApp Flow opens in-app.

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"appointment_booking_template_190126",
"components":[
{
"type":"header",
"parameters":[
{
"type":"image",
"url":"https://iili.io/KtDO5BV.jpg"
}
]
},
{
"type":"button",
"subType":"flow",
"index":0,
"parameters":[
{
"type":"action"
}
]
}
]
}
}
}
tip

Learn more about building and sending WhatsApp Flows in the WhatsApp Flows guide.

Button Combination

WhatsApp Button Combination Template Example

Create Template: POST https://chatapps.8x8.com/api/v1/accounts/{accountId}/channels/{channelId}/templates

Creates a MARKETING template with an IMAGE header and a combination of 1 COPY_CODE button, 2 URL buttons, 1 PHONE_NUMBER button, 1 FLOW button, and 6 quick_reply buttons.

View JSON

{
"language":"en_US",
"name":"button_combination_template_demo",
"category":"MARKETING",
"components":[
{
"type":"HEADER",
"format":"image",
"examples":[
"https://iili.io/KtDO5BV.jpg"
]
},
{
"type":"BODY",
"text":"Hi {{1}}, ready to elevate your customer communications? Discover the power of 8x8 CPaaS. We provide the tools to connect with your customers on their favorite channels, seamlessly and reliably. ",
"examples":[
"Tony"
]
},
{
"type":"FOOTER",
"text":"Powered by 8x8"
},
{
"type":"BUTTONS",
"buttons":[
{
"type":"COPY_CODE",
"examples":[
"250FF"
]
},
{
"type":"URL",
"text":"Discover all omnichannels",
"url":"https://cpaas.8x8.com/en/products/{{1}}",
"examples":[
"omnichannel-messaging"
]
},
{
"type":"URL",
"text":"Discover all channels",
"url":"https://cpaas.8x8.com/en/products/{{1}}",
"examples":[
"channels"
]
},
{
"type":"PHONE_NUMBER",
"text":"Request address change",
"phoneNumber":"62211521",
"country":"SG"
},
{
"type":"FLOW",
"text":"Book Appointment",
"flowId":"1234567890123456"
},
{
"type":"quick_reply",
"text":"Want to know more"
},
{
"type":"quick_reply",
"text":"Talk to Sales"
},
{
"type":"quick_reply",
"text":"Call me"
},
{
"type":"quick_reply",
"text":"Schedule demo"
},
{
"type":"quick_reply",
"text":"Get service quotation"
},
{
"type":"quick_reply",
"text":"Get support"
}
]
}
]
}

Send Template: POST https://chatapps.8x8.com/api/v1/subaccounts/{subAccountId}/messages

Sends the template, providing the url for the image, the text for the body, the couponCode for the COPY_CODE button, the dynamic parts of the url buttons, and the optional Flow parameters. Note: COPY_CODE, URL, and FLOW buttons need to be specified in the send request; quick_reply and PHONE_NUMBER buttons are static.

View JSON

{
"user":{
"msisdn":"+15551234567"
},
"type":"template",
"content":{
"template":{
"language":"en_US",
"name":"button_combination_template_demo",
"components":[
{
"type":"header",
"parameters":[
{
"type":"image",
"url":"https://iili.io/KtDO5BV.jpg"
}
]
},
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"Jason"
}
]
},
{
"type":"button",
"index":"0",
"subType":"copyCode",
"parameters":[
{
"type":"couponCode",
"couponCode":"25OFF"
}
]
},
{
"type":"button",
"index":"1",
"subType":"url",
"parameters":[
{
"type":"text",
"text":"omnichannel-messaging"
}
]
},
{
"type":"button",
"index":"2",
"subType":"url",
"parameters":[
{
"type":"text",
"text":"channel"
}
]
},
{
"type":"button",
"index":"4",
"subType":"flow",
"parameters":[
{
"type":"action",
"action":"navigate",
"navigateScreen":"APPOINTMENT_SCREEN",
"flowActionData":{
"customerName":"Jason",
"preferredDate":"2024-02-15"
}
}
]
}
]
}
}
}

Source: https://developer.8x8.com/connect/docs/whatsapp/template-message-api-library · 8x8 CPaaS Developer Docs. Synced for support deflection.

Was this article helpful?
or
0 out of 0 found this helpful

0 Comments

Please sign in to leave a comment.

Didn't find what you were looking for?

Submit a request