You can use this API to create a content block in MoEngage.
API Endpoint
POST https://api-0X.moengage.com/v1/external/campaigns/content-blocks
The 'X' in the API Endpoint URL refers to the MoEngage Data Center (DC). MoEngage maintains different data centres for different clients. You can find your DC number (value of X) and replace the value of 'X' in the URL by referring to the DC and API endpoint mapping here.
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_APPKEY_APIKEY"}
You can obtain the username and password details from the MoEngage UI.
- 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 tile to copy the API key.
- Use these details to authenticate the API requests.
Request Headers
| Key | Value | Description |
|---|---|---|
|
MOE-APPKEY
|
The App key for your MoEngage account. |
You can find your MoEngage APP key at Settings -> Account -> APIs -> App ID. |
| Content-Type | application/json | -- |
Request Body
| Keys | Type | Value | Description |
|---|---|---|---|
|
name |
Mandatory |
String |
Name of the content block |
|
label |
Mandatory |
String |
Label to uniquely identify your content block |
|
status |
Optional |
String |
Shows the status of the content block |
|
raw_content |
Mandatory |
String |
Raw content of the content block |
|
content_type |
Mandatory |
String |
Type of the content block - HTML/TEXT |
|
description |
Optional |
String |
Description of the content block |
|
created_by |
Mandatory |
String |
Email id of the user who created the content block |
|
tag_ids |
Optional |
Array of ids |
Tags associated with the content block |
|
team_ids |
Optional |
Array of ids |
Name of the teams for which the content block is enabled. This is only applicable to the accounts where Teams is enabled. For more information, refer to Teams. |
|
content_block_used |
Optional |
Array of ids |
If 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 : [] |
|
images_used |
Optional |
Array of ids |
Images used in content block |
Response
| Status Code | Request State | Description | Body |
|---|---|---|---|
|
HTTP 202 |
Success |
||
|
HTTP 400 |
Bad Request |
|
{ "title": "Invalid Field Value", "description": "app_key - Some of the field values are invalid: app_key : None", "code": "nGpUNpDQ" } |
|
HTTP 5xx |
Failure |
Server issue |
{ "title": "Internal Server Error", ... } |
Sample cURL request
curl --location --request POST 'https://api-0X.moengage.com/v1/external/campaigns/content-blocks' \
--header 'MOE-APPKEY: {{APP-KEY}} \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "test",
"description": "test",
"content_type": "HTML",
"raw_content": "test",
"images_used": [],
"status": "ACTIVE",
"created_by": "test",
"label": "test"
}'
Sample request
{
"name": "test",
"description": "test",
"content_type": "HTML",
"raw_content": "test",
"images_used": [],
"status": "ACTIVE",
"created_by": "test",
"label": "test"
}
Attribute Mapping
| Key | Type | Data Type | Description |
|---|---|---|---|
|
name
|
Mandatory | String | Name of the content block |
| label | Mandatory | String | Label to uniquely identify your content block |
| raw_content | Mandatory | String | Content of the content block |
| content_type | Mandatory | String | Type of the content block - HTML/ TEXT |
| description | Optional | String | Description of the content block |
| created_by | Mandatory | String | Email id of the user who is creating the content block |
| tag_ids | Optional | Array of strings | Tags associated with the content block |
| team_ids | Optional | Array of strings | Teams for which the content block should be available. Passing team id is mandatory if you are using multiple teams. For more information, refer to Teams. |
| content_block_used | Mandatory | Array of string |
In case, you are using nested content blocks, provide the names of the other content blocks used in this content block content_block_used : [] |
Postman Collections
We have made it easy for you to test the APIs. Click here to view it in Postman.