Create a WhatsApp Template with Sample Media

POST Method

Kaleyra.io allows you to create WhatsApp templates with sample media using the API. After you create a WhatsApp template with sample media, it has to get approved by Meta before you can use the WhatsApp template with sample media to send messages.

Template Category

📘

Note:

Marketing, Authentication, and Utility template categories are supported by Kaleyra. For more information, see the WhatsApp Template Category page.

To create the WhatsApp templates with sample media, perform the following:

Signup or Login to Kaleyra.io and Create your API key

Refer to the Create an API Key page for steps to create your API key. To view the API Key and the SID, see View API Key and SID.

📘

Note:

After you sign up, your account will be on the trial version. You must complete the KYC to access all the features in Kaleyra.io.

Base URL

https://<api_domain>/v1/<SID>

API Domain and Value

api_domainValue
IN podapi.in.kaleyra.io
SG Podapi.kaleyra.io
EU Podapi.eu.kaleyra.io
NA podapi.na.kaleyra.ai

API Request to Create WhatsApp Templates

To create the WhatsApp templates, use the whatsapp/templates endpoint with the following request method:

Request format

The following is the request format to create WhatsApp template with sample media:

curl --location 'https://<api_domain>/v1/<sid>/whatsapp/template' \
--header 'api-key: <api_key>' \
--form 'name="<name>"' \
--form 'category="<category>"' \
--form 'language="<language>"' \
--form 'header="{\"type\":\"image\"}";type=application/json' \
--form 'body="<body>"' \
--form 'sample_body="<sample body>"' \
--form 'footer="<footer>"' \
--form 'waba_id="<waba_id>"' \
--form 'button_data="[
	{
    \"type\":\"<type>\",
    \"quick_reply1\":\"<quick_reply1>\",
    \"quick_reply2\":\"<quick_reply2>\",
	\"quick_reply3\":\"<quick_reply3>\"
}
]";type=<type>' \
--form 'sample_media_url="<sample_media_url>"' \
--form 'sample_media_file="<sample_media_file>"'

Sample Request Format

The following is the sample request format to create WhatsApp templates with sample media:

curl --location 'https://api.in.kaleyra.io/v1/HXXXXXXX071IN/whatsapp/template' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--form 'name="template_01"' \
--form 'category="marketing"' \
--form 'language="en"' \
--form 'header="{\"type\":\"image\"}";type=application/json' \
--form 'body="Hi, this is a sample message"' \
--form 'sample_body="Up to 70% off on Home, Kitchen, and outdoor"' \
--form 'footer="This is the footer content"' \
--form 'waba_id="13XXXXXXXXXXXXX"' \
--form 'button_data="[
	{
    \"type\":\"QUICK_REPLY\",
    \"quick_reply1\":\"Bye\",
    \"quick_reply2\":\"Sample\",
	\"quick_reply3\":\"Okie\"
}
]";type=application/json' \
--form 'sample_media_url="https://www.kaleyra.com/wp-content/uploads/kaleyra.png"' \
--form 'sample_media_file=@"/C:/Users/company_A/Downloads/videoplayback.mp4"'

Parameter and Data Types

The following is the list of parameter and data types supported to create a WhatsApp template with a sample media:

Parameter

Data Type

Description

Example

Mandatory

sid

String

Account SID (Security Identifier).

HXXXXXXX071IN

True

api-key

String

API key generated from Kaleyra.io account.

Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3

True

name

String

Template name.

template_01

True

category

String

Select one of the following:

  • Marketing
  • Authentication
  • Utility

marketing

True

language

String

The language in which, you want to create the template.

en

True

header

JSON/String

Select one of the following:

  • Image
  • Video
  • Document
  • Text.

{"type": "image"}

True

body

String

Body of the message.

Hi, this is a sample message.

True

sample_body

String

Sample value for the variable pass in the body field.

Up to 70% off on Home, Kitchen, and outdoor

True

footer

String

Footer text

This is the footer content

False

waba_id

String

WhatsApp Business Account ID

13XXXXXXXXXXXXX

True

button_data

Array of Objects

Specifies the type of button in the template.

[
{
"type":"QUICK_REPLY",
"quick_reply1":"Bye",
"quick_reply2":"Sample",
"quick_reply3":"Okie"
}
][
{
\"type\":\"QUICK_REPLY\",
\"quick_reply1\":\"Bye\",
\"quick_reply2\":\"Sample\",
\"quick_reply3\":\"Okie\"
}
]

False

sample_media_file

Media

Upload a media file from the following list:

  • Image (.JPG, .PNG, or .JPEG)
  • Video (.mp4)
  • Documents (.pdf)

@/C:/Users/company_A/Downloads/videoplayback.mp4

Conditional (True/False) Note: If the header_type is Image/Video/PDF, then the sample_media_file is mandatory.

sample_media_url

String

The sample media URL should be public and have a file extension and valid SSL certificate.
Note: URL path is supported for image/video/media instead of uploading it.
If both media_file and media_url are passed in the API request, then only "media_file" will be considered.

https://www.kaleyra.com/wp-content/uploads/kaleyra.png

Conditional (True/False) Note: If the header_type is Image/Video/PDF, then the sample_media_url is mandatory instead of sample_media_file.

The following table lists the button_data attributes:

Parameter

Data Type

Description

Example

Mandatory?

type (button_data) (Optional)

String

It can be one of the following:

  • QUICK_REPLY
  • PHONE_NUMBER
  • URL

QUICK_REPLY

False

quick_reply_1

String

Specifies the quick reply button text.

Bye

False

quick_reply_2

String

Specifies the quick reply button text.

Sample

False

quick_reply_3

String

Specifies the quick reply button text.

Okie

False

Sample Success Response

The following success message appears with status 200:

{
    "status": 200,
    "message": "Template created successfully.",
    "data": [],
    "error": {}
}

Sample Failure Response Format

  1. Sample validation error when API is unable to create the WhatsApp templates with sample media:
{
    "error": {
        "code": "E996",
        "type": "VALIDATION_ERROR",
        "parameter": "message",
        "message": "Unable to create the Template.",
        "reference": ""
    }
}
  1. Sample validation error when body and sample_body don't have the same content in the WhatsApp templates with sample media:
{
    "error": {
        "code": "E996",
        "type": "VALIDATION_ERROR",
        "parameter": "message",
        "message": "The body and sample_body don't have the same content. Please verify and try again.",
        "reference": ""
    }
}
  1. Sample validation error when template name already exists in the WhatsApp templates with sample media:
{
    "error": {
        "code": "E996",
        "type": "VALIDATION_ERROR",
        "parameter": "name",
        "message": "Template name already taken!",
        "reference": ""
    }
}




© 2025 Kaleyra Inc. All rights reserved.
Trademarks, logos and service marks displayed on this site are registered and unregistered trademarks of Kaleyra Inc.