This API allows you to update an OSM template as per your requirements.
API Endpoint
PUT https://api-0X.moengage.com/v1.0/custom-templates/osm/
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 Base64_ENCODED_WORKSPACEID_APIKEY=="}
Follow the steps below to obtain the username and password details 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.
- Use the above details to authenticate the API requests.
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 Base64_ENCODED_WORKSPACEID_APIKEY=="} |
This authentication parameter, used for access control, must be passed in the request. To generate the authentication header, refer to Authentication. |
Request Body
Key | Data Type | Required | Description |
---|---|---|---|
external_template_id | String | Mandatory |
The external template ID needs to be updated. This field contains the unique identifier that is generated during the creation of the template. Example: 4a1afbc5-4c31-4f19-8c23-793e27af01aa |
update_campaigns | Boolean | Optional (default value: false) |
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. |
basic_details | JSON | Mandatory |
Details about the template, including its payload and template type.
|
meta_info | JSON | Mandatory |
This field will update template information, such as the name of the template and the update's details. Keys:
The version of the templates will be increased by 1 after every template update. Example: { |
Response
Status | Key | Data Type | Description |
---|---|---|---|
Success | external_template_id | String |
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. |
Failure | 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:
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>" }
For the sample error response, refer here. |
Response Codes
Status Code | Request State | Description |
---|---|---|
200 |
Success |
Template updated successfully. |
400 |
Bad Request |
This response is returned when the required parameters are missing from the request, when the provided parameters are invalid, or when a template already exists with the same version, name, or ID. |
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 --location --request PUT 'https://api-0X.moengage.com/v1.0/custom-templates/osm' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic Q000DZGPJk7ySU1KTkJZOLWMWELVNzNEOlIxWk1AS0FYUENCNg==' \
--data-raw '{
"external_template_id": "81e1a740-3e57-4c70-8ec7-ffc84d576498",
"basic_details": {
"payload": "<!DOCTYPE HTML><html><head><meta name='\''viewport'\'' content='\''width=device-width, initial-scale=1.0'\'' charset='\''UTF-8'\''><meta charset='\''utf-8'\''><link rel='\''stylesheet'\'' type='\''text/css'\'' href='\''https://fonts.googleapis.com/css?family=ABeeZee%7CAbel%7CAclonica%7CAcme%7CActor%7CAdvent+Pro%7CAlata%7CAlatsi%7CAldrich%7CAlef%7CAlegreya+Sans%7CAlegreya+Sans+SC%7CAllerta%7CAllerta+Stencil%7CAlmarai%7CAmaranth%7CAmiko%7CAnaheim%7CAndika%7CAndika+New+Basic%7CAntic%7CAnton%7CArchivo%7CArchivo+Black%7CArchivo+Narrow%7CArimo%7CArmata%7CArsenal%7CArya%7CAsap%7CAsap+Condensed%7CAssistant%7CAsul%7CAthiti%7CAverage+Sans%7CB612%7CBai+Jamjuree%7CBarlow%7CBarlow+Condensed%7CBarlow+Semi+Condensed%7CBasic%7CBe+Vietnam%7CBelleza%7CBenchNine%7CBiryani%7CBlack+And+White+Picture%7CBlack+Han+Sans%7CBlinker%7CBubbler+One%7CCabin%7CCabin+Condensed%7CCagliostro%7CCairo%7CCambay%7CCandal%7CCantarell%7CCantora+One%7CCapriola%7CCarme%7CCarrois+Gothic%7CCarrois+Gothic+SC%7CCatamaran%7CChakra+Petch%7CChanga%7CChathura%7CChau+Philomene+One%7CChivo%7CCoda+Caption%7CCommissioner%7CConvergence%7CCuprum%7CDM+Sans%7CDarker+Grotesque%7CDays+One%7CDenk+One%7CDhurjati%7CDidact+Gothic%7CDo+Hyeon%7CDoppio+One%7CDorsa%7CDosis%7CDuru+Sans%7CEconomica%7CEl+Messiri%7CElectrolize%7CEncode+Sans%7CEncode+Sans+Condensed%7CEncode+Sans+Expanded%7CEncode+Sans+Semi+Condensed%7CEncode+Sans+Semi+Expanded%7CEnglebert%7CEpilogue%7CExo%7CExo+2%7CFahkwang%7CFarro%7CFedero%7CFira+Sans%7CFira+Sans+Condensed%7CFira+Sans+Extra+Condensed%7CFjalla+One%7CFrancois+One%7CFresca%7CGFS+Neohellenic%7CGafata%7CGaldeano%7CGayathri%7CGeo%7CGidugu%7CGothic+A1%7CGotu%7CGudea%7CHammersmith+One%7CHarmattan%7CHeebo%7CHind%7CHind+Guntur%7CHind+Madurai%7CHind+Siliguri%7CHind+Vadodara%7CHomenaje%7CIBM+Plex+Sans%7CIBM+Plex+Sans+Condensed%7CImprima%7CInder%7CInria+Sans%7CInter%7CIstok+Web%7CJaldi%7CJockey+One%7CJosefin+Sans%7CJost%7CJua%7CJulius+Sans+One%7CJura%7CK2D%7CKanit%7CKantumruy%7CKarla%7CKhand%7CKhula%7CKite+One%7CKoHo%7CKodchasan%7CKosugi%7CKosugi+Maru%7CKrona+One%7CKrub%7CKulim+Park%7CKumbh+Sans%7CLato%7CLekton%7CLexend+Deca%7CLexend+Exa%7CLexend+Giga%7CLexend+Mega%7CLexend+Peta%7CLexend+Tera%7CLexend+Zetta%7CLibre+Franklin%7CLivvic%7CM+PLUS+1p%7CM+PLUS+Rounded+1c%7CMada%7CMagra%7CMako%7CMallanna%7CMandali%7CManjari%7CManrope%7CMarmelad%7CMartel+Sans%7CMarvel%7CMaven+Pro%7CMeera+Inimai%7CMerriweather+Sans%7CMetrophobic%7CMichroma%7CMina%7CMiriam+Libre%7CMitr%7CMolengo%7CMonda%7CMontserrat%7CMontserrat+Alternates%7CMontserrat+Subrayada%7CMouse+Memoirs%7CMukta%7CMukta+Mahee%7CMukta+Malar%7CMukta+Vaani%7CMulish%7CNTR%7CNanum+Gothic%7CNews+Cycle%7CNiramit%7CNobile%7CNotable%7CNoto+Sans%7CNoto+Sans+HK%7CNoto+Sans+JP%7CNoto+Sans+KR%7CNoto+Sans+SC%7CNoto+Sans+TC%7CNumans%7CNunito%7CNunito+Sans%7COpen+Sans%7COpen+Sans+Condensed%7COrbitron%7COrienta%7COswald%7COverpass%7COxygen%7CPT+Sans%7CPT+Sans+Caption%7CPT+Sans+Narrow%7CPadauk%7CPalanquin%7CPalanquin+Dark%7CPathway+Gothic+One%7CPattaya%7CPavanam%7CPaytone+One%7CPhilosopher%7CPlay%7CPontano+Sans%7CPoppins%7CPort+Lligat+Sans%7CPragati+Narrow%7CPrompt%7CProza+Libre%7CPublic+Sans%7CPuritan%7CQuantico%7CQuattrocento+Sans%7CQuestrial%7CQuicksand%7CRajdhani%7CRaleway%7CRamabhadra%7CRambla%7CRationale%7CRecursive%7CRed+Hat+Display%7CRed+Hat+Text%7CReem+Kufi%7CRoboto%7CRoboto+Condensed%7CRopa+Sans%7CRosario%7CRubik%7CRubik+Mono+One%7CRuda%7CRuluko%7CRum+Raisin%7CRusso+One%7CSaira%7CSaira+Condensed%7CSaira+Extra+Condensed%7CSaira+Semi+Condensed%7CSansita%7CSarabun%7CSarala%7CSarpanch%7CSawarabi+Gothic%7CSawarabi+Mincho%7CScada%7CSecular+One%7CSen%7CSeymour+One%7CShanti%7CShare+Tech%7CSignika%7CSignika+Negative%7CSintony%7CSix+Caps%7CSnippet%7CSora%7CSource+Sans+Pro%7CSpace+Grotesk%7CSpartan%7CSpinnaker%7CStrait%7CStylish%7CSulphur+Point%7CSunflower%7CSyncopate%7CSyne%7CTajawal%7CTauri%7CTeko%7CTelex%7CTenali+Ramakrishna%7CTenor+Sans%7CText+Me+One%7CThasadith%7CTimmana%7CTitillium+Web%7CTomorrow%7CTrispace%7CUbuntu%7CUbuntu+Condensed%7CVarela%7CVarela+Round%7CVarta%7CViga%7CVoltaire%7CWendy+One%7CWire+One%7CWork+Sans%7CYanone+Kaffeesatz%7CYantramanav'\''><style>.moe-container {display: inline-block;background: transparent;overflow:hidden;}.moe-image {width: 100%;}body {height: 100vh;width: 100vw;display: flex;flex: 1;justify-content: center;align-items: center;background: rgba(0, 0, 0, 0.3);}.close-icon {position: absolute;right: 15px;top: 10px;width: 32px;height: 32px;opacity: 1;z-index: 9999999;}.button-container {position: absolute;bottom: 30px;z-index: 999999;transform: translate(-50%);left: 50%;}.moe-button {background: #007bff;color: #ffff;padding: 10px;border-radius: 5px;cursor: pointer;}@media only screen and (max-width: 600px) {.frame {width: 80%;background: transparent;}}</style></head><body style='\''margin: 0'\''><div style='\''display: inline-block; position: relative;'\''><div data-id='\''CONTAINER'\''style='\''position: relative; display: inline-block;'\''class='\''moe-element moe-container'\''data-editor-type='\''MOE_EDITOR'\''><img data-id='\''IMAGE'\''class='\''moe-element moe-image'\''src='\''https://s3.amazonaws.com/moe-email-campaigns/onsite/web_new_arrival.jpg'\''/></div><div class='\''button-container no-bounds'\''><span data-id='\''BUTTON'\'' class='\''btn moe-button moe-element'\'' type='\''button'\''>Click Here</span></div><button data-id='\''CLOSE'\''type='\''button'\''class='\''close close-icon moe-inapp-close moe-element'\''aria-label='\''Close'\''id='\''close-icon'\''> x </button></div></body></html>"
},
"meta_info": {
"template_name": "AD tempalte updated API 1",
"template_id": "133434477456",
"template_version": "2",
"updated_by": "testuser@moengage.com"
}
}'
Sample Response
{
"external_template_id": "4a1afbc5-4c31-4f19-8c23-793e27af01aa"
}
Sample Response for Bad Request
{
"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"
}
}
Sample Response for Server Side Errors
{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}
Postman Collections
We have made it easy for you to test the APIs. Click here to view it in Postman.