Update Push Campaign

You can use this API to update a push campaign in MoEngage.

info Information
  • If this API is not enabled for your account, contact your CSM or raise a support ticket to request enablement.
  • You can update only those Push campaigns that are created using the Create Push Campaigns API, not the campaigns created through the MoEngage UI.

API Endpoint

Method: PATCH

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

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

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

  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 Parameters

Key Required Sample Values Description
Campaign ID Required {{campaign_id}}

This is the campaign ID of the push campaign. The campaign ID is encrypted using 16-bit DES and is encoded in the URL of the landing page. You can fetch the same from the URL of the landing page.

 

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

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 must be passed in the request. You can find your MoEngage Workspace ID in the MoEngage UI:

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

For more information, refer to Authentication.

Request Body

info

Information

  • To update a Push campaign, pass only those objects and fields that you want to update. For example, if you want to update the content of the Push campaign, pass only the campaign_content object. You need not pass the complete payload.
  • If you want to update one field of a campaign, you must pass the complete object to which the field belongs. For example, to update the "title" of the push notification, pass the complete campaign_content object.
  • You can update fields in the campaign when the campaign is in any state apart from Stopped and Archived. You can see the campaign status on the All Campaigns page by searching the campaign ID. You can also get the Campaign Status by querying the GET Campaign details API with the Campaign ID.

  • You can edit all fields except scheduling type if the campaign is in a Scheduled state for:

    • One-time campaigns

    • Periodic or Event-triggered campaigns if a single instance has not been sent out yet.

  • If the campaign is in the Active state, you cannot edit the following fields:

    • Trigger Condition

    • Segmentation Details

    • Conversion Goal Details

    • Scheduling Type

    • Scheduling Start Date

Key Required Values Description
basic_details Optional JSON Object This object contains the basic details of the campaign. For more information, refer to Basic Details.
campaign_content Optional JSON Object This object contains the campaign content. For more information, refer to Campaign Content.
trigger_condition Optional JSON Object This object contains the trigger condition details. For more information, refer to Trigger Conditions.
segmentation_details Optional 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.
scheduling_details Optional 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.
request_id Required String This field denotes the request ID for which the campaign is updated.
updated_by Required String This field denotes the Email ID of the user who updated the campaign. Supported value is email ID only.

Response Body

Key Data Type Description
message String This field contains a brief description of the request status in the case of success.
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
204 Success The server successfully processed the request, but is not returning any content.
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.
500 Internal Server Error This response is returned when the system runs into an unexpected error.

Sample cURL Request

The following cURL request serves as an example for updating a PUSH Event triggered campaign. For campaigns with other delivery types, a similar payload structure to that used in the Create Push Campaign API should be employed.

