Create Campaigns

You can use the Create Campaigns API to create a campaign in MoEngage.

info

Information

Currently, you can use this API to create Email campaigns only.

API Endpoint

API Endpoint
POST https://api-0X.moengage.com/core-services/v1/campaigns

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="}

You can obtain the username and password details from the MoEngage Dashboard.

  1. Navigate to Settings -> Account -> APIs.
  2. 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.
  3. Use these 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 bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="}

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

MOE-APPKEY Required

{“MOE-APPKEY”: “Workspace ID”}

This is the workspace ID (earlier APP ID) of your MoEngage workspace. The MOE-APPKEY has to be passed in the request. You can find your MoEngage Workspace ID in the MoEngage Dashboard:

Settings -> Account -> APIs -> Workspace ID (earlier app id)

For more information, refer to Authentication.

Request Body

Key Required Values Description
request_id
Required String

This field denotes the request ID that you must pass to create the campaign.

Note: After you create a campaign successfully using a request ID, do not use it again for the next 1 day. If campaign creation is unsuccessful, you can use the same request ID immediately again.

channel
Required String

This field denotes the type of channel. Currently, the supported value is:

  • EMAIL
campaign_delivery_type
Required String

This field denotes the type of campaign based on delivery. Supported values are:

  • ONE_TIME
  • PERIODIC
  • EVENT_TRIGGERED
  • BUSINESS_EVENT_TRIGGERED
created_by
Required String This field denotes the Email ID of the user who created the campaign. Supported value is email ID only.
basic_details Required JSON Object This object contains the basic details of the campaign. For more information, refer to Basic Details.
trigger_condition Optional JSON Object

This object contains the trigger condition details. For more information, refer to Trigger Conditions.

Note: This object is required for event-triggered campaigns. 

segmentation_details Required JSON Object

This object contains the segmentation details. For more information, refer to Segmentation Details.

control_group_details Optional JSON Object This object contains the control group details. For more information, refer to Control Group Details.
utm_params Optional JSON Object This object contains the UTM parameters details. For more information, refer to UTM Parameters.
connector Required JSON Object

This object contains the connector details. For more information, refer to Connector Details.

campaign_content Required JSON Object This object contains the campaign content. For more information, refer to Campaign Content.
scheduling_details Required JSON Object This object contains the scheduling details. For more information, refer to Scheduling Details.
conversion_goal_details Optional JSON Object This object contains the conversion goal details. For more information, refer to Conversion Goal Details.
delivery_controls Optional JSON Object This object contains the delivery controls details. For more information, refer to Delivery Controls.

Basic Details

The basic_details JSON object contains the following information:

Key Required Values Description
business_event Optional String

This field denotes the business event to be mapped to the campaign.

Note: This field is required for business event-triggered campaigns.

content_type Required String

This field denotes the type of content in the campaign. Supported values are:

  • PROMOTIONAL
  • TRANSACTIONAL
name Required String This field denotes the name of the campaign.
subscription_category Optional String

This field denotes the type of communication that your customer receives from your brand.

This would help you target only those users who have opted-in to receive communication about a specific category. For more information, refer to Subscription Categories.

Note: This field is mandatory if you are creating a promotional email campaign.

tags Optional Array

This field provides context about the campaigns and describes the nature of the campaign or the campaign's central theme.

team Optional String This field denotes the name of a group of users collaborating on the same campaign. For more information, refer to Teams.
user_attribute_identifier Required String

This field denotes the user attribute that stores the email address.

MoEngage standard user attribute identifier is MOE_EMAIL_ID. This is a standard attribute where the name is provided by MoEngage and the value is provided by the client.

Trigger Conditions

The trigger_condition is used for Event-Triggered campaigns. This JSON object contains the following information:

info

Information

The trigger_condition object is required only for Event-Triggered campaigns.

Key Required Values Description
included_filters Optional JSON Object This object denotes the segmentation filters that help you choose the trigger condition for your campaign.
secondary_included_filters Optional  JSON Object

