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:
- Login to the dashboard, and create the report using the report builder. For more information, refer to Advanced Reports.
- In step 3 of the Campaign Report Builder, select the time at which the report should be generated.
- 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.
GET https://api-0X.moengage.com/campaign_reports/rest_api/[APP ID]/[FILENAME]
MoEngage hosts each customer in a different data center; you can find your data center number (value of X) by checking the data center and API endpoint mapping here. Replace the value of 'X' in the endpoint URL based on your DataCenter.
|APP ID||The APP ID is displayed as APP Settings on the dashboard.|
File name is a combination of:
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
- Navigate to MoEngage dashboard > Settings > APIs.
- In the General tab, under Transaction Push/Report Settings, click Click here to show APP secret! in API Secret.
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.|
"message": "error message",
"type": "BAD REQUEST",
|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|
The following is the sample API :
https://api.moengage.com/campaign_reports/rest_api/<APP ID>/Report_-_test_20210217.zip Headers: Signature: 80300f554f9dc88cdc7d64c6c06f4de580b27a2afcc396816d1ec3a8d1c09579
Sample Signature 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.