Update Push Template API

This API can be used to update a push template by specifying its external template id. You can specify whether the updated version of the template can be used in active campaigns in the request.

API Endpoint

API Endpoint
PUT https://api-0X.moengage.com/v1.0/custom-templates/push

Each customer is hosted on a different data center; you can find your data center number (value of X) by checking the data center and API endpoint mapping page.

Authentication

The API request will be authenticated through Basic Authentication. Basic Authentication 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 as shown below:

{"Authorization":"Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}

The username and password details can be obtained from the MoEngage Dashboard. We've revamped the settings UI in the Dashboard. If you're using the API for the first time, follow these steps for the revamped and old UIs:

Revamped UI

  1. Navigate to Settings -> Account -> APIs.
  2. Click the Copy icon in the Campaign report/Business events/Custom templates tile in the API Keys section to copy the API Key.
  3. Use the App ID as the username and the Push API Key as the password to generate the authentication header.

Old UI

  1. Navigate to Settings -> APIs -> TRANSACTION PUSH/REPORT Settings.
  2. Click on the Click here to show APP Secret link to view the API SECRET.
  3. Use the APP ID as the username and the API SECRET as the password to generate the authentication header.

Request Headers

Key Required Sample Values Description

Content-Type

Required

{"Content-Type": "application/json"}

Set the Content-Type header to application/json.

Authorization

Required

{"Authorization": "Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="}

This authentication parameter, used for access control, must be passed along with the request. To generate the authentication header, refer to Authentication.

Request Body

Key Required Values Description
external_template_id Required String This field contains the unique identifier that is generated during the creation of the template.
update_campaigns Optional Boolean

This field contains a flag that is used to update all the campaigns that are currently using the template being updated to the newer version(that is being updated in this request). The default value for this flag is false.

When the update_campaigns flag is true, all the campaigns running with this template will get updated to the latest version of the template, and when it is false, the new version of the template will be created, but there will be no change made to the template used in the existing campaigns.

 
ANDROID Optional JSON Object

This field contains the updated definition of the template for the Android platform. 

Structure:

"ANDROID": {
     "basic_details": {

        <Template's basic details>

     },

     "buttons": [List of buttons],

     "advanced": {

        <Template's advanced options>

     },

     "template_backup": {

        <Template's backup options>

     }

}

For more information, refer to Template Details.

IOS Optional  JSON Object

This field contains the updated definition of the template for the IOS platform. 

Structure:

"IOS": {
     "basic_details": {

        <Template's basic details>

     },

     "buttons": [List of buttons],

     "advanced": {

        <Template's advanced options>

     },

     "template_backup": {

        <Template's backup options>

     }

}

For more information, refer to Template Details.

meta_info Mandatory JSON Object

This field contains information about the template being updated, such as the name, the template's platform, style, and the details of the user updating the template. For more information, refer to Meta Info Object.

Note: The ANDROID and the IOS keys differ in the payload structure, which is explained below.

Template Details

The ANDROID and IOS keys contain the following JSON objects that define the template for the respective platforms:

Note:

  • You will not be able to add or remove a platform while updating the template.
  • You have to pass the entire payload in the request when trying to update your campaigns.
    Even if you are updating the details for only one platform, say, for instance, ANDROID, you will have to pass the IOS payload too.

Meta Info

The meta_info JSON object contains the following information:

Key Required Values Description
platform Required List This field contains the list of platforms where the template can be used. Allowed values: ANDROID, IOS
template_style Required String This field contains the style of the template. Allowed values: BASIC, STYLIZED
updated_by Required String This field contains the email id of the person updating the template.
template_name Required String This field contains the name of the template.
template_version Optional String This field contains the version of the template.

Response

Key Data Type Description
external_template_id String This field contains the unique template id corresponding to a successful template updation request.
error JSON Object

This field contains the reason for the request's failure.

Structure:

 "error": {

    "code": "<error_code>", 

    "message": "<error_message>",

     "details": [],

    "request_id": "<unique identifier for the request>

}

The error object contains the following fields:

  • code - This field contains the error code that provides a brief explanation of the error and is a String. For example, 400 - Bad Request, 401- Authentication required, and so on. This field is present in the response only in the case of errors.
  • message - This field describes why the request has failed and is a String. For example, in the case of a duplicate request (400- Bad Request), the following message will be present: 'Duplicate - template_id and template_version'.
  • details - This is a List of the error details objects. Each object contains the following information:

           { 

             "code": "<Descriptive Error Code>",

             "target": "<Denotes the field causing the issue or a brief description of the error message in some cases >",

              "message": "<Descriptive Error Message>"

            }

  • request_id -  This field contains the unique id pertaining to the request.

For example, in the case of a 400 request where the request is trying to update a template using an invalid template-id, the following error object is returned.

{
"error": {
"code": "400 Bad Request",
"message": "Invalid template id",
"details": [
{
"code": "Missing Value",
"target": "<template_id>",
"message": "<template_id>is invalid template id" 
}
],
"request_id": "cLCcgLQj"
}

Response Codes

Status Code Request State Description

200

Success

This response is returned when the request is processed successfully. 

400

Bad Request

This response is returned when the required parameters are missing from the request or when the provided parameters are invalid.

5xx

Internal Server Error

This response is returned when the system runs into an unexpected error.

Rate Limit

The rate limit is 100 RPM.

Sample cURL Request

cURL
curl --location --request PUT 'https://api-0X.moengage.com/v1.0/custom-templates/push/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic e3tBUFBfSUR9fTp7e0FQSV9TRUNSRVR9fQ==' \
--data '{
    "external_template_id": "d05a44f0-a7cf-471a-bcb6-63054800a367",
    "update_campaigns": false,
  {
   "ANDROID": { 
    "basic_details": {
    "title": "Updated Basic Android Template",
    "message": "Updated Basic Android Template",
    "summary": "Updated Basic Android Template summary",
    "image_url": "",
    "default_click_action": "DEEPLINKING",
    "default_click_action_value": "https://www.google.com"
  },
  "buttons": [
    {
      "btn_name": "btn1",
      "click_action_type": "DEEPLINKING",
      "click_action_name": "btn1",
      "click_action_value": "https://www.google.com"
    }
  ],
  "advanced": {
    "coupon_code": "",
    "icon_type_in_notification": "url",
    "large_icon_url": "https://www.google.com",
    "auto_dismiss_notification": true,
    "dismissal_time_multiplier": "minutes",
    "dismissal_time_value": 5
  }
 },
  "meta_info": {
    "platform": [
        "ANDROID"
    ],
    "template_style": "BASIC",
    "updated_by": "John.doe@yourbrand.com",
    "template_name": "Basic Android Template 2",
    "template_version": "2.0"
  }
}'

Sample Response

200 400 5XX
Sample Response for a successful request
{
   "external_template_id": "eca024b7-a8ea-4f31-9154-5b80c85d18a9"
}

Postman Collections

We have made it easy for you to test the APIs. Click here to view it in Postman.

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?