curl --request POST \
--url https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: <api-key>' \
--data '
{
"name": "Summer_Sale_Header",
"label": "summer_sale_header_2025",
"description": "Header for all summer sale communications",
"content_type": "HTML",
"raw_content": "<h1>Huge Summer Sale!</h1>",
"images_used": [],
"status": "ACTIVE",
"created_by": "marketing@example.com",
"content_block_used": []
}
'import requests
url = "https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks"
payload = {
"name": "Summer_Sale_Header",
"label": "summer_sale_header_2025",
"description": "Header for all summer sale communications",
"content_type": "HTML",
"raw_content": "<h1>Huge Summer Sale!</h1>",
"images_used": [],
"status": "ACTIVE",
"created_by": "marketing@example.com",
"content_block_used": []
}
headers = {
"MOE-APPKEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'MOE-APPKEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Summer_Sale_Header',
label: 'summer_sale_header_2025',
description: 'Header for all summer sale communications',
content_type: 'HTML',
raw_content: '<h1>Huge Summer Sale!</h1>',
images_used: [],
status: 'ACTIVE',
created_by: 'marketing@example.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 => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Summer_Sale_Header',
'label' => 'summer_sale_header_2025',
'description' => 'Header for all summer sale communications',
'content_type' => 'HTML',
'raw_content' => '<h1>Huge Summer Sale!</h1>',
'images_used' => [
],
'status' => 'ACTIVE',
'created_by' => 'marketing@example.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 \"name\": \"Summer_Sale_Header\",\n \"label\": \"summer_sale_header_2025\",\n \"description\": \"Header for all summer sale communications\",\n \"content_type\": \"HTML\",\n \"raw_content\": \"<h1>Huge Summer Sale!</h1>\",\n \"images_used\": [],\n \"status\": \"ACTIVE\",\n \"created_by\": \"marketing@example.com\",\n \"content_block_used\": []\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks")
.header("MOE-APPKEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Summer_Sale_Header\",\n \"label\": \"summer_sale_header_2025\",\n \"description\": \"Header for all summer sale communications\",\n \"content_type\": \"HTML\",\n \"raw_content\": \"<h1>Huge Summer Sale!</h1>\",\n \"images_used\": [],\n \"status\": \"ACTIVE\",\n \"created_by\": \"marketing@example.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::Post.new(url)
request["MOE-APPKEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Summer_Sale_Header\",\n \"label\": \"summer_sale_header_2025\",\n \"description\": \"Header for all summer sale communications\",\n \"content_type\": \"HTML\",\n \"raw_content\": \"<h1>Huge Summer Sale!</h1>\",\n \"images_used\": [],\n \"status\": \"ACTIVE\",\n \"created_by\": \"marketing@example.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"
}Create Content Block
You can use this API to create a content block in MoEngage.
curl --request POST \
--url https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: <api-key>' \
--data '
{
"name": "Summer_Sale_Header",
"label": "summer_sale_header_2025",
"description": "Header for all summer sale communications",
"content_type": "HTML",
"raw_content": "<h1>Huge Summer Sale!</h1>",
"images_used": [],
"status": "ACTIVE",
"created_by": "marketing@example.com",
"content_block_used": []
}
'import requests
url = "https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks"
payload = {
"name": "Summer_Sale_Header",
"label": "summer_sale_header_2025",
"description": "Header for all summer sale communications",
"content_type": "HTML",
"raw_content": "<h1>Huge Summer Sale!</h1>",
"images_used": [],
"status": "ACTIVE",
"created_by": "marketing@example.com",
"content_block_used": []
}
headers = {
"MOE-APPKEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'MOE-APPKEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Summer_Sale_Header',
label: 'summer_sale_header_2025',
description: 'Header for all summer sale communications',
content_type: 'HTML',
raw_content: '<h1>Huge Summer Sale!</h1>',
images_used: [],
status: 'ACTIVE',
created_by: 'marketing@example.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 => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Summer_Sale_Header',
'label' => 'summer_sale_header_2025',
'description' => 'Header for all summer sale communications',
'content_type' => 'HTML',
'raw_content' => '<h1>Huge Summer Sale!</h1>',
'images_used' => [
],
'status' => 'ACTIVE',
'created_by' => 'marketing@example.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 \"name\": \"Summer_Sale_Header\",\n \"label\": \"summer_sale_header_2025\",\n \"description\": \"Header for all summer sale communications\",\n \"content_type\": \"HTML\",\n \"raw_content\": \"<h1>Huge Summer Sale!</h1>\",\n \"images_used\": [],\n \"status\": \"ACTIVE\",\n \"created_by\": \"marketing@example.com\",\n \"content_block_used\": []\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-0{dc}.moengage.com/v1/external/campaigns/content-blocks")
.header("MOE-APPKEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Summer_Sale_Header\",\n \"label\": \"summer_sale_header_2025\",\n \"description\": \"Header for all summer sale communications\",\n \"content_type\": \"HTML\",\n \"raw_content\": \"<h1>Huge Summer Sale!</h1>\",\n \"images_used\": [],\n \"status\": \"ACTIVE\",\n \"created_by\": \"marketing@example.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::Post.new(url)
request["MOE-APPKEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Summer_Sale_Header\",\n \"label\": \"summer_sale_header_2025\",\n \"description\": \"Header for all summer sale communications\",\n \"content_type\": \"HTML\",\n \"raw_content\": \"<h1>Huge Summer Sale!</h1>\",\n \"images_used\": [],\n \"status\": \"ACTIVE\",\n \"created_by\": \"marketing@example.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 details of the content block to be created.
Name of the content block
Label to uniquely identify your content block
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 : []
Shows the status of the content block
ACTIVE, DRAFT Description of the content block
Tags associated with the content block
Images used in content block
Response
Success
Was this page helpful?