curl --request PUT \
--url https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: <api-key>' \
--data '
{
"id": "634fdf4db9c206ba55b8223b",
"name": "Summer_Sale_Header_Updated",
"status": "ACTIVE",
"raw_content": "<h1>Massive Summer Sale!</h1>",
"content_type": "HTML",
"updated_by": "abc@gmail.com",
"content_block_used": []
}
'import requests
url = "https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks"
payload = {
"id": "634fdf4db9c206ba55b8223b",
"name": "Summer_Sale_Header_Updated",
"status": "ACTIVE",
"raw_content": "<h1>Massive Summer Sale!</h1>",
"content_type": "HTML",
"updated_by": "abc@gmail.com",
"content_block_used": []
}
headers = {
"MOE-APPKEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'MOE-APPKEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '634fdf4db9c206ba55b8223b',
name: 'Summer_Sale_Header_Updated',
status: 'ACTIVE',
raw_content: '<h1>Massive Summer Sale!</h1>',
content_type: 'HTML',
updated_by: 'abc@gmail.com',
content_block_used: []
})
};
fetch('https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks', 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/external/campaigns/content-blocks",
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([
'id' => '634fdf4db9c206ba55b8223b',
'name' => 'Summer_Sale_Header_Updated',
'status' => 'ACTIVE',
'raw_content' => '<h1>Massive Summer Sale!</h1>',
'content_type' => 'HTML',
'updated_by' => 'abc@gmail.com',
'content_block_used' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"MOE-APPKEY: <api-key>"
],
]);
$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/external/campaigns/content-blocks"
payload := strings.NewReader("{\n \"id\": \"634fdf4db9c206ba55b8223b\",\n \"name\": \"Summer_Sale_Header_Updated\",\n \"status\": \"ACTIVE\",\n \"raw_content\": \"<h1>Massive Summer Sale!</h1>\",\n \"content_type\": \"HTML\",\n \"updated_by\": \"abc@gmail.com\",\n \"content_block_used\": []\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("MOE-APPKEY", "<api-key>")
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/external/campaigns/content-blocks")
.header("MOE-APPKEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"634fdf4db9c206ba55b8223b\",\n \"name\": \"Summer_Sale_Header_Updated\",\n \"status\": \"ACTIVE\",\n \"raw_content\": \"<h1>Massive Summer Sale!</h1>\",\n \"content_type\": \"HTML\",\n \"updated_by\": \"abc@gmail.com\",\n \"content_block_used\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["MOE-APPKEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"634fdf4db9c206ba55b8223b\",\n \"name\": \"Summer_Sale_Header_Updated\",\n \"status\": \"ACTIVE\",\n \"raw_content\": \"<h1>Massive Summer Sale!</h1>\",\n \"content_type\": \"HTML\",\n \"updated_by\": \"abc@gmail.com\",\n \"content_block_used\": []\n}"
response = http.request(request)
puts response.read_body{
"title": "Invalid Field Value",
"description": "app_key - Some of the field values are invalid: app_key : None",
"code": "nGpUNpDQ"
}{
"title": "Internal Server Error",
"description": "An unexpected error occurred on the server.",
"code": "SRV_ERR_123"
}Update Content Block
You can use this API to update the content blocks in MoEngage.
curl --request PUT \
--url https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: <api-key>' \
--data '
{
"id": "634fdf4db9c206ba55b8223b",
"name": "Summer_Sale_Header_Updated",
"status": "ACTIVE",
"raw_content": "<h1>Massive Summer Sale!</h1>",
"content_type": "HTML",
"updated_by": "abc@gmail.com",
"content_block_used": []
}
'import requests
url = "https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks"
payload = {
"id": "634fdf4db9c206ba55b8223b",
"name": "Summer_Sale_Header_Updated",
"status": "ACTIVE",
"raw_content": "<h1>Massive Summer Sale!</h1>",
"content_type": "HTML",
"updated_by": "abc@gmail.com",
"content_block_used": []
}
headers = {
"MOE-APPKEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'MOE-APPKEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '634fdf4db9c206ba55b8223b',
name: 'Summer_Sale_Header_Updated',
status: 'ACTIVE',
raw_content: '<h1>Massive Summer Sale!</h1>',
content_type: 'HTML',
updated_by: 'abc@gmail.com',
content_block_used: []
})
};
fetch('https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks', 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/external/campaigns/content-blocks",
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([
'id' => '634fdf4db9c206ba55b8223b',
'name' => 'Summer_Sale_Header_Updated',
'status' => 'ACTIVE',
'raw_content' => '<h1>Massive Summer Sale!</h1>',
'content_type' => 'HTML',
'updated_by' => 'abc@gmail.com',
'content_block_used' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"MOE-APPKEY: <api-key>"
],
]);
$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/external/campaigns/content-blocks"
payload := strings.NewReader("{\n \"id\": \"634fdf4db9c206ba55b8223b\",\n \"name\": \"Summer_Sale_Header_Updated\",\n \"status\": \"ACTIVE\",\n \"raw_content\": \"<h1>Massive Summer Sale!</h1>\",\n \"content_type\": \"HTML\",\n \"updated_by\": \"abc@gmail.com\",\n \"content_block_used\": []\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("MOE-APPKEY", "<api-key>")
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/external/campaigns/content-blocks")
.header("MOE-APPKEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"634fdf4db9c206ba55b8223b\",\n \"name\": \"Summer_Sale_Header_Updated\",\n \"status\": \"ACTIVE\",\n \"raw_content\": \"<h1>Massive Summer Sale!</h1>\",\n \"content_type\": \"HTML\",\n \"updated_by\": \"abc@gmail.com\",\n \"content_block_used\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["MOE-APPKEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"634fdf4db9c206ba55b8223b\",\n \"name\": \"Summer_Sale_Header_Updated\",\n \"status\": \"ACTIVE\",\n \"raw_content\": \"<h1>Massive Summer Sale!</h1>\",\n \"content_type\": \"HTML\",\n \"updated_by\": \"abc@gmail.com\",\n \"content_block_used\": []\n}"
response = http.request(request)
puts response.read_body{
"title": "Invalid Field Value",
"description": "app_key - Some of the field values are invalid: app_key : None",
"code": "nGpUNpDQ"
}{
"title": "Internal Server Error",
"description": "An unexpected error occurred on the server.",
"code": "SRV_ERR_123"
}Authorizations
Your MoEngage Workspace ID (App Key). You can find this at Settings -> Account -> APIs -> Workspace ID.
Body
The updated details for the content block.
ID of the content block that you want to update
Name of the content block
Status of the content block - DRAFT/ACTIVE
ACTIVE, DRAFT Content of the content block
Type of the content block - HTML/ Plain Text
HTML, TEXT Email id of the user who is creating the content block
In case, you are using nested content blocks, provide the names of the other content blocks used in this content block.
If you are not using nested content blocks, you can pass this as an empty array: content_block_used : []
Description of the content block
Tags associated to the content block
Images used in content block
Response
Success
Was this page helpful?