GetOTP Documentation
Create Template
The Create Template API provides a way to create your custom Templates.
Request for Create Template API
To create a Template, make a POST request to our Template endpoint.
https://api.otp.dev/v1/templatesWith the following Basic HTTP verification method:
| Description | Required | Data Type | Example |
|---|---|---|---|
| Your API Key | Yes | String | mtbi2w4hlendfpxa1igthcu5p6mzxf7k |
Note
- Grab your API key from this page
With the following parameters:
| Name | Description | Required | Data Type | Example |
|---|---|---|---|---|
| channel | OTP channel for the template | Yes | String | SMS |
| name | Name of the template | No | String | My Template |
| text | Text of the template | Yes | String | Your code is {code} |
Examples
Below is an example request using cURL:
curl --request POST \
--url https://api.otp.dev/v1/templates \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"data": {
"channel": "SMS",
"name": "My Template",
"text": "Your code is {code}"
}
}
'The response would be a JSON structure, returned with HTTP 201 Codestatus code:
{
"data": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"account_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "My Template",
"text": "Your code is {code}",
"channel": "SMS",
"status": "COMPLETED",
"type": "text",
"create_date": "2025-10-15T06:01:14.478Z",
"update_date": "2025-10-15T06:01:14.478Z",
"links": {
"self": "string",
"account": "string"
}
}
}Response data details:
| Name | Description | Data Type | Example |
|---|---|---|---|
| data.id | The unique identifier of the template | String (UUID) | 3fa85f64-5717-4562-b3fc-2c963f66afa6 |
| data.account_id | The unique identifier of the account | String (UUID) | 3fa85f64-5717-4562-b3fc-2c963f66afa6 |
| data.name | The name of the template | String | My Template |
| data.text | The text of the template | String | https://example.com |
| data.channel | The channel of the template | String | 1234567890 |
| data.status | The status of the template | String | DELIVERY |
| data.type | The type of the template | String | My Webhook |
| data.create_date | Creation date of the template in UTC, formatted as yyyy-mm-dd hh:mm:ss | String (datetime) | 2025-09-24 07:09:20 |
| data.update_date | Updated date of the template in UTC, formatted as yyyy-mm-dd hh:mm:ss | String (datetime) | 2025-09-24 07:09:20 |
| data.links.self | URL of the template | String (URL) | string |
| data.links.account | URL of the account | String (URL) | string |
If there is an error with the API call, you will receive a JSON response with 400+ status code, error code and message.
{
"errors": [{
"timestamp": "2025-08-18 00:00:00",
"path": "/v1/templates",
"method": "POST",
"status": 400,
"message": "'data.text' is required",
"code": "1254"
}]
}Please refer to this table for details:
| Error Code | Description | HTTP Code |
|---|---|---|
| 1254 | 'data.text' is required | 400 |
| 1256 | 'data.channel' is required | 400 |
| 1257 | 'data.channel' value should be: [SMS, VIBER, WHATSAPP] | 400 |
| 1259 | 'data.name' is invalid | 400 |
| 1260 | 'data.text' is too long | 400 |
| 1263 | 'data.name' is too long | 400 |