You can use the Campaign Status API to change the status of a campaign in MoEngage. This API helps you to update the following statuses of the APIs:
- Stop a scheduled One-time campaign
- Pause and resume a running Periodic or Event-triggered campaign
info |
Information
|
API Endpoint
POST https://api-0X.moengage.com/core-services/v1/campaigns/status
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.
- 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 | 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 |
---|---|---|---|
action | Required | String |
This field denotes the action you want to perform on a campaign. The supported values are:
|
campaign_ids | Required | Array |
This field denotes the campaign ID of the campaign whose status you want to change. Note: You can pass a maximum of 10 campaign IDs. |
request_id | Required | String | This field denotes the request ID of the campaigns whose status you want to change. |
Response
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:
|
Response Codes
Status Code | Request State | Description |
---|---|---|
200 |
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 are sample codes to:
- Pause a campaign
- Resume a campaign
- Stop a campaign
curl --location 'https://api-0X.moengage.com/core-services/v1/campaigns/status' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data '{
"action": "PAUSE",
"campaign_ids": [
"{{Campaign_ID}}"
],
"request_id": "12345"
}'
curl --location 'https://api-0X.moengage.com/core-services/v1/campaigns/status' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data '{
"action": "RESUME",
"campaign_ids": [
"{{Campaign_ID}}"
],
"request_id": "12345"
}'
curl --location 'https://api-0X.moengage.com/core-services/v1/campaigns/status' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data '{
"action": "STOP",
"campaign_ids": [
"{{Campaign_ID}}"
],
"request_id": "12345"
}'
Sample Response
info |
Information For a successful response of 200, the API does not return any content. |
{}
{
"error": {
"code": "400 Bad Request",
"message": "request_id key is mandatory field",
"target": "request_id",
"details": [
{
"target": "request_id",
"message": "request_id key is mandatory field"
}
],
"request_id": "11"
}
}
{
"error": {
"code": "401 Authentication error",
"message": "Authentication required",
"details": [
{
"code": "InvalidValue",
"target": "APP_SECRET_KEY",
"message": [
{
"code": "InvalidValue",
"target": "APP_SECRET_KEY",
"message": "Invalid APP_SECRET_KEY is provided."
}
]
}
],
"request_id": ""
}
}
{
"error": {
"code": "500 Internal Server Error",
"message": "Something went wrong. Please contact Moengage team",
"target": "string",
"details": [
{
"message": "Expecting value: line 1 column 1 (char 0)",
"target": ""
}
]
}
}
Postman Collections
We have made it easy for you to test the APIs. Click here to view it in Postman.
FAQs
Periodic campaign only supports Pause and Resume actions of the campaign. You can stop only One-time campaigns.
No, after the One-time campaign moved to the Active state, you cannot stop it.