---
updatedAt: 2026-09-17T14:25:00.000Z
agentTools:
  projectIndex: https://developers.kaleyra.io/llms.txt
---

# Send OTP SMS

POST Method

kaleyra.io provides an API that simplifies sending critical and high priority SMS containing a one-time password. Use this API to send OTP SMS to your customers.

## Prerequisites

* Before sending the SMS, you must configure the SMS channel in kaleyra.io.
* After you sign up, your account will be on the trial version. You must [complete the KYC](https://developers.kaleyra.io/docs/document-submission-and-approval) to access all the features in kaleyra.io.
* Before you get started, [Create an API Key](https://developers.kaleyra.io/docs/generating-an-api-key). To view the API Key and the SID, see[ View API Key and SID](https://developers.kaleyra.io/docs/view-api-key-and-sid).
* You must have an approved `SenderID` or a specific number to be used as `SenderID`.

## Base URL

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

## API Domain and Value

| api\_domain | Value             |
| :---------- | :---------------- |
| IN pod      | api.in.kaleyra.io |
| SG Pod      | api.ap.kaleyra.io |
| EU Pod      | api.eu.kaleyra.io |
| NA Pod      | api.na.kaleyra.io |

<br />

## API request to send OTP SMS

To send OTP SMS use the `<api_domain>/v1/<sid>/sms` endpoint with the following request method:

## Request Format

The following is the request format to send the OTP SMS for non-Indian companies:

```curl
curl -X POST "https://<api_domain>/v1/<sid>/sms" \
     -H "Content-Type:<content-type>" \
     -H "api-key:<api-key>" \
     -d "to=<to>" \
     -d "type=<type>" \
     -d "prefix=<prefix>" \
     -d "sender=<sender>" \
     -d "body=<body>" \
     -d "callback_profile_id=<callback_profile_id>"
```

The following is the request format to send the OTP SMS for customers from India:

```curl
curl -X POST "https://<api_domain>/v1/<sid>/sms" \
     -H "Content-Type:<content-type>" \
     -H "api-key:<api-key>" \
     -d "to=<to>" \
     -d "sender=<sender>" \
     -d "type=<type>" \
     -d "prefix=<prefix>" \
     -d "body=<body>" \
     -d "callback_profile_id=<callback_profile_id>" \
     -d "template_id=<template_id>"
```

## Sample Request Format

The following is the sample request format to send OTP SMS for non-Indian companies:

```curl
curl -X POST "https://api.in.kaleyra.io/v1/HXAP16XXXXXX97IN/sms" \
     -H "Content-Type:application/json" \
     -H "api-key:Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3" \
     -d "to=+91XXXXXXXXXX"\
     -d "sender=KLRHXA" \
     -d "type=OTP" \
     -d "prefix=+91" \
     -d "body=Dear Customer, 1234 is your OTP (One Time Password) for the transaction."\
     -d "callback_profile_id=IN_09b3dfa7-e05d-4d84-ab2d-6ed654272XXX"
```

The following is the sample request format to send OTP SMS for customers from India:

```curl
curl -X POST "https://api.in.kaleyra.io/v1/HXAP16XXXXXX97IN/sms" \
     -H "Content-Type:application/json" \
     -H "api-key:Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3" \
     -d "to=+91XXXXXXXXXX" \
     -d "sender=KLRHXA" \
     -d "type=OTP" \
     -d "prefix=+91" \
     -d "body=Dear Customer, 1234 is your OTP (One Time Password) for the transaction." \
     -d "callback_profile_id=IN_09b3dfa7-e05d-4d84-ab2d-6ed654272XXX" \
     -d "template_id=101XXXXXX012"
```

<Callout icon="📘" theme="info">
  ### Note:

  The `template_id` should be the one registered in the DLT system.
</Callout>

## URL Parameters and Headers

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

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th style={{ textAlign: "left" }}>
        Parameter / Headers
      </th>

      <th style={{ textAlign: "left" }}>
        Data Type
      </th>

      <th style={{ textAlign: "left" }}>
        Description
      </th>

      <th style={{ textAlign: "left" }}>
        Example
      </th>

      <th style={{ textAlign: "left" }}>
        Mandatory?
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td style={{ textAlign: "left" }}>
        `sid`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        Account SID (Security Identifier).
      </td>

      <td style={{ textAlign: "left" }}>
        `HXAP16XXXXXX97IN`
      </td>

      <td style={{ textAlign: "left" }}>
        Yes
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `api-key`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        API key generated from kaleyra.io account.
      </td>

      <td style={{ textAlign: "left" }}>
        `AXXXXXXXXXXXXXXXXXXXXXXXXX3`
      </td>

      <td style={{ textAlign: "left" }}>
        Yes
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `content-type`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        Indicates the format of the content the API will be processing.
      </td>

      <td style={{ textAlign: "left" }}>
        The only allowed value is application/json.
      </td>

      <td style={{ textAlign: "left" }}>
        Yes
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `to`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        Phone number of the end customer you want to send a message to.
      </td>

      <td style={{ textAlign: "left" }}>
        `+91XXXXXXXXXX`
      </td>

      <td style={{ textAlign: "left" }}>
        Yes  
        (valid phone numbers only)
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `sender`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        Alphanumeric Sender ID displayed on recipient devices.
      </td>

      <td style={{ textAlign: "left" }}>
        KLRHXA
      </td>

      <td style={{ textAlign: "left" }}>
        Yes
      </td>
    </tr>
  </tbody>
</Table>

Following is the list of attributes to be used in the payload to send the OTP SMS message:

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Parameter
      </th>

      <th>
        Data Type
      </th>

      <th>
        Description
      </th>

      <th>
        Example
      </th>

      <th>
        Mandatory?
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `type`
      </td>

      <td>
        String
      </td>

      <td>
        Route type.

        * _Note_\*: To send an OTP, the only allowed value is OTP.
      </td>

      <td>
        OTP
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `prefix`
      </td>

      <td>
        String
      </td>

      <td>
        Specifies the country code prefix.
        Note: If a mobile number already includes a country code, the Kaleyra platform will use that country code as provided. If the number does not include a country code, the Kaleyra platform will automatically prepend the default country code specified in the API request. For example, with a default country code of +91, numbers like +91800XXXXXX6 and +44 20 7XXXXXX12 will be sent as-is, while a number such as 966XXXXXX91 will be converted to +91966XXXXXX9 before sending.
      </td>

      <td>
        +91
      </td>

      <td>
        No
      </td>
    </tr>

    <tr>
      <td>
        `body`
      </td>

      <td>
        String
      </td>

      <td>
        Body of the SMS. It is required if `template_id` is not provided.
      </td>

      <td>
        "Dear Customer, 1234 is your OTP (One Time Password) for the transaction."
      </td>

      <td>
        Conditional
      </td>
    </tr>

    <tr>
      <td>
        `callback_profile_id`
      </td>

      <td>
        String
      </td>

      <td>
        The callback profile ID of the callback profile to be used to send webhook to your system about SMS status updates. For more information related to callback profiles, see [callback profiles](https://developers.kaleyra.io/docs/account-settings-callback-profiles)  page
      </td>

      <td>
        IN_09b3dfa7-e05d-4d84-ab2d-6ed654272XXX
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        `template_id`
      </td>

      <td>
        String
      </td>

      <td>
        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.
      </td>

      <td>
        101XXXXXX012
      </td>

      <td>
        Conditional
      </td>
    </tr>
  </tbody>
</Table>

<Callout icon="📘" theme="info">
  ### Note:

  For `template_id`, if the body parameter is passed together with a template ID and template data, then the Body will have priority, and the template ID and template data will have less priority.
</Callout>

## Success Response

The following success response is received when the JSON script has the correct syntax:

Success response for non-Indian companies.

```json
{
  "id": "ee8aXXXX-XXXX-XXXX-XXXX-9b717XXXX30d",
  "sender": "KLRHXA",
  "type": "OTP",
  "body": "Hello! Your OTP is 1234.",
  "createdDateTime": "2019-11-04 10:42:23+00:00",
  "totalCount": 1,
  "data": [
    {
      "message_id": "ee8aXXXX-XXXX-XXXX-XXXX-9b717XXXX30d:1",
      "recipient": "1XXXXXXXXXX"
    }
  ],
  "dlrurl": null,
  "error": {}
}
```

Success response for Indian customers.

```json JSON-Indian Customers
{
  "id": "ee8aXXXX-XXXX-XXXX-XXXX-9b717XXXX30d",
  "sender": "KLRHXA",
  "type": "OTP",
  "template_id": "2xxxxxxxxxxxx",
  "body": "Hello! Your OTP is 1234.",
  "createdDateTime": "2019-11-04 10:42:23+00:00",
  "totalCount": 1,
  "data": [
    {
      "message_id": "ee8aXXXX-XXXX-XXXX-XXXX-9b717XXXX30d:1",
      "recipient": "1XXXXXXXXXX"
    }
  ],
  "dlrurl": null,
  "error": {}
}
```

## Failure Response

The following failure response are received when the JSON script has an incorrect syntax:

* **Multiple Mobile Numbers**<br />Multiple **Mobile Numbers** are not allowed for the OTP type message. Check the To parameter for the multiple numbers.

```json
{
  "code": "E404",
  "message": "If Type is OTP then only one mobile number is allowed.",
  "error": {
    "time": "If Type is OTP then only one mobile number is allowed."
  }
}
```

## SMS Error Codes, SMS Status and Status Trace Codes

Refer to the following links for Error Codes, Status and Status Trace Codes:

* For information related to SMS error codes, see [SMS Error Codes](https://developers.kaleyra.io/docs/sms-error-codes).
* For information related to SMS status and status trace codes, see [SMS Status and Status Trace Codes](https://developers.kaleyra.io/docs/sms-status-and-status-trace-codes).