Campaign Report API

Campaign Report REST API enables you to download the campaign report for a particular date. The API provides campaign data for only one date at a time.

On the report builder page, select the REST API option for the system to generate the report for the selected schedule. Ensure some buffer time from the scheduled time as the reports are generated using the API. Generated report expires within seven days of generation.

To use the Campaign Report API, do the following:

  1. Configure the report.
  2. Use the API to generate the report.

Configure Report

  1. Login to the dashboard, and create the report using the report builder. For more information, refer to Advanced Reports.
  2. In step 3 of the Campaign Report Builder, select the time at which the report should be generated.
  3. Select the Send report as REST API to download the report using the API. Use the REST API method to generate campaign reports using API instead of receiving an email.

0e1a284-CampaignReportBuilder.png

API Endpoint

URL
GET https://api-0X.moengage.com/campaign_reports/rest_api/[APP ID]/[FILENAME]

The 'X' in the API Endpoint URL refers to the MoEngage Data Center (DC). MoEngage hosts each customer in a different DC. 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.

Parameter Description
APP ID The APP ID is displayed as APP Settings on the dashboard.
FILENAME

File name is a combination of:

  1. The report name is the same as the report name created in the Campaign Report Builder with space replaced by underscores. For example, the file name on the dashboard is *Report test*, then the file name for the API is *Report_test*.
  2. Report generation date in YYYYMMDD format. For example, 20210217 in the name contains the report generated on 17/02/2021.
  3. Compression format such as *.zip*Final report name, for example, is Report_test_20210217.zip

Request Headers

Generate a unique signature, passed as a GET parameter, to verify the authenticity of the caller and the validity of the request. The signature is a combination of APP ID, FILENAME, and SECRET-KEY.
To get the SECRET-KEY

  1. Navigate to MoEngage dashboard > Settings > APIs.
  2. In the General tab, under Transaction Push/Report Settings, click Click here to show APP secret! in API Secret.

Response

Successful API requests automatically download the report file.
Failure of API request results in JSON Response explaining the reason for failure.

Response Code Content Type Response Description
200 application/gzip   Successful API request automatically downloads the report file.
400 application/json {
"error": {
"attribute": "",
"message": "error message",
"type": "BAD REQUEST",
"request_id": ""
}
}
Any of the following reasons:
1. Invalid Report file name/ file name format
2. Requested report if older than 7 days.
3. Incorrect App Id
401 application/json empty body Invalid Signature/Signature Missing

Example

The following is the sample API :

Text
https://api.moengage.com/campaign_reports/rest_api/<APP ID>/Report_-_test_20210217.zip Headers: Signature: 80300f554f9dc88cdc7d64c6c06f4de580b27a2afcc396816d1ec3a8d1c09579

Sample Signature Python

Python
# SAMPLE IMPLEMENTATION IN PYTHON
from hashlib import sha256
Api_ID = "YOUR-APP-ID"
FILENAME = "Report_-_test_20210217.zip"
SECRET_KEY = "YOUR-SECRET-KEY"
Signature_Key = Api_ID + "|" + FILENAME + "|" + SECRET_KEY
# Now Signature is hexdigest of sha256 of Signature_Key
Signature = sha256(Signature_Key).hexdigest() 

Import APIs for Postman

We have made it easy for you to test the APIs.
Click here to export our Campaign Report APIs into your Postman collections.

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

How can we improve this article?