curl --request PUT \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/sms \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"external_template_id": "d05a44f0-a7cf-471a-bcb6-63054800a367",
"update_campaigns": false,
"basic_details": {
"message": "Hi {{UserAttribute['first_name']}}, your order has been delivered!"
},
"meta_info": {
"template_name": "Shipping Update Template V2",
"updated_by": "jane.doe@example.com",
"template_version": "2"
}
}
EOFimport requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms"
payload = {
"external_template_id": "d05a44f0-a7cf-471a-bcb6-63054800a367",
"update_campaigns": False,
"basic_details": { "message": "Hi {{UserAttribute['first_name']}}, your order has been delivered!" },
"meta_info": {
"template_name": "Shipping Update Template V2",
"updated_by": "jane.doe@example.com",
"template_version": "2"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
external_template_id: 'd05a44f0-a7cf-471a-bcb6-63054800a367',
update_campaigns: false,
basic_details: {
message: 'Hi {{UserAttribute[\'first_name\']}}, your order has been delivered!'
},
meta_info: {
template_name: 'Shipping Update Template V2',
updated_by: 'jane.doe@example.com',
template_version: '2'
}
})
};
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 => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'external_template_id' => 'd05a44f0-a7cf-471a-bcb6-63054800a367',
'update_campaigns' => false,
'basic_details' => [
'message' => 'Hi {{UserAttribute[\'first_name\']}}, your order has been delivered!'
],
'meta_info' => [
'template_name' => 'Shipping Update Template V2',
'updated_by' => 'jane.doe@example.com',
'template_version' => '2'
]
]),
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 \"external_template_id\": \"d05a44f0-a7cf-471a-bcb6-63054800a367\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"message\": \"Hi {{UserAttribute['first_name']}}, your order has been delivered!\"\n },\n \"meta_info\": {\n \"template_name\": \"Shipping Update Template V2\",\n \"updated_by\": \"jane.doe@example.com\",\n \"template_version\": \"2\"\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api-0{dc}.moengage.com/v1.0/custom-templates/sms")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"external_template_id\": \"d05a44f0-a7cf-471a-bcb6-63054800a367\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"message\": \"Hi {{UserAttribute['first_name']}}, your order has been delivered!\"\n },\n \"meta_info\": {\n \"template_name\": \"Shipping Update Template V2\",\n \"updated_by\": \"jane.doe@example.com\",\n \"template_version\": \"2\"\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::Put.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"external_template_id\": \"d05a44f0-a7cf-471a-bcb6-63054800a367\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"message\": \"Hi {{UserAttribute['first_name']}}, your order has been delivered!\"\n },\n \"meta_info\": {\n \"template_name\": \"Shipping Update Template V2\",\n \"updated_by\": \"jane.doe@example.com\",\n \"template_version\": \"2\"\n }\n}"
response = http.request(request)
puts response.read_body{
"external_template_id": "eca024b7-a8ea-4f31-9154-5b80c85d18a9"
}{
"error": {
"code": "400 Bad Request",
"message": "Invalid template id",
"details": [
{
"code": "MissingValue",
"target": "9925c8",
"message": "9925c8 is invalid template id."
}
],
"request_id": "BTkUaYgU"
}
}{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}Update SMS Template
This API updates an SMS template by specifying its external template ID. You can specify in the request whether the updated version of the template can be used in active campaigns.
curl --request PUT \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/sms \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"external_template_id": "d05a44f0-a7cf-471a-bcb6-63054800a367",
"update_campaigns": false,
"basic_details": {
"message": "Hi {{UserAttribute['first_name']}}, your order has been delivered!"
},
"meta_info": {
"template_name": "Shipping Update Template V2",
"updated_by": "jane.doe@example.com",
"template_version": "2"
}
}
EOFimport requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/sms"
payload = {
"external_template_id": "d05a44f0-a7cf-471a-bcb6-63054800a367",
"update_campaigns": False,
"basic_details": { "message": "Hi {{UserAttribute['first_name']}}, your order has been delivered!" },
"meta_info": {
"template_name": "Shipping Update Template V2",
"updated_by": "jane.doe@example.com",
"template_version": "2"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
external_template_id: 'd05a44f0-a7cf-471a-bcb6-63054800a367',
update_campaigns: false,
basic_details: {
message: 'Hi {{UserAttribute[\'first_name\']}}, your order has been delivered!'
},
meta_info: {
template_name: 'Shipping Update Template V2',
updated_by: 'jane.doe@example.com',
template_version: '2'
}
})
};
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 => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'external_template_id' => 'd05a44f0-a7cf-471a-bcb6-63054800a367',
'update_campaigns' => false,
'basic_details' => [
'message' => 'Hi {{UserAttribute[\'first_name\']}}, your order has been delivered!'
],
'meta_info' => [
'template_name' => 'Shipping Update Template V2',
'updated_by' => 'jane.doe@example.com',
'template_version' => '2'
]
]),
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 \"external_template_id\": \"d05a44f0-a7cf-471a-bcb6-63054800a367\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"message\": \"Hi {{UserAttribute['first_name']}}, your order has been delivered!\"\n },\n \"meta_info\": {\n \"template_name\": \"Shipping Update Template V2\",\n \"updated_by\": \"jane.doe@example.com\",\n \"template_version\": \"2\"\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api-0{dc}.moengage.com/v1.0/custom-templates/sms")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"external_template_id\": \"d05a44f0-a7cf-471a-bcb6-63054800a367\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"message\": \"Hi {{UserAttribute['first_name']}}, your order has been delivered!\"\n },\n \"meta_info\": {\n \"template_name\": \"Shipping Update Template V2\",\n \"updated_by\": \"jane.doe@example.com\",\n \"template_version\": \"2\"\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::Put.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"external_template_id\": \"d05a44f0-a7cf-471a-bcb6-63054800a367\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"message\": \"Hi {{UserAttribute['first_name']}}, your order has been delivered!\"\n },\n \"meta_info\": {\n \"template_name\": \"Shipping Update Template V2\",\n \"updated_by\": \"jane.doe@example.com\",\n \"template_version\": \"2\"\n }\n}"
response = http.request(request)
puts response.read_body{
"external_template_id": "eca024b7-a8ea-4f31-9154-5b80c85d18a9"
}{
"error": {
"code": "400 Bad Request",
"message": "Invalid template id",
"details": [
{
"code": "MissingValue",
"target": "9925c8",
"message": "9925c8 is invalid template id."
}
],
"request_id": "BTkUaYgU"
}
}{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}Rate Limit
The rate limit is 100 RPM.Authorizations
Basic Authentication using Workspace ID as username and the 'Campaign report/Business events/Custom templates' API key as the password.
Body
The updated details for the SMS template.
This field contains the unique identifier that is generated by MoEngage during the template creation.
This field contains the basic details of the SMS template.
Show child attributes
Show child attributes
This field contains information about the template being created.
Show child attributes
Show child attributes
If true, this field contains a flag used to update all active campaigns currently using the template being updated to the newer version (being updated in this request).
Response
Template updated successfully.
The unique ID of the updated template.
Was this page helpful?