Sample cURL
curl --location 'https://api-0X.moengage.com/core-services/v1/campaigns/{{campaign_id}}'\
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data-raw '{
    "request_id": "{{request_id}}",
    "updated_by": "john.doe@abc.com",
    "basic_details": {
        "name": "{{campaign_name}}",
        "team": "{{team_name}}",
        "platforms": [
            "ANDROID",
            "IOS",
            "WEB"
        ],
        "platform_specific_details": {
            "ios": {
                "send_to_all_eligible_device": true,
                "exclude_provisional_push_devices": false,
                "send_to_only_provisional_push_enabled_devices": false
            }
        }
    },
    "campaign_content": {
        "content": {
            "push": {
                "android": {
                    "template_type": "BASIC",
                    "basic_details": {
                        "notification_channel": "general",
                        "title": "Sample Title",
                        "message": "Sample Message",
                        "summary": "Sample Message summary",
                        "image_url": "https://www.gstatic.com/webp/gallery/1.jpg",
                        "default_click_action": "DEEPLINKING",
                        "input_gif_url": "https://sample-videos.com/gif/2.gif",
                        "default_click_action_value": "https://www.gstatic.com/webp/gallery/1.jpg",
                        "key_value_pairs": [
                            {
                                "key": "q",
                                "value": "cat"
                            }
                        ]
                    },
                    "buttons": [
                        {
                            "btn_name": "Button1",
                            "click_action_type": "DEEPLINKING",
                            "click_action_name": "asd",
                            "click_action_value": "https://www.gstatic.com/webp/gallery/1.jpg",
                            "key_value_pairs": [
                                {
                                    "key": "q",
                                    "value": "tree"
                                }
                            ]
                        },
                        {
                            "btn_name": "Button2",
                            "click_action_type": "RICH_LANDING",
                            "click_action_name": "asd",
                            "click_action_value": "https://www.gstatic.com/webp/gallery/1.jpg",
                            "key_value_pairs": [
                                {
                                    "key": "q",
                                    "value": "bat"
                                }
                            ]
                        }
                    ],
                    "advanced": {
                        "coupon_code": "Coupon code 24",
                        "group_key": "1234",
                        "collapse_replace_key": "1",
                        "icon_type_in_notification": "app_icon",
                        "auto_dismiss_notification": true,
                        "auto_dismiss_notification_time_value": 1,
                        "auto_dismiss_notification_time_granularity": "DAYS"
                    }
                },
                "ios": {
                    "template_type": "BASIC",
                    "basic_details": {
                        "title": "Sample Title",
                        "message": "Sample Message",
                        "subtitle": "Sample Subtitle",
                        "allow_bg_refresh": true,
                        "rich_media_type": "Image",
                        "rich_media_value": "https://sample-videos.com/gif/2.gif",
                        "default_click_action": "DEEPLINKING",
                        "default_click_action_value": "https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg",
                        "key_value_pairs": [
                            {
                                "key": "keyy",
                                "value": "value"
                            }
                        ]
                    },
                    "buttons": [
                        {
                            "button_category": "INVITE_CATEGORY"
                        }
                    ],
                    "advanced": {
                        "coupon_code": "Sample Message",
                        "sound_file": "sampleFile",
                        "enable_ios_badge": true,
                        "group_key": "1234",
                        "collapse_replace_key": "1"
                    }
                },
                "web": {
                    "template_type": "BASIC",
                    "basic_details": {
                        "title": "Sample Title",
                        "message": "Sample Message",
                        "redirect_url": "https://www.gstatic.com/webp/gallery/1.jpg",
                        "auto_dismiss_notification": true,
                        "image_url": "https://www.gstatic.com/webp/gallery/2.jpg"
                    },
                    "buttons": [
                        {
                            "title": "Button-1",
                            "icon_url": "https://www.gstatic.com/webp/gallery/1.jpg",
                            "url": "https://www.gstatic.com/webp/gallery/2.jpg"
                        }
                    ],
                    "advanced": {
                        "icon_image_type": "ICON_URL",
                        "icon_url": "https://www.gstatic.com/webp/gallery/4.jpg"
                    }
                }
            }
        }
    },
    "scheduling_details": {
        "expiry_time": "2026-07-20T13:55:00"
    },
    "control_group_details": {
        "campaign_control_group_percentage": "5",
        "is_campaign_control_group_enabled": true,
        "is_global_control_group_enabled": true
    },
    "delivery_controls": {
        "count_for_frequency_capping": true,
        "ignore_frequency_capping": true,
        "minimum_delay_between_two_notification_in_hour": 0,
        "max_time_to_show_message_of_same_camapign": 0,
        "expiry_time_of_sync_data_in_hour": 0
    },
    "advanced": {
        "expiration_settings": {
            "expire_notification_after_value": 1,
            "expire_notification_after_type": "HOUR",
            "remove_from_inbox_after_value": 1,
            "remove_from_inbox_after_type": "HOUR"
        },
        "platform_level_priority": {
            "ios_specific_priority": {
                "apns_priority": 1,
                "interruption_level": "ACTIVE",
                "relevance_score": 1
            }
        }
    }
}'

Sample Response

info

Information

For a successful response of 204, the API does not return any content.

204 400 401 500
[]

Postman Collections

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

FAQs

arrow_drop_down Can I change the template type in an active campaign?

The template type can be modified for the required platforms, and new content needs to be provided for the updated template type.

arrow_drop_down Can I add or remove the platform in an active campaign?

The platform can be added or removed during the update of the campaigns. You need to provide content for the new platform added to the campaign.

arrow_drop_down When does the updated content get started sending out to users?

The updated campaign starts sending out as soon as changes are done, except for Event-triggered campaigns. In Event-triggered campaigns, details are cached and take up to 30 mins to send the updated campaign.

Previous

Next

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

How can we improve this article?