curl --request PUT \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/osm \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"external_template_id": "81e1a740-3e57-4c70-8ec7-ffc84d576498",
"update_campaigns": false,
"basic_details": {
"payload": "<html><body><h1>Updated HTML Content</h1></body></html>"
},
"meta_info": {
"template_name": "AD template updated API 1",
"template_id": "133434477456",
"template_version": "2",
"updated_by": "testuser@moengage.com"
}
}
'import requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/osm"
payload = {
"external_template_id": "81e1a740-3e57-4c70-8ec7-ffc84d576498",
"update_campaigns": False,
"basic_details": { "payload": "<html><body><h1>Updated HTML Content</h1></body></html>" },
"meta_info": {
"template_name": "AD template updated API 1",
"template_id": "133434477456",
"template_version": "2",
"updated_by": "testuser@moengage.com"
}
}
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: '81e1a740-3e57-4c70-8ec7-ffc84d576498',
update_campaigns: false,
basic_details: {payload: '<html><body><h1>Updated HTML Content</h1></body></html>'},
meta_info: {
template_name: 'AD template updated API 1',
template_id: '133434477456',
template_version: '2',
updated_by: 'testuser@moengage.com'
}
})
};
fetch('https://api-0{dc}.moengage.com/v1.0/custom-templates/osm', 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/osm",
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' => '81e1a740-3e57-4c70-8ec7-ffc84d576498',
'update_campaigns' => false,
'basic_details' => [
'payload' => '<html><body><h1>Updated HTML Content</h1></body></html>'
],
'meta_info' => [
'template_name' => 'AD template updated API 1',
'template_id' => '133434477456',
'template_version' => '2',
'updated_by' => 'testuser@moengage.com'
]
]),
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/osm"
payload := strings.NewReader("{\n \"external_template_id\": \"81e1a740-3e57-4c70-8ec7-ffc84d576498\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Updated HTML Content</h1></body></html>\"\n },\n \"meta_info\": {\n \"template_name\": \"AD template updated API 1\",\n \"template_id\": \"133434477456\",\n \"template_version\": \"2\",\n \"updated_by\": \"testuser@moengage.com\"\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/osm")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"external_template_id\": \"81e1a740-3e57-4c70-8ec7-ffc84d576498\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Updated HTML Content</h1></body></html>\"\n },\n \"meta_info\": {\n \"template_name\": \"AD template updated API 1\",\n \"template_id\": \"133434477456\",\n \"template_version\": \"2\",\n \"updated_by\": \"testuser@moengage.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1.0/custom-templates/osm")
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\": \"81e1a740-3e57-4c70-8ec7-ffc84d576498\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Updated HTML Content</h1></body></html>\"\n },\n \"meta_info\": {\n \"template_name\": \"AD template updated API 1\",\n \"template_id\": \"133434477456\",\n \"template_version\": \"2\",\n \"updated_by\": \"testuser@moengage.com\"\n }\n}"
response = http.request(request)
puts response.read_body{
"external_template_id": "4a1afbc5-4c31-4f19-8c23-793e27af01aa"
}{
"error": {
"code": "400 Bad Request",
"message": "Validation failed because of invalid request data",
"details": [
{
"code": "MissingValue",
"target": "external_template_id",
"message": "external_template_id value is required but value is passed empty."
}
],
"request_id": "cTRlnJaG"
}
}{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}Update OSM Template
This API allows you to update an OSM template as per your requirements.
curl --request PUT \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/osm \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"external_template_id": "81e1a740-3e57-4c70-8ec7-ffc84d576498",
"update_campaigns": false,
"basic_details": {
"payload": "<html><body><h1>Updated HTML Content</h1></body></html>"
},
"meta_info": {
"template_name": "AD template updated API 1",
"template_id": "133434477456",
"template_version": "2",
"updated_by": "testuser@moengage.com"
}
}
'import requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/osm"
payload = {
"external_template_id": "81e1a740-3e57-4c70-8ec7-ffc84d576498",
"update_campaigns": False,
"basic_details": { "payload": "<html><body><h1>Updated HTML Content</h1></body></html>" },
"meta_info": {
"template_name": "AD template updated API 1",
"template_id": "133434477456",
"template_version": "2",
"updated_by": "testuser@moengage.com"
}
}
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: '81e1a740-3e57-4c70-8ec7-ffc84d576498',
update_campaigns: false,
basic_details: {payload: '<html><body><h1>Updated HTML Content</h1></body></html>'},
meta_info: {
template_name: 'AD template updated API 1',
template_id: '133434477456',
template_version: '2',
updated_by: 'testuser@moengage.com'
}
})
};
fetch('https://api-0{dc}.moengage.com/v1.0/custom-templates/osm', 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/osm",
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' => '81e1a740-3e57-4c70-8ec7-ffc84d576498',
'update_campaigns' => false,
'basic_details' => [
'payload' => '<html><body><h1>Updated HTML Content</h1></body></html>'
],
'meta_info' => [
'template_name' => 'AD template updated API 1',
'template_id' => '133434477456',
'template_version' => '2',
'updated_by' => 'testuser@moengage.com'
]
]),
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/osm"
payload := strings.NewReader("{\n \"external_template_id\": \"81e1a740-3e57-4c70-8ec7-ffc84d576498\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Updated HTML Content</h1></body></html>\"\n },\n \"meta_info\": {\n \"template_name\": \"AD template updated API 1\",\n \"template_id\": \"133434477456\",\n \"template_version\": \"2\",\n \"updated_by\": \"testuser@moengage.com\"\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/osm")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"external_template_id\": \"81e1a740-3e57-4c70-8ec7-ffc84d576498\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Updated HTML Content</h1></body></html>\"\n },\n \"meta_info\": {\n \"template_name\": \"AD template updated API 1\",\n \"template_id\": \"133434477456\",\n \"template_version\": \"2\",\n \"updated_by\": \"testuser@moengage.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1.0/custom-templates/osm")
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\": \"81e1a740-3e57-4c70-8ec7-ffc84d576498\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Updated HTML Content</h1></body></html>\"\n },\n \"meta_info\": {\n \"template_name\": \"AD template updated API 1\",\n \"template_id\": \"133434477456\",\n \"template_version\": \"2\",\n \"updated_by\": \"testuser@moengage.com\"\n }\n}"
response = http.request(request)
puts response.read_body{
"external_template_id": "4a1afbc5-4c31-4f19-8c23-793e27af01aa"
}{
"error": {
"code": "400 Bad Request",
"message": "Validation failed because of invalid request data",
"details": [
{
"code": "MissingValue",
"target": "external_template_id",
"message": "external_template_id value is required but value is passed empty."
}
],
"request_id": "cTRlnJaG"
}
}{
"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
The API request is authenticated through Basic Authentication. This sends a Base64-encoded string containing your username and password with every API request.
It encodes a username:password string in Base64 and appends the encoded string with Basic . This string is included in the authorization header:
{"Authorization: "Basic Base64_ENCODED_WORKSPACEID_APIKEY=="}
Follow these steps to obtain the username and password from the MoEngage Dashboard:
- Navigate to Settings > Account > APIs.
- Copy the following details:
- Username: Under Workspace ID (earlier App ID), click the copy icon.
- Password: In the API keys section, click the copy icon in the Campaign report/Business events/Custom templates/Catalog API tile.
Body
The updated details for the OSM template.
The unique identifier generated by MoEngage during template creation.
Details about the template payload.
Show child attributes
Show child attributes
Updates template information such as name, version, and updater details.
Show child attributes
Show child attributes
Flag to update all campaigns currently using this template to the newer version.
true: All campaigns running with this template will be updated.false: A new version of the template is created; existing campaigns remain unchanged.
Response
Template updated successfully.
The unique ID of the updated template.
Was this page helpful?