Get Campaigns API

Overview

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

Base URL

https:// <clevertap region>.api.clevertap.com/1/targets/list.jsonz

📘

Note

The region for a specific CleverTap account can be found under Project in Settings.

The image below represents the section where one can find the Region for their respective account.

The following table lists down the API endpoint for the region of your account:

Headers

These headers are all required. The X-CleverTap-Account-Id and X-CleverTap-Passcode are used to authenticate the request. Please see the authentication guide to see how to get their values.*

Header

Description

Type

Example Value

X-CleverTap-Account-Id

Your CleverTap Account ID.

string

"X-CleverTap-Account-Id: ACCOUNT_ID"

X-CleverTap-Passcode

Your CleverTap Account Passcode.

string

"X-CleverTap-Passcode: PASSCODE"

Content-Type

Request content-type is always set to application/json.

string

"Content-Type: application/json"

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

curl -X POST -d '{"from": 20160101,"to": 20160101}' "https://location.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://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://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://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://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"
        }
    ]
}

Did this page help you?