Get Campaigns

Overview

The Get Campaigns API lets you get a list of campaigns created using the API.

Base URL

Here is an example base URL from the account in the India region:
https://in1.api.clevertap.com/1/targets/list.json

Region

Refer Region for more details.

HTTP Method

GET

Headers

Refer Headers for more details.

Body Parameters

The body is uploaded as a JSON payload.
Will return campaigns which have start time between the the date range.

Parameter

Description

Type

Example Value

from

Start of date range for events needed. Value specified in format YYYYMMDD.

int

20171201

to

End of date range for events needed. Value specified in format YYYYMMDD.

int

20171225

Below is an example payload.

{
    "from": 20160101,
    "to": 20160101
}

Example Request

Here is an example cURL request to the Get Campaigns API showing the headers needed to authenticate the request from the account in the India region:

curl -X POST -d '{"from": 20160101,"to": 20160101}' "https://in1.api.clevertap.com/1/targets/list.json" \
-H "X-CleverTap-Account-Id: ACCOUNT_ID" \
-H "X-CleverTap-Passcode: PASSCODE" \
-H "Content-Type: application/json"
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://in1.api.clevertap.com/1/targets/list.json")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request["X-Clevertap-Account-Id"] = "ACCOUNT_ID"
request["X-Clevertap-Passcode"] = "PASSCODE"
request.body = JSON.dump({
  "from" => 20160101,
  "to" => 20160101
})

req_options = {
  use_ssl: uri.scheme == "https",
}

response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(request)
end
import requests

headers = {
    'X-CleverTap-Account-Id': 'ACCOUNT_ID',
    'X-CleverTap-Passcode': 'PASSCODE',
    'Content-Type': 'application/json',
}

data = '{"from": 20160101,"to": 20160101}'

response = requests.post('https://in1.api.clevertap.com/1/targets/list.json', headers=headers, data=data)
<?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 = '{"from": 20160101,"to": 20160101}';
$response = Requests::post('https://in1.api.clevertap.com/1/targets/list.json', $headers, $data);
var request = require('request');

var headers = {
    'X-CleverTap-Account-Id': 'ACCOUNT_ID',
    'X-CleverTap-Passcode': 'PASSCODE',
    'Content-Type': 'application/json'
};

var dataString = '{"from": 20160101,"to": 20160101}';

var options = {
    url: 'https://in1.api.clevertap.com/1/targets/list.json',
    method: 'POST',
    headers: headers,
    body: dataString
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);

Example Response

{
    "status": "success",
    "targets": [
        {
            "id": 1457429935,
            "name": "My API Campaign",
            "scheduled_on": 201703081508,
            "status": "pending"
        },
        {
            "id": 1457432766,
            "name": "My API Campaign 2",
            "scheduled_on": 201603081556,
            "status": "completed"
        }
    ]
}

For more information on rate limit, refer to API Rate Limit.