Download Campaign Report
curl --request GET \
--url https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME} \
--header 'Signature: <api-key>'import requests
url = "https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}"
headers = {"Signature": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Signature: '<api-key>'}};
fetch('https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Signature: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Signature", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}")
.header("Signature", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Signature"] = '<api-key>'
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"attribute": "<string>",
"message": "<string>",
"type": "BAD REQUEST",
"request_id": "<string>"
}
}{}Campaign Report and Stats
Download Campaign Report
Campaign Report API lets you download campaign reports for any specific date range. You can fetch reports for one-time and periodic campaigns.
Important: Successful API requests automatically download the report file.
GET
/
campaign_reports
/
rest_api
/
{APP_ID}
/
{FILENAME}
Download Campaign Report
curl --request GET \
--url https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME} \
--header 'Signature: <api-key>'import requests
url = "https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}"
headers = {"Signature": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Signature: '<api-key>'}};
fetch('https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Signature: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Signature", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}")
.header("Signature", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-0{dc}.moengage.com/campaign_reports/rest_api/{APP_ID}/{FILENAME}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Signature"] = '<api-key>'
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"attribute": "<string>",
"message": "<string>",
"type": "BAD REQUEST",
"request_id": "<string>"
}
}{}Generating the Signature
A unique signature must be passed in the headers to verify the caller’s authenticity. The signature isSHA256(Api_ID + "|" + FILENAME + "|" + SECRET_KEY).
# 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()
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.
Authorizations
Custom SHA256 Signature.
Headers
A custom signature generated by SHA256(Api_ID + "|" + FILENAME + "|" + SECRET_KEY).
Path Parameters
Your MoEngage App ID (Workspace ID). Can be fetched from Settings > Account > APIs.
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
Response
Successful API request automatically downloads the report file.
The response is of type file.
Was this page helpful?