openapi: 3.2.0 info: title: MoEngage Campaign Stats and Reports Campaign Reports API description: "The Stats API allows you to fetch detailed campaign stats synchronized in real time. \nThe Campaign Report API allows you to download campaign reports for any specific date range.\n" version: '1.0' servers: - url: https://api-{dc}.moengage.com description: MoEngage API Server variables: dc: default: '01' description: The ‘dc’ 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 and replace the value of ‘dc’ in the URL by referring to the DC and API endpoint mapping [here](/api/introduction#data-centers). Your MoEngage Data Center (DC) can be 01, 02, 03, 04, 05, 06, or 101. tags: - name: Campaign Reports description: Download campaign report files. paths: /campaign_reports/rest_api/{APP_ID}/{FILENAME}: get: tags: - Campaign Reports summary: Download Campaign Report description: 'This API downloads campaign reports for any specific date range. You can fetch reports for one-time and periodic campaigns. ' x-mint: content: "#### Limits\n\n- **Expiry**: The generated reports will expire in **7 days** from the date of creation.\n- **Max Range**: You can generate reports for up to **90 days**.\n\n#### Generating the Signature\nA unique signature must be passed in the headers to verify the caller's authenticity. \n\nThe signature is `SHA256(Api_ID + \"|\" + FILENAME + \"|\" + SECRET_KEY)`.\n\n```python\n# SAMPLE IMPLEMENTATION IN PYTHON\nfrom hashlib import sha256\nApi_ID = \"YOUR-APP-ID\"\nFILENAME = \"Report_-_test_20210217.zip\"\nSECRET_KEY = \"YOUR-SECRET-KEY\"\nSignature_Key = Api_ID + \"|\" + FILENAME + \"|\" + SECRET_KEY\n# Now Signature is hexdigest of sha256 of Signature_Key\nSignature = sha256(Signature_Key.encode('utf-8')).hexdigest()\n```\n" operationId: downloadCampaignReport security: - apiKeySignature: [] parameters: - name: APP_ID in: path required: true schema: type: string description: 'This is the Workspace ID of your MoEngage account that must be passed with the request. You can find it in the MoEngage dashboard at **Settings** > **Account** > **APIs** > **Workspace ID (earlier app id)**. ' example: YOUR-APP-ID - name: FILENAME in: path required: true schema: type: string description: 'The name of the report file to download. It is a combination of report name, generation date, and file format. Example: `Report_test_20210217.zip` ' example: Report_-_test_20210217.zip - name: Signature in: header required: true schema: type: string description: A custom signature generated by SHA256(Api_ID + "|" + FILENAME + "|" + SECRET_KEY). example: 80300f554f9dc88cdc7d64c6c06f4de580b27a2afcc396816d1ec3a8d1c09579 responses: '200': description: Successful API request automatically downloads the report file. content: application/gzip: schema: type: string format: binary '400': description: '**Bad Request** Reasons: Invalid Report file name, requested report is older than 7 days, or incorrect App Id. ' content: application/json: schema: $ref: '#/components/schemas/ErrorResponseCampaignReport' '401': description: Unauthorized. Invalid Signature or Signature Missing. content: application/json: schema: type: object description: Empty body. components: schemas: ErrorResponseCampaignReport: type: object properties: error: type: object properties: attribute: type: string message: type: string type: type: string example: BAD REQUEST request_id: type: string securitySchemes: basicAuth: type: http scheme: basic description: 'Authentication is done via Basic Auth. This requires a base64-encoded string of your credentials in the format ''username:password''. - **Username**: Use your MoEngage workspace ID (also known as the App ID). You can find it in the MoEngage dashboard at **Settings** > **Account** > **APIs** > **Workspace ID (earlier app id)**. - **Password**: Use your API Key, which you can find within the **Campaign report/Business events/Custom templates/Catalog API/Inform Report** tile. For more information on authentication and getting your credentials, refer [here](https://www.moengage.com/docs/api/introduction#getting-your-credentials). ' apiKeySignature: type: apiKey in: header name: Signature description: 'Custom SHA256 Signature. Refer [here](/api/campaign-reports/download-campaign-report#generating-the-signature). '