This object denotes the segmentation filters that help you choose the secondary trigger condition for your campaign.

Note: Secondary include filters will be used when the secondary events are used in the event triggered campaigns.

trigger_delay_type Optional String

This field denotes the type of triggered delay. Supported values are:

  • DELAY
  • ASAP

Note: When you pass DELAY value in this parameter, the following fields are mandatory:

  • trigger_delay_value
  • trigger_delay_granularity
  • trigger_relation
trigger_delay_value Optional Integer This field denotes the value of the triggered delay.
trigger_delay_granularity Optional String

This field denotes the granularity of the triggered delay. Supported values are:

  • DAYS
  • HOURS
  • MINUTES
trigger_relation Optional String

This field denotes the trigger relation with delay. Supported values are:

  • BEFORE
  • AFTER
trigger_attr Optional JSON Object This object denotes the attribute value of the trigger.

Segmentation Details

The <> JSON object contains the following information:

Key Required Values Description
excluded_filters Optional JSON Object This field contains the exclusion filtering criteria used for segmentation. The users satisfying this set of filters will be excluded from the segment.
included_filters Optional JSON Object

This field contains the inclusion filtering criteria used for segmentation. The users satisfying this set of filters will be included in the segment.

is_all_user_campaign Optional Boolean

This field indicates if all users should be included in the campaign.

info

Information

For more information on the detailed segmentation payload and supported fields, refer to Create Custom Segment.

Control Group Details

The control_group_details JSON object contains the following information:

Key Required Values Description
is_campaign_control_group_enabled Optional Boolean This field denotes whether the campaign control group is enabled or not.
campaign_control_group_percentage Optional Integer

This field denotes the percentage of users added to an exclusion list.

Note: If is_campaign_control_group_enabled is True, campaign_control_group_percentage field is required.

is_global_control_group_enabled Optional Boolean This field denotes whether the global control group is enabled or not.

UTM Parameters

The utm_params JSON object contains the following information:

Key Required Values Description
utm_source Required String

This field denotes the source of the traffic. It helps to track where the traffic came from. The source can be a website, app, or link. For example, YouTube, Instagram, Google.

Note: When you are using the utm_params JSON object, this field is required.

utm_medium Required String

This field denotes the channel type. It helps to track the channel from where the user came. For example, Push, SMS, Email.

Note: When you are using the utm_params JSON object, this field is required.

utm_campaign Optional String

This field denotes the name of the campaign. It helps to track the performance of a specific campaign. For example, Newyear, Bigbillionday.

utm_term Optional String

This field denotes search terms for paid traffic. It helps to search the keyword or term that led to the audience visiting your site. For example, Mobile+sale.

utm_content Optional String

This field denotes the content. It is the element that differentiates links pointing to the same URL. It helps to identify the exact element on your campaign that was clicked. It is useful for for A/B testing. For example, banner, video, product image.

utm_custom Optional String

This field denotes the custom UTM parameter. You can pass a maximum of five custom UTM parameters.

Connector Details

The connector JSON object contains the following information:

Key Required Values Description
connector_name Required String This field indicates the connector service you are using.
connector_type Required String This field indicates the type of connector you are using.

Campaign Content

The campaign_content JSON object contains the following information:

Key Required Values Description
content Required JSON Object This object has the email object. For more information, refer to Email Details.
locales Optional Array

This field includes locale information. You can send email campaigns in multiple languages using locales.

variation_details Optional JSON Object For more information, refer to Variation Details.

Email Details

The email JSON object contains the following information:

Key Required Values Description
attachments Optional Array

This field indicates the attachment to the email. It has the items field in the following structure:

items: {}
   example: [{'file_type': 'URL/PERSONALIZED_ATTACHMENT', 'url': ''}]

bcc_ids Optional Array

This field indicates the email IDs to which you want to send the email in Bcc.

cc_ids Optional Array

This field indicates the email IDs to which you want to send the email in Cc.

from_address Required  String This field denotes the sender's email address.
custom_template_id Optional String

This field denotes the ID of the custom template.

Note:

  • This field is required if you do not pass the html_content.
  • When you pass this field, the following fields are not required:
    • subject
    • preview_text
    • sender_name
custom_template_version Optional Integer This field denotes the version of the custom template.
html_content Required String

This field denotes the HTML content of the email campaign.

Note: This field is optional if you pass the custom_template_id.

preview_text Optional String This field denotes the preview text of the campaign.
reply_to_address Required String The field denotes the reply to the address of the campaign.
sender_name Required String This field denotes the name of the sender of the campaign.
subject Required String This field denotes the subject line of your campaign.

Variation Details

The variation_details JSON object contains the following information:

Key Required Values Description
distribution_type Required String

This field denotes the distribution type. Supported values are:

  • SHERPA
  • MANUAL
manual_distribution_percentage Optional JSON Object This object denotes the percentage of manual distribution. This object contains the following fields:
  • 0: This field is of String type and indicates the percentage of user category you want to send for the zero variation.
  • 1: This field is of String type and indicates the percentage of user category you want to send for the first variation.
no_of_variations Required Number This field denotes the number of variations of the campaign.
sherpa_campaign_duration Optional Number This field denotes the Sherpa campaign duration.
sherpa_distribution_metric Optional String

This field denotes the Sherpa distribution metric. Supported values are:

  • OPEN RATE
  • CLICK RATE
  • BOTH

Scheduling Details

The scheduling_details JSON object contains the following information:

Key Required Values Description
bts_details Optional JSON Object This field contains the details about best time to send. For more information, refer to Best Time to Send (BTS) Details.
delivery_type Required String This field denotes when to deliver your campaign.
expiry_time Optional String This field denotes the expiry time of your campaign.
periodic_details Optional JSON Object This object denotes the periodic details of the campaign. For more information, refer to Periodic Details.
start_time Optional String This field denotes the start time of your campaign.
user_timezone_details Optional JSON Object This object denotes the user's time zone details. For more information, refer to User Timezone Details.

Best Time to Send (BTS) Details

Best Time to Send (BTS) provides a prescriptive time slot to send a campaign to the user to increase the chance of interaction or user response. For more information, refer to Best time to send.

The bts_details JSON object contains the following information:

Key Required Values Description
if_user_bts_is_not_available Optional String This field denotes when to send the campaign if the user's best time is not available.
if_user_bts_outside_time_window Optional String This field denotes when to send the campaign if the user's best time is outside this time window.
send_in_bts Optional Boolean This field denotes whether to send a campaign in the best time or not.
window_end_time Optional String This field denotes the window end time. 

Periodic Details

The periodic_details JSON object contains the following information:

Key Required Values Description
no_of_occurences Optional Number This field denotes the number of occurrences of the campaign.
repeat_frequency Optional Number This field denotes the repeat frequency of the campaign. 
repeat_on_date_of_month Optional Array

This field indicates the date of the month on which the campaign should be repeated.

For example, to send the campaign on the 5th and the 25th of a month, pass 5 and 25.

repeat_on_days_of_week_for_month Optional Array

This field denotes which days of the week for a month the campaign should repeat.

This array contains the following item fields: 

  • week_granularity: This field is of String type and indicates the days on which the campaign should be sent. For example, SECOND, FIRST, and LAST.
  • repeat_on_days_of_week: This field indicates the days of the week on which the campaign should be repeated and is an Array. For example, MONDAY.
repeat_on_days_of_week Optional Array

This field denotes which days of the week the campaign repeats. 

For example, if you wish to send the campaign every Monday and Friday, pass these days in this field as MONDAY and FRIDAY.

sending_frequency Optional String This field denotes the frequency to send the campaign.
       

User Timezone Details

The user_timezone_details JSON object contains the following information:

Key Required Values Description
send_if_user_timezone_has_passed Optional Boolean This field denotes whether to send the campaign if the user's time zone has passed.
send_in_user_timezone Optional Boolean This field denotes whether to send the campaign on a specific date and time within the time zone of the user.

Conversion Goal Details

The conversion_goal_details JSON object contains the following information:

Key Required Values Description
attribution_window_in_hours Optional Number This field denotes the attribution window in hours.
goals Optional Array This field has the items object. For more information on its structure, refer to Items Details.

Items Details

The items JSON object contains the following information:

Key Required Values Description
goal_event_attribute Optional JSON Object This object denotes the goal event attribute. For more information, refer to Goal Event Attributes.
goal_event_name Optional String This field denotes the goal event name.
goal_name Optional String This field denotes the goal name.
is_primary_goal Optional Boolean This field denotes whether this is a primary goal or not.
revenue_attribute Optional String This field denotes the revenue attribute.
revenue_currency Optional String This field denotes the revenue currency.

Goal Event Attributes

The goal_event_attribute JSON object contains the following information:

Key Required Values Description
condition Optional String This field denotes the condition used while creating a goal. 
is_case_sensitive Optional Boolean This field denotes whether the goal event attribute is case-sensitive or not.
name Optional String This field denotes the name of the goal event attribute.
value Optional String This field denotes the value of the goal event attribute.

Delivery Controls

The delivery_controls JSON object contains the following information:

Key Required Values Description
bypass_dnd Optional Boolean This field denotes whether you want to bypass DND.
campaign_throttle_rpm Optional Number This field denotes the campaign throttle RPM.
count_for_frequency_capping Optional Boolean This field denotes whether you want to count the channel message sent by a particular Flow for frequency capping.
ignore_frequency_capping Optional Boolean This field denotes whether you want to ignore frequency capping or not.
minimum_delay_between_two_notification_in_hour Optional Number This field denotes the minimum delay between two notifications in an hour.

Response

Key Data Type Description
campaign_id String This field contains the unique ID corresponding to a successful campaign creation request and needs to be stored by you. This campaign ID is used for searching a specific campaign and updating it.
error JSON Object

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

Structure:

 "error": {

    "code": "<error_code>", 

    "message": "<error_message>",

    "target": "<target>",

    "details": [

         {

             "target": "<target>",

             "message": "<error_message>"

          }

    ],

    "request_id": "<request_id>"

    }

}

The error object contains the following fields:

  • code - This field is of String type and contains the error code that provides a brief explanation of the error. 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 is of String type and describes why the request has failed.
  • target - This field is of String type and denotes the target of the error.
  • details - This object provides the error details and contains the following information:
    • target - This field is of String type and denotes the target of the error.
    • message - This field is of String type and describes why the request has failed.
  • request_id: This field denotes the request ID.

Response Codes

Status Code Request State Description

201

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, or when a template already exists with the same version, name, or ID.

401

Authentication Failure

This response is returned when the authorization parameters are missing in the HTTP Auth Header.

429

Rate Limit Breach

This response is returned when the number of requests per minute has exceeded the rate limit.

500

Internal Server Error

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

Rate Limit

You can create 5 campaigns per minute, 25 campaigns per hour, and 100 campaigns per day.

Sample cURL Request

Delivery Types

One-Time Periodic Event-Triggered
curl --location 'https://api-0X.moengage.com/core-services/v1/campaigns' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data-raw '{
    "request_id": "dfgdbddddu123",
    "channel": "EMAIL",
    "campaign_delivery_type": "ONE_TIME",
    "created_by": "john.doe@example.com",
    "basic_details": {
        "name": "Test Name 1",
        "tags": [
            "activation"
        ],
        "content_type": "PROMOTIONAL",
        "subscription_category" : "music",
        "team" : "campaign_core"
    },
    "segmentation_details": {
        "included_filters": {
            "filter_operator": "and",
            "filters": [
                {
                    "data_type": "string",
                    "category": "Tracked Standard Attribute",
                    "name": "uid",
                    "value": "John_Ios",
                    "filter_type": "user_attributes",
                    "case_sensitive": false,
                    "operator": "is",
                    "negate": false
                }
            ]
        }
    },
    "control_group_details": {
        "is_global_control_group_enabled": true,
        "is_campaign_control_group_enabled": true,
        "campaign_control_group_percentage": "5"
    },
    "utm_params": {},
    "connector": {
        "connector_type": "SENDGRID",
        "connector_name": "default"
    },
    "campaign_content": {
        "locales": [],
        "variation_details": {},
        "content": {
            "email": {
                "subject": "Scheduled Campaign - BT",
                "preview_text": "Scheduled Campaign - BT",
                "sender_name": "Scheduled Campaign - BT",
                "from_address": "",
                "reply_to_address": "john.doe@example.com",
                "cc_ids": [],
                "bcc_ids": [],
                "html_content": "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title></title><style>\n \n body table{\n border-collapse: collapse;\n }\n\n body table td, body table th{\n border: 1px solid rgb(221, 221, 221);\n }\n\n \t\t\t</style></head><body aria-disabled=\"false\" data-gr-ext-installed=\"\" data-new-gr-c-s-check-loaded=\"14.1182.0\" data-new-gr-c-s-loaded=\"14.1182.0\" spellcheck=\"false\">\n\n<p>Test User</p></body></html>"
            }
        }
    },
    "scheduling_details": {
        "delivery_type": "AT_FIXED_TIME",
        "start_time": "2024-06-21T12:59:00.000Z"    
    },
    "conversion_goal_details": {
        "attribution_window_in_hours": "36",
        "goals": [
            {
                "goal_name": "Goal 1",
                "goal_event_name": "NOTIFICATION_RECEIVED_MOE",
                "goal_event_attribute": {
                    "name": "moe_campaign_channel",
                    "condition": "is",
                    "value": "2",
                    "is_case_sensitive": true
                },
                "is_primary_goal": true,
                "revenue_attribute": "moe_device_densitydpi",
                "revenue_currency": "ALL"
            },
            {
                "goal_name": "Goal 2",
                "goal_event_name": "testconversions",
                "goal_event_attribute": {
                    "name": "sdkVersion",
                    "condition": "is",
                    "value": "2.2",
                    "is_case_sensitive": true
                },
                "is_primary_goal": false
            }
        ]
    },
    "delivery_controls": {
        "ignore_frequency_capping": true,
        "count_for_frequency_capping": true,
        "minimum_delay_between_two_notification_in_hour": 2,
        "bypass_dnd": false,
        "campaign_throttle_rpm": 2000
    }
}'

Scheduling

The following is a sample code for a Periodic campaign with:

Monthly frequency Weekly frequency with BTS Daily frequency with user time zone
"scheduling_details": {
        "delivery_type": "AT_FIXED_TIME",
        "start_time": "2024-06-29T20:32:00.000Z",
        "periodic_details": {
            "sending_frequency": "MONTHLY",
            "repeat_frequency": 1,
            "no_of_occurences": 3,
            "repeat_on_days_of_week_for_month": [
                {
                    "week_granularity": "FIRST",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "FRIDAY"
                    ]
                },
                {
                    "week_granularity": "THIRD",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "MONDAY"
                    ]
                },
                {
                    "week_granularity": "SECOND",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "THURSDAY"
                    ]
                },
                {
                    "week_granularity": "FOURTH",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "WEDNESDAY"
                    ]
                },
                {
                    "week_granularity": "LAST",
                    "repeat_on_days_of_week": [
                        "SATURDAY",
                        "FRIDAY"
                    ]
                }
            ]
        }
    },

Locale and Variation

The following is a sample code for a Periodic campaign with three locales and three variations:

Sample cURL
curl --location 'https://api-0X.moengage.com/core-services/v1/campaigns' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data-raw '{
    "request_id": "111111241",
    "channel": "EMAIL",
    "campaign_delivery_type": "PERIODIC",
    "created_by": "john.doe@example.com",
    "basic_details": {
        "name": "happy flow campaigns api",
        "tags": [
            "activation"
        ],
        "content_type": "PROMOTIONAL",
        "team" : "campaign_core",
        "subscription_category" : "music"
    },
    "segmentation_details": {
        "included_filters": {
            "filter_operator": "and",
            "filters": [
                {
                    "data_type": "string",
                    "category": "Tracked Standard Attribute",
                    "name": "u_em",
                    "filter_type": "user_attributes",
                    "case_sensitive": false,
                    "operator": "exists",
                    "negate": false
                }
            ]
        }
    },
    "control_group_details": {
        "is_global_control_group_enabled": false,
        "is_campaign_control_group_enabled": false
    },
    "utm_params": {},
    "connector": {
        "connector_type": "SENDGRID",
        "connector_name": "default"
    },
    "campaign_content": {
        "locales": [
            "karnataka",
            "SampleTest",
            "default"
        ],
        "variation_details": {
            "distribution_type": "MANUAL",
            "no_of_variations": 3,
            "manual_distribution_percentage": {
                "variation_1": "40",
                "variation_2": "50",
                "variation_3": "10"
            }
        },
        "content": {
            "karnataka": {
                "variation_1": {
                    "email": {
                        "subject": "abca locale var1 karnataka",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html"
                    }
                },
                "variation_2": {
                    "email": {
                        "subject": "abca locale var2 karnataka",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                },
                "variation_3": {
                    "email": {
                        "subject": "abca locale var3 karnataka",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                }
            },
            "SampleTest": {
                "variation_1": {
                    "email": {
                        "subject": "abca locale var1 SampleTest",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                },
                "variation_2": {
                    "email": {
                        "subject": "abca locale var2 SampleTest",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                },
                "variation_3": {
                    "email": {
                        "subject": "abca locale var3 SampleTest",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                }
            },
            "default": {
                "variation_1": {
                    "email": {
                        "subject": "abca locale var1",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                },
                "variation_2": {
                    "email": {
                        "subject": "abca locale var2",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                },
                "variation_3": {
                    "email": {
                        "subject": "abca locale var3",
                        "preview_text": "abc",
                        "sender_name": "abc",
                        "from_address": "john.doe@example.com",
                        "reply_to_address": "john.doe@example.com",
                        "cc_ids": [],
                        "bcc_ids": [],
                        "html_content": "<!DOCTYPEhtml><html><head><metahttp-equiv=\"Content-Type\"content=\"text/html; charset=UTF-8\"><title></title><style>bodytable{border-collapse:collapse;}bodytabletd,bodytableth{border:1pxsolidrgb(221,221,221);}</style></head><bodyaria-disabled=\"false\"><p><spanclass=\"fr-marker\"data-id=\"0\"data-type=\"true\"style=\"display: none; line-height: 0;\">​</span>hey</p><p>Userattribute- {{UserAttribute['\''First Seen'\'']}} {{UserAttribute['\''product_id'\'']}}</p><p>Eventattribute-no</p><p>Contentblock- {{ContentBlock['\''test'\'']}}{{ContentBlock['\''22Duplicate_Wilber_Plain_text_06_07_2023_83596'\'']}}</p><p>Auxdatamapping-{%set Core_devTest_fileData=UserAttribute['\''uid'\'']|getAuxData('\''Core_devTest_file'\'')%} {{Core_devTest_fileData.random_data}}</p><p>Contentapi- {%set var=ContentApi.migration_content_api({({&quot;params&quot;:{&quot;q&quot;:&quot;London,uk&quot;,&quot;appid&quot;:&quot;e81e3dcdf2845b441d22458d2cc02bb6&quot;},&quot;static_params&quot;:{},&quot;dynamic_params&quot;:{},&quot;request_body&quot;:{}})})%} {{var}} </p><p>productset-{%if ProductSet.test_migration_product_sets%}{%for product in ProductSet.test_migration_product_sets%}{%endfor%}{%else%}MOE_NOT_SEND{%endif%}<spanclass=\"fr-marker\"data-id=\"0\"data-type=\"false\"style=\"display: none; line-height: 0;\">​</span></p></body></html>"
                    }
                }
            }
        }
    },
    "scheduling_details": {
        "delivery_type": "AT_FIXED_TIME",
        "start_time": "2024-06-29T20:32:00.000Z",
        "periodic_details": {
            "sending_frequency": "MONTHLY",
            "repeat_frequency": 1,
            "no_of_occurences": 3,
            "repeat_on_days_of_week_for_month": [
                {
                    "week_granularity": "FIRST",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "FRIDAY"
                    ]
                },
                {
                    "week_granularity": "THIRD",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "MONDAY"
                    ]
                },
                {
                    "week_granularity": "SECOND",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "THURSDAY"
                    ]
                },
                {
                    "week_granularity": "FOURTH",
                    "repeat_on_days_of_week": [
                        "TUESDAY",
                        "WEDNESDAY"
                    ]
                },
                {
                    "week_granularity": "LAST",
                    "repeat_on_days_of_week": [
                        "SATURDAY",
                        "FRIDAY"
                    ]
                }
            ]
        }
    },
    "conversion_goal_details": {
        "attribution_window_in_hours": 39,
        "goals": [
            {
                "goal_name": "Goal 1",
                "goal_event_name": "NOTIFICATION_RECEIVED_MOE",
                "goal_event_attribute": {
                    "name": "moe_campaign_channel",
                    "condition": "is",
                    "value": "2",
                    "is_case_sensitive": true
                },
                "is_primary_goal": true,
                "revenue_attribute": "moe_device_densitydpi",
                "revenue_currency": "ALL"
            },
            {
                "goal_name": "Goal 2",
                "goal_event_name": "testconversions",
                "goal_event_attribute": {
                    "name": "sdkVersion",
                    "condition": "is",
                    "value": "2.2",
                    "is_case_sensitive": true
                },
                "is_primary_goal": false
            },
            {
                "goal_name": "Goal 3",
                "goal_event_name": "USER ENTERED FLOW",
                "goal_event_attribute": {
                    "name": "user_entry_identifier",
                    "condition": "is",
                    "value": "2",
                    "is_case_sensitive": true
                },
                "is_primary_goal": false
            }
        ]
    },
    "delivery_controls": {
        "ignore_frequency_capping": true,
        "count_for_frequency_capping": true,
        "minimum_delay_between_two_notification_in_hour": 2,
        "bypass_dnd": false,
        "campaign_throttle_rpm": 3000
    }
}'

Sample Response

201 400 401 429 500
Sample Response for a successful request
{
  "campaign_id": "{Campaign_ID}"
}

Postman Collections

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

FAQs

arrow_drop_down How can I personalize the campaign created through this API?

You can use user attributes, event attributes, product sets, content API, and content block for personalising campaigns. The syntax of the personalization Jinja is the same as supported in the MoEngage dashboard.

arrow_drop_down Is there any way to ensure multiple campaigns with the same payload are not created?

MoEngage dedups the campaign using the request ID. If the same request ID is passed twice in 24 hours, the second campaign creation will fail.

arrow_drop_down How are these campaigns displayed on the UI?

Campaigns are displayed under the same delivery type with which the campaigns are created through this API. For example, One-Time, Periodic, and so on.

arrow_drop_down Can I pass template ID and HTML content together in the content object?

No, only one of the two is required for creating the campaign. If both are passed, the campaign creation will display an error.

Previous

Next

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

How can we improve this article?