Create SMS Template
curl --request POST \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/sms \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"basic_details": {
"message": "Hello {{UserAttribute['first_name']}}, your order is on its way!"
},
"meta_info": {
"created_by": "john.doe@example.com",
"template_id": "shipping_update_v1",
"template_name": "Shipping Update Template",
"template_version": "1"
}
}
EOFimport requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms"
payload = {
"basic_details": { "message": "Hello {{UserAttribute['first_name']}}, your order is on its way!" },
"meta_info": {
"created_by": "john.doe@example.com",
"template_id": "shipping_update_v1",
"template_name": "Shipping Update Template",
"template_version": "1"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
basic_details: {message: 'Hello {{UserAttribute[\'first_name\']}}, your order is on its way!'},
meta_info: {
created_by: 'john.doe@example.com',
template_id: 'shipping_update_v1',
template_name: 'Shipping Update Template',
template_version: '1'
}
})
};
fetch('https://api-0{dc}.moengage.com/v1.0/custom-templates/sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'basic_details' => [
'message' => 'Hello {{UserAttribute[\'first_name\']}}, your order is on its way!'
],
'meta_info' => [
'created_by' => 'john.doe@example.com',
'template_id' => 'shipping_update_v1',
'template_name' => 'Shipping Update Template',
'template_version' => '1'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms"
payload := strings.NewReader("{\n \"basic_details\": {\n \"message\": \"Hello {{UserAttribute['first_name']}}, your order is on its way!\"\n },\n \"meta_info\": {\n \"created_by\": \"john.doe@example.com\",\n \"template_id\": \"shipping_update_v1\",\n \"template_name\": \"Shipping Update Template\",\n \"template_version\": \"1\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-0{dc}.moengage.com/v1.0/custom-templates/sms")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"basic_details\": {\n \"message\": \"Hello {{UserAttribute['first_name']}}, your order is on its way!\"\n },\n \"meta_info\": {\n \"created_by\": \"john.doe@example.com\",\n \"template_id\": \"shipping_update_v1\",\n \"template_name\": \"Shipping Update Template\",\n \"template_version\": \"1\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1.0/custom-templates/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"basic_details\": {\n \"message\": \"Hello {{UserAttribute['first_name']}}, your order is on its way!\"\n },\n \"meta_info\": {\n \"created_by\": \"john.doe@example.com\",\n \"template_id\": \"shipping_update_v1\",\n \"template_name\": \"Shipping Update Template\",\n \"template_version\": \"1\"\n }\n}"
response = http.request(request)
puts response.read_body{
"external_template_id": "d05a44f0-a7cf-471a-bcb6-63054800a367"
}
Custom SMS Templates
Create SMS Template
This API creates an SMS template in MoEngage. It helps you upload templates created outside the MoEngage ecosystem to MoEngage and use them for campaign creation.
POST
/
custom-templates
/
sms
Create SMS Template
curl --request POST \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/sms \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"basic_details": {
"message": "Hello {{UserAttribute['first_name']}}, your order is on its way!"
},
"meta_info": {
"created_by": "john.doe@example.com",
"template_id": "shipping_update_v1",
"template_name": "Shipping Update Template",
"template_version": "1"
}
}
EOFimport requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms"
payload = {
"basic_details": { "message": "Hello {{UserAttribute['first_name']}}, your order is on its way!" },
"meta_info": {
"created_by": "john.doe@example.com",
"template_id": "shipping_update_v1",
"template_name": "Shipping Update Template",
"template_version": "1"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
basic_details: {message: 'Hello {{UserAttribute[\'first_name\']}}, your order is on its way!'},
meta_info: {
created_by: 'john.doe@example.com',
template_id: 'shipping_update_v1',
template_name: 'Shipping Update Template',
template_version: '1'
}
})
};
fetch('https://api-0{dc}.moengage.com/v1.0/custom-templates/sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'basic_details' => [
'message' => 'Hello {{UserAttribute[\'first_name\']}}, your order is on its way!'
],
'meta_info' => [
'created_by' => 'john.doe@example.com',
'template_id' => 'shipping_update_v1',
'template_name' => 'Shipping Update Template',
'template_version' => '1'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms"
payload := strings.NewReader("{\n \"basic_details\": {\n \"message\": \"Hello {{UserAttribute['first_name']}}, your order is on its way!\"\n },\n \"meta_info\": {\n \"created_by\": \"john.doe@example.com\",\n \"template_id\": \"shipping_update_v1\",\n \"template_name\": \"Shipping Update Template\",\n \"template_version\": \"1\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-0{dc}.moengage.com/v1.0/custom-templates/sms")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"basic_details\": {\n \"message\": \"Hello {{UserAttribute['first_name']}}, your order is on its way!\"\n },\n \"meta_info\": {\n \"created_by\": \"john.doe@example.com\",\n \"template_id\": \"shipping_update_v1\",\n \"template_name\": \"Shipping Update Template\",\n \"template_version\": \"1\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1.0/custom-templates/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"basic_details\": {\n \"message\": \"Hello {{UserAttribute['first_name']}}, your order is on its way!\"\n },\n \"meta_info\": {\n \"created_by\": \"john.doe@example.com\",\n \"template_id\": \"shipping_update_v1\",\n \"template_name\": \"Shipping Update Template\",\n \"template_version\": \"1\"\n }\n}"
response = http.request(request)
puts response.read_body{
"external_template_id": "d05a44f0-a7cf-471a-bcb6-63054800a367"
}
Rate Limit
The rate limit is 100 RPM. You can upload a maximum of 100 templates per channel.FAQs
Can I create multiple templates with the same name?
Can I create multiple templates with the same name?
Yes, you can create multiple templates with the same name, provided they have different versions.
Authorizations
Basic Authentication using Workspace ID as username and the 'Campaign report/Business events/Custom templates' API key as the password.
Body
application/json
The details of the SMS template to be created.
Response
Success. This response is returned when the template is created successfully.
This field contains the unique ID assigned to the newly created template by MoEngage.
Was this page helpful?
⌘I