Get Campaign Report
Overview
The Get Campaign Report API retrieves metrics and metadata for a specific campaign.
- Supports all campaign types (Push, Email, SMS, In-App, Web, etc.).
- You must provide the
idof the campaign. - If the campaign has not completed, the API returns an error indicating its status.
Use Cases
- Integrate campaign reports into analytics dashboards.
- Track delivery, click, and conversion metrics.
- Monitor campaign health and optimize performance.
- Automate reporting workflows.
Base URL
The sample base URL for the India region:
https://in1.api.clevertap.com/1/targets/result.json
Refer to Region for more details.
Authentication
Authentication is required using the account ID and passcode headers.
Headers
| Header | Description | Required | Example |
|---|---|---|---|
X-CleverTap-Account-Id | Your CleverTap account ID. | Yes | ABCD-RSTU-1234 |
X-CleverTap-Passcode | Passcode generated for the account to authenticate API requests. | Yes | XXXXXX |
Content-Type | Content type of the request payload. Must be application/json. | Yes | application/json |
HTTP Method
POST
Body Parameters
The following table lists the body parameters:
| Parameter | Description | Type | Example Value | Required |
|---|---|---|---|---|
id | The CleverTap campaign ID of the campaign whose report you want. Applies to all campaign types. You can find this ID in the CleverTap Dashboard under each campaign, or via the Get Campaigns API. | Integer | 1457432766 | Yes |
Sample Payload
The following is the sample payload:
{
"id": 1457432766
}
Example Request
The following is the sample request:
curl -X POST \
"https://in1.api.clevertap.com/1/targets/result.json" \
-H "X-CleverTap-Account-Id: ACCOUNT_ID" \
-H "X-CleverTap-Passcode: PASSCODE" \
-H "Content-Type: application/json" \
-d '{
"id": 1457432766
}'
require 'net/http'
require 'json'
require 'uri'
uri = URI("https://in1.api.clevertap.com/1/targets/result.json")
request = Net::HTTP::Post.new(uri)
request["X-CleverTap-Account-Id"] = "ACCOUNT_ID"
request["X-CleverTap-Passcode"] = "PASSCODE"
request["Content-Type"] = "application/json"
request.body = { id: 1457432766 }.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
import requests
url = "https://in1.api.clevertap.com/1/targets/result.json"
headers = {
"X-CleverTap-Account-Id": "ACCOUNT_ID",
"X-CleverTap-Passcode": "PASSCODE",
"Content-Type": "application/json",
}
payload = { "id": 1457432766 }
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
print("Report:", response.json())
else:
print("Error:", response.text)
const axios = require("axios");
const url = "https://in1.api.clevertap.com/1/targets/result.json";
const headers = {
"X-CleverTap-Account-Id": "ACCOUNT_ID",
"X-CleverTap-Passcode": "PASSCODE",
"Content-Type": "application/json",
};
const data = { id: 1457432766 };
axios.post(url, data, { headers })
.then((res) => console.log("Report:", res.data))
.catch((err) => console.error("Error:", err.response?.data || err.message));
<?php
include('vendor/rmccue/requests/library/Requests.php');
Requests::register_autoloader();
$headers = array(
'X-CleverTap-Account-Id' => 'ACCOUNT_ID',
'X-CleverTap-Passcode' => 'PASSCODE',
'Content-Type' => 'application/json'
);
$data = json_encode(array("id" => 1457432766));
$response = Requests::post(
'https://in1.api.clevertap.com/1/targets/result.json',
$headers,
$data
);
echo $response->body;
?>
Example Response
The following are the sample response:
{
"status": "success",
"result": {
"sent": 82,
"delivered": 80,
"clicked": 28,
"bounced": 2,
"unsubscribed": 1,
"opened": 40,
"converted": 5
},
"metadata": {
"campaign_id": 1457432766,
"campaign_name": "My Campaign",
"campaign_type": "push",
"created_at": "2025-03-01T10:00:00Z",
"completed_at": "2025-03-01T12:00:00Z",
"last_updated": "2025-03-01T12:05:00Z"
}
}
Response Parameters
The following are the response parameters:
| Field | Description | Type |
|---|---|---|
sent | Number of messages attempted to be sent. | Integer |
delivered | Number of messages successfully delivered. | Integer |
clicked | Number of users who clicked the message (push, email, SMS with links). | Integer |
opened | Number of users who opened the message (applies to email). | Integer |
bounced | Number of messages that failed due to invalid addresses or delivery issues. | Integer |
unsubscribed | Number of users who unsubscribed after receiving the message. | Integer |
converted | Number of users who completed a conversion event attributed to the campaign. | Integer |
metadata | Contains campaign metadata like name, type, and timestamps. | Object |
Notes
- Metrics are integers and cannot be negative.
- Reports are finalized only after campaign completion.
- For recurring campaigns, reports are available per instance.
- If no data is available, fields may be omitted or set to
null.
Error Codes
The following are the error codes:
| HTTP Status | Error Code | Description | Example JSON Payload |
|---|---|---|---|
| 200 | success | Request successful and metrics returned. | {"status":"success","result":{"sent":82}} |
| 400 | invalid_payload | Malformed request body or missing id. | {"status":"fail","error":"Missing campaign id","code":400} |
| 400 | invalid_id_format | The campaign ID is not a valid integer. | {"status":"fail","error":"Invalid campaign id format","code":400} |
| 401 | unauthorized | Authentication failed due to missing/invalid credentials. | {"status":"fail","error":"Invalid Credentials","code":401} |
| 403 | forbidden | The account does not have permission to use this API. | {"status":"fail","error":"Forbidden","code":403} |
| 404 | report_not_found | Campaign ID does not exist or no report available. | {"status":"fail","error":"Report not found","code":404} |
| 409 | campaign_not_completed | The campaign has not completed, so report cannot be generated. | {"status":"fail","error":"This target hasn't been completed""code":404} |
| 429 | rate_limit_exceeded | Too many requests made in a short time. Limit: 60 requests/min per campaign. For more information, refer to API Request Limit. | {"status":"fail","error":"Rate limit exceeded","code":429} |
| 500 | internal_error | Unexpected error occurred on the server. | {"status":"fail","error":"Internal server error","code":500} |
Limitations
- Only one campaign ID can be requested per call.
- Bulk report retrieval is not supported.
- Recommended polling interval: once every 1–5 minutes per campaign.
- Reports are updated in near real-time but finalized only after completion.
Updated 13 days ago
