curl --request PUT \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"external_template_id": "4a1afbc5-4c31-4f19-8c23-793e27af01aa",
"update_campaigns": false,
"basic_details": {
"payload": "<html><body><h1>Hello Updated World!</h1></body></html>",
"inapp_template_type": "INAPP_HTML"
},
"meta_info": {
"template_name": "My Updated HTML Promo",
"updated_by": "jane.doe@example.com"
}
}
'import requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp"
payload = {
"external_template_id": "4a1afbc5-4c31-4f19-8c23-793e27af01aa",
"update_campaigns": False,
"basic_details": {
"payload": "<html><body><h1>Hello Updated World!</h1></body></html>",
"inapp_template_type": "INAPP_HTML"
},
"meta_info": {
"template_name": "My Updated HTML Promo",
"updated_by": "jane.doe@example.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: '4a1afbc5-4c31-4f19-8c23-793e27af01aa',
update_campaigns: false,
basic_details: {
payload: '<html><body><h1>Hello Updated World!</h1></body></html>',
inapp_template_type: 'INAPP_HTML'
},
meta_info: {template_name: 'My Updated HTML Promo', updated_by: 'jane.doe@example.com'}
})
};
fetch('https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp', 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/inapp",
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' => '4a1afbc5-4c31-4f19-8c23-793e27af01aa',
'update_campaigns' => false,
'basic_details' => [
'payload' => '<html><body><h1>Hello Updated World!</h1></body></html>',
'inapp_template_type' => 'INAPP_HTML'
],
'meta_info' => [
'template_name' => 'My Updated HTML Promo',
'updated_by' => 'jane.doe@example.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/inapp"
payload := strings.NewReader("{\n \"external_template_id\": \"4a1afbc5-4c31-4f19-8c23-793e27af01aa\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Hello Updated World!</h1></body></html>\",\n \"inapp_template_type\": \"INAPP_HTML\"\n },\n \"meta_info\": {\n \"template_name\": \"My Updated HTML Promo\",\n \"updated_by\": \"jane.doe@example.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/inapp")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"external_template_id\": \"4a1afbc5-4c31-4f19-8c23-793e27af01aa\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Hello Updated World!</h1></body></html>\",\n \"inapp_template_type\": \"INAPP_HTML\"\n },\n \"meta_info\": {\n \"template_name\": \"My Updated HTML Promo\",\n \"updated_by\": \"jane.doe@example.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp")
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\": \"4a1afbc5-4c31-4f19-8c23-793e27af01aa\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Hello Updated World!</h1></body></html>\",\n \"inapp_template_type\": \"INAPP_HTML\"\n },\n \"meta_info\": {\n \"template_name\": \"My Updated HTML Promo\",\n \"updated_by\": \"jane.doe@example.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": "updated_by",
"message": "updated_by attribute is missing in meta_info."
}
],
"request_id": "cjUaLVrE"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
],
"request_id": "<string>"
}
}Update In-app Template
This API allows you to update an In-app template as per your requirements.
curl --request PUT \
--url https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"external_template_id": "4a1afbc5-4c31-4f19-8c23-793e27af01aa",
"update_campaigns": false,
"basic_details": {
"payload": "<html><body><h1>Hello Updated World!</h1></body></html>",
"inapp_template_type": "INAPP_HTML"
},
"meta_info": {
"template_name": "My Updated HTML Promo",
"updated_by": "jane.doe@example.com"
}
}
'import requests
url = "https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp"
payload = {
"external_template_id": "4a1afbc5-4c31-4f19-8c23-793e27af01aa",
"update_campaigns": False,
"basic_details": {
"payload": "<html><body><h1>Hello Updated World!</h1></body></html>",
"inapp_template_type": "INAPP_HTML"
},
"meta_info": {
"template_name": "My Updated HTML Promo",
"updated_by": "jane.doe@example.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: '4a1afbc5-4c31-4f19-8c23-793e27af01aa',
update_campaigns: false,
basic_details: {
payload: '<html><body><h1>Hello Updated World!</h1></body></html>',
inapp_template_type: 'INAPP_HTML'
},
meta_info: {template_name: 'My Updated HTML Promo', updated_by: 'jane.doe@example.com'}
})
};
fetch('https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp', 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/inapp",
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' => '4a1afbc5-4c31-4f19-8c23-793e27af01aa',
'update_campaigns' => false,
'basic_details' => [
'payload' => '<html><body><h1>Hello Updated World!</h1></body></html>',
'inapp_template_type' => 'INAPP_HTML'
],
'meta_info' => [
'template_name' => 'My Updated HTML Promo',
'updated_by' => 'jane.doe@example.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/inapp"
payload := strings.NewReader("{\n \"external_template_id\": \"4a1afbc5-4c31-4f19-8c23-793e27af01aa\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Hello Updated World!</h1></body></html>\",\n \"inapp_template_type\": \"INAPP_HTML\"\n },\n \"meta_info\": {\n \"template_name\": \"My Updated HTML Promo\",\n \"updated_by\": \"jane.doe@example.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/inapp")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"external_template_id\": \"4a1afbc5-4c31-4f19-8c23-793e27af01aa\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Hello Updated World!</h1></body></html>\",\n \"inapp_template_type\": \"INAPP_HTML\"\n },\n \"meta_info\": {\n \"template_name\": \"My Updated HTML Promo\",\n \"updated_by\": \"jane.doe@example.com\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1.0/custom-templates/inapp")
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\": \"4a1afbc5-4c31-4f19-8c23-793e27af01aa\",\n \"update_campaigns\": false,\n \"basic_details\": {\n \"payload\": \"<html><body><h1>Hello Updated World!</h1></body></html>\",\n \"inapp_template_type\": \"INAPP_HTML\"\n },\n \"meta_info\": {\n \"template_name\": \"My Updated HTML Promo\",\n \"updated_by\": \"jane.doe@example.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": "updated_by",
"message": "updated_by attribute is missing in meta_info."
}
],
"request_id": "cjUaLVrE"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
],
"request_id": "<string>"
}
}Authorizations
The API request is authenticated through Basic Authentication. Follow the steps below 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 to copy the username.
- Password: In the API keys section, click the copy icon in the Campaign report/Business events/Custom templates/Catalog API tile to copy the API key.
Body
The updated details for the In-app template.
The external template ID needs to be updated. This field contains the unique identifier that is generated during the creation of the template.
Details about the template, including its payload and template type.
Show child attributes
Show child attributes
This field will update template information, such as the name of the template and the update's details.
Show child attributes
Show child attributes
This field contains a flag used to update all campaigns currently using the template to the newer version. When true, all running campaigns with this template will be updated. When false, no change will be made to the template used in existing campaigns.
Response
Template updated successfully.
This field contains the unique ID corresponding to a successful custom template update. This template ID is used as header input for updates, searches, or any kind of template modifications in a later stage.
"4a1afbc5-4c31-4f19-8c23-793e27af01aa"
Was this page helpful?