> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Download Campaign Report

> This API downloads campaign reports for any specific date range. You can fetch reports for one-time and periodic campaigns.


#### Limits

* **Expiry**: The generated reports will expire in **7 days** from the date of creation.
* **Max Range**: You can generate reports for up to **90 days**.

#### Generating the Signature

A unique signature must be passed in the headers to verify the caller's authenticity.

The signature is `SHA256(Api_ID + "|" + FILENAME + "|" + SECRET_KEY)`.

```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()
```


## OpenAPI

````yaml /api/stats-report/stats-report.yaml get /campaign_reports/rest_api/{APP_ID}/{FILENAME}
openapi: 3.0.3
info:
  title: MoEngage Campaign Stats and Reports API
  description: >
    The Stats API allows you to fetch detailed campaign stats synchronized in
    real time. 

    The Campaign Report API allows you to download campaign reports for any
    specific date range.
  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.
security: []
tags:
  - name: Stats
    description: Fetch detailed, real-time campaign statistics.
  - 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.
      operationId: downloadCampaignReport
      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.
      security:
        - apiKeySignature: []
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:
    apiKeySignature:
      type: apiKey
      in: header
      name: Signature
      description: >
        Custom SHA256 Signature. Refer
        [here](/api/campaign-reports/download-campaign-report#generating-the-signature).

````