Send Template Message with Dynamic Variables

POST Method

The Send Template Message with Dynamic Variables uses template containing variable parts; each variable is a placeholder within the template that gets replaced with actual data for each recipient when the message is sent, allowing the same template to send personalized message to each given recipient.

📘

Note:
This feature is applicable only to customer onboarded in the India region.

Prerequisites

  • 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.
  • Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
  • To send any RCS messages, you must configure the RCS channel in the Kaleyra platform. To configure the RCS channel in your account, please contact your local Kaleyra representative.
  • You must have an approved AgentID or a specific number to be used as AgentID.
  • Templates must be approved in Kaleyra platform and in RCS ecosystem.

Base URL

https://rcs-api.<pod>.kaleyra.io/v1/<sid>

API Domain and Value

api_domainValue
IN podhttps://rcs-api.in.kaleyra.io

API request to Send Dynamic Template Message

To send Dynamic template message, use the https://rcs-api.<pod>.kaleyra.io/v1/<sid>/rcs/messages endpoint with the following request method:

Request Format

The following is the request format to send templates with dynamic variables using messageParams:

curl --location --request POST 'https://<api_domain>/v1/<sid>/rcs/messages' \
--header 'Content-Type: application/json' \
--header 'api-key: <api-key>' \
--data-raw '{
  "from": "<from>",
  "to": ["<to>"],
  "templateId": "<template_id>",
  "ttlSeconds": <ttlSeconds>,
  "messageParams": [
    {
      "<first_variable_name>": "<first_variable_value>",
      "<second_variable_name>": "<second_variable_value>",
      "<last_variable_name>": "<last_variable_value>"
    }
  ]
}'

Sample Request Format

The following is the sample request format to send templates with Dynamic variables using messageParams:

curl --location --request POST 'https://rcs-api.in.kaleyra.io/v1/XXXXX6913850XXXX/rcs/messages'
--header 'Content-Type: application/json' \ 
--header 'api-key: XXXXX3b8497f58a94e84b671aca43XXXX' \ 
--data  { 
  "from": "rcs-vi-IN-Trans",
  "to": ["91XXXXXXXXXX", "91XXXXXXXXXX"],
  "templateId": "template-dynamic-1234",
  "ttlSeconds": "30",
  "messageParams": [
    {
      "firstName": "John",
      "dueAmount": "500",
      "dueDate": "2026-04-20"
    },
    {
      "firstName": "Jane",
      "dueAmount": "750",
      "dueDate": "2026-04-22"
    }
  ]
}'

URL Parameters and Headers

The following is the list of parameters and headers to send the outgoing message request:

Parameter/HeadersData TypeDescriptionExampleMandatory?
sidStringAccount SID (Security Identifier).XXXXX6913850XXXXYes
Content-TypeStringIndicates the format of the content the API will be processing.The only allowed value is application/JSONYes
api-keyStringAPI key generated from kaleyra.io account.XXXXX3b8497f58a94e84b671aca43XXXXYes

The following is the list of attributes to be used in the payload to send Dynamic template message:

ParameterData TypeDescriptionExampleMandatory?
fromStringThe service code unique to the RCS agent, specified when the RCS agent is created or onboarded. You can contact the RCS Provisioning Team for more details on unique service code.rcs-vi-IN-TransYes
toArray of StringList of recipients’ device addresses (up to 100 allowed), a phone number in E.164 format prefixed with the country code without a plus sign used to contact the user.["91XXXXXXXXXX", "91XXXXXXXXXX"]Yes
templateidStringDefines the template ID which is automatically created after sending template creation API.template-dynamic-1234Yes
ttlSecondsStringSpecifies the Time‑to‑Live (TTL) for the RCS message, in seconds. If the platform is unable to deliver the message within this duration, it will automatically expire and be revoked, no further delivery will be attempted after TTL is expired.30No
messageparamsArray of ObjectsKey-value pairs for template variables.See the specific table for details.Yes (for dynamic templates)
📘

Note:

Each object within the messageParams array contains a list of "<name>": "<value>" pairs, one for each variable in the template that needs to be replaced.

Please be aware that:

  • Variables are replaced based on a match between the variable names in the template body and the names provided in the JSON request as the "<name>" attributes.
  • Elements in the messageParams array must be in the same order as the recipient numbers in the to array. The first element personalizes the message for the first recipient, the second element for the second recipient, and so on.
  • Any mismatch in one or both of the above may disrupt message personalization.

Following the request sample above, the following attributes are used in the payload (messageParams) to send a dynamic template message:

ParameterData TypeDescriptionExampleMandatory?
firstnameStringRecipient's first name used in the template.JohnYes
dueamountString / NumberAmount due to be paid.500Yes
duedateStringDue date for the payment.2026-04-20Yes
📘

Note:

You can pass additional parameters in messageparams based on your requirement, provided they are defined in the approved template.

Sample Success Response

The following is the sample success response:

{
    "code": "1200",
    "message": "Message Sent Successfully to provider",
    "data": {
        "to": ["91XXXXXXXXXX","91XXXXXXXXXX"],
        "messageId": "0c213560-47d1-46c4-a71d-d6XXXXXXXXXX"
    },
    "error": {}
}

Sample Failure Response

The following is the sample failure responses:

{
"type":"ERROR",
"eventId":"5d951fc9-9d96-4971-96f0-aaXXXXXXXX3e",
"from":"91XXXXXXXXXX",
"to":"rcs-vi-IN-Trans",
"sentAt":"2026-02-19T12:36:28.421Z",
"messageId":"cb774c44-2205-4bf0-a754-b9a1XXXXXXX9",
"error":
{
"code":"CARRIER_ERROR",
"reason":"400-B-- Template not approved",
}
} 
{
"type":"ERROR",
"eventId":"bb81b327-e08e-4e39-8b0d-6XXXXXXXXXX0",
"from":"91XXXXXXXXXX",
"to":"rcs-vi-IN-Trans",
"sentAt":"2026-02-20T10:18:02.281Z",
"messageId":"ccec5381-b6bd-4faf-8bfc-09XXXXXXXXXX",
"error":
{
"code":"CARRIER_ERROR",
"reason":"400-C-- Template limit exceeded",
}
}





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