Send a Text Template Message through WhatsApp

POST and GET Method

This API allows you to create and send WhatsApp Message Templates.
Template messages are predefined messages that are used for standard communication and are designed to be reusable.

To send a Text Template Message through WhatsApp, perform the following steps:

  1. Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
  2. Pre-requisites

The following are the pre-requisites for using Kaleyra WhatsApp API’s:

  • A WhatsApp business number.
  • An associated profile with the business number.
  • A WhatsApp verified and approved profile.

For more details, read what WhatsApp has to say about creating a business account.
Read Message Templates for any questions you may have about creating templates.

  1. Send a Text Template Message API request.

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 send a Text Template Message through WhatsApp

To send a Text Template Message through WhatsApp, use the /messages endpoint with the following request method:

Request Format - POST Method

The following is the request format to send a text template message through WhatsApp for POST method:

curl -X POST "https://<api_domain>/v1/<sid>/messages" \
     -H "api-key: <api_key>" \
     -d "from=<from_number>" \
     -d "to=<to_number>" \
     -d "type=<message_type>" \
     -d "channel=<channel_name>" \
     -d "template_name=<template_name>" \
     -d "params=<template_parameters>" \
     -d "lang_code=<language_code>" \
     -d "callback_url=<callback_url>"     

Sample Request Format -POST Method

The following is the sample request format to send a text template message through WhatsApp for POST Method:

curl -X POST "https://api.in.kaleyra.io/v1/HXXXXXXX071IN/messages" \
     -H "api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3" \
     -d "from=+91XXXXXXXXXX" \
     -d "to=+91XXXXXXXXXX" \
     -d "type=template" \
     -d "channel=whatsapp" \
     -d "template_name=booking_confirm" \
     -d "params=param1,param2,param3" \
     -d "lang_code=en" \
     -d "callback_url=https%3A%2F%2Ftrees.free.beeceptor.com"     

Request Format - GET Method

The following is the request format to send a text template message through WhatsApp for GET method:

curl -X GET "https://<api_domain>/v1/<sid>/messages?channel=<channel_name>&to=<to_number>&from=<from_number>&type=<message_type>&template_name=<template_name>&params=<template_parameters>&lang_code=<language_code>&callback_url=<callback_url>" \
--header "api-key: <api-key>"

Sample Request Format

The following is the sample request format to send a text template message through WhatsApp for GET Method:

curl -X GET "https://api.in.kaleyra.io/v1/HXXXXXXX071IN/messages?channel=whatsapp&to=91XXXXXXXXXX&from=91XXXXXXXXXX&type=template&template_name=booking_confirm&params=test&lang_code=en&callback_url=https%3A%2F%2Ftrees.free.beeceptor.com" \
--header "api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3"

Parameter and Data Types

The following is the list of parameters and data types supported for sending a Text Template Message:

Parameter

Data Type

Description

Examples

Mandatory?

sid

String

Account SID (Security Identifier). Generated by Kaleyra.io while creating an API key.

HXXXXXXX071IN

Yes

api_key

String

Your API Key generated by Kaleyra.io.

Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3

Yes

content_type

String

Indicates the format of the content the API will be processing.

application/json

Yes

from_number

String

The number registered with WhatsApp business from which the message is to be sent. Ensure that the country code is prefixed to the number. (E164 format).

+91XXXXXXXXXX

Yes

to_number

String

A valid WhatsApp number of the recipient. Ensure that the country code is prefixed to the number. (E164 format).

Note: You can add multiple recipients, separate each number using the comma (,) delimiter.

+91XXXXXXXXXX

Yes

message_type

String

The type of message to be sent.

template

Yes

channel_name

String

The channel on which message must be sent.

whatsapp

Yes

template_name

String or Integer

Name of the WhatsApp template that was created in the Kaleyra.io portal. This name must be approved by WhatsApp before you start using this API.

booking_confirm

Yes

template_parameters

String

The values that you will pass when you want to send a message using the template. Since the values are dynamic, it must be passed through the <params> key. Multiple parameters are allowed that must be separated with a comma.

For a template that says: Hi <name> your booking id is <id number> for date <date> the params to be passed would be <name>, <id\_number>, <date>.

"<param1>", "<param2>", "<param3>"

Yes

language_code

String

The language code of the language that the template will allow.

'en' is the code for English.
For a comprehensive list of supported languages, read this

en

Yes

callback_url

String

The URL that Kaleyra.io should send information to when your number receives a response. This URL can be accessed publicly.
Click here for an example.

https%3A%2F%2Ftrees.free.beeceptor.com

No

Sample Success Response

The following success message appears with the status 200 Accepted:

{
    "id": "1b4XXXX8-61bf-4XX3-9aXX-f130XXXX80a5",
    "type": "template", 
    "body":  null,
    "createdDateTime": "2020-01-29 05:30:39+00:00", 
    "totalCount": 1, 
    "data": [
        {
            "message_id": "1b4XXXX0-61bf-46d3-9a1d-f130XXXXf0a5:0",
            "recipient": "1202XXXXXXX" 
        }
    ],
    "error": {}
  
}

Error Codes

The below table provides information about the error codes you would receive when executing the WhatsApp Template Message API.

Error CodeParameterDescription
E13008from_invalidInvalid or in-correct input of the From number.
E13009to_invalidInvalid or in-correct input of the TO number.
E13004template_paramsThe Template params are not matching.
E13005template_name_missmatchInvalid template.




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