---
title: "Send SMS using a template"
method: POST
path: "/v2/{sid}/messages"
tags: ["Single SMS API"]
---

# Send SMS using a template

`POST /v2/{sid}/messages`

## Request

- Base URL: `api.in.kaleyra.io` (relative, and the document’s source URL is not known)
- URL: `api.in.kaleyra.io/v2/{sid}/messages`
- Auth: none declared. Required headers: `api-key`, `Content-Type`

SMS is a simple and cost-effective way to communicate with customers. Before starting to send the SMS APIs, make sure that you have configured the SMS channel in Kalyra.io. This section details how to send your first outbound SMS using an API request.

To send marketing messages use "type" value as "MKT".  
To send transactional messages use "type" value as "TXN".  
To send otp messages use "type" value as "OTP".

## Path parameters

- `sid` string, required

## Headers

- `api-key` string, required
- `Content-Type` string, required

## Request body `application/x-www-form-urlencoded`

- object
  - `to` string, required: It contains a phone number, Numbers Separated by “,“ comma OR It can have a list of numbers in an Array. For example - 9188XXXXXXXX.
  - `sender` string, required: Sender ID used for sending SMS. The sender must be in the form of a tag when used in template-based sending. For example - "KLRHXA"
  - `body` string: [Conditional] Body of the SMS. It is required if template_id is not provided.
  - `template_id` string: [Conditional] Template ID for pre-registered templates. Required if the body is not provided. `template_id` must be 12 to 30 digits and exist as a tag.
  - `type` string: Type of the SMS (for example, transactional). `type` must exist as a tag if using template-based sending.
  - `callback_profile_id` string: URL for callbacks. Callback must exist as a tag if using template-based sending.
  - `template_data` string: Data to replace template placeholders. `template_data` must be a `key-value` pair JSON structure with each value under 30 characters.
  - `campaign_name` string: Name of the campaign. Must match regex pattern ^[\w-]*$.
  - `ref` string: Custom reference fields for the message, up to 150 characters each.
  - `ref1` string: Custom reference fields for the message, up to 150 characters each.
  - `ref2` string: Custom reference fields for the message, up to 150 characters each.

## Response `200`

Successful response

---

[API](https://skmtc.dev/kaleyra/apis/kaleyra-io-sms-apis.md) - [All operations](https://skmtc.dev/kaleyra/apis/kaleyra-io-sms-apis/llms.txt) - [OpenAPI document](https://skmtc.dev/kaleyra/apis/kaleyra-io-sms-apis/revisions/b7c9b536aa4d?raw)
