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:
Configure Report
- 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.
API Endpoint
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:
|
Request Headers
Generate a unique signature, passed as a GET parameter, to verify the caller's authenticity and the request's validity. The signature is a combination of the APP ID, FILENAME, and SECRET-KEY.
We've revamped the settings UI in the Dashboard. The SECRET-KEY is available in the following navigations in the revamped and old UIs:
Revamped UI
- Navigate to Settings -> Account -> APIs.
- The SECRET KEY is available in the Campaign report/Business events/Custom templates tile in the API Keys section. Click on the copy icon to copy the key.
- Use the App ID as the username and the Campaign report API Key as the password to generate the authentication header.
Old UI
- 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.
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 :
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.encode('utf-8')).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.