×

To get the details of a specific campaign in your account, make an HTTP GET request to:

GET

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/campaigns/<id>

Replace <your_api_key> and <your_api_token> with the API key and token created by you. Similarly, replace <your_sid> with your “Account sid” value. These values are available in the API settings page of your Exotel Dashboard. Replace <id> with the campaign id.

curl -X GET https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/campaigns/<id>
var request = require("request");
var accountSid = "XXXXXXXXX";
var accountToken = "YYYYYYYYY";
var authKey = "ZZZZZZZZZZ";

var encoding = Buffer.from(authKey + ':' + accountToken).toString('base64')
var options = { method: 'GET',
  url: 'https://api.exotel.com/v2/accounts/'+ accountSid +'/campaigns/491dd6c97d64475ba0ce346a18530ce5',
  headers: 
   { 
     Authorization: 'Basic ' + encoding 
    } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
  
});
<?php
$curl = curl_init();
$accountSid = "XXXXXXXXXX";
$accountToken = "YYYYYYYYYY";
$authKey = "ZZZZZZZZZZ";

$encoding = base64_encode($authKey .":". $accountToken);
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.exotel.com/v2/accounts/".$accountSid."/campaigns/491dd6c97d64475ba0ce346a18530ce5",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic ".$encoding
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
    
import requests, base64, json
accountSid = "XXXXXXXXX"
authToken = "YYYYYYYYY"
authKey = "ZZZZZZZZZZ"

encoding = base64.b64encode(authKey + ":" + authToken)

url = "https://api.exotel.com/v2/accounts/"+ accountSid +"/campaigns/491dd6c97d64475ba0ce346a18530ce5"

payload = ""
headers = {
    'Authorization': "Basic " + encoding
    }

response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
print(json.dumps(json.loads(response.text), indent = 4, sort_keys = True))
package main

import (
	b64 "encoding/base64"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {

	// Please provide accountSid, authToken from your Exotel account
	accountSid := "XXXXXXXXX"
	authToken := "YYYYYYYY"
	authKey := "ZZZZZZZZZZ"

	// Encoding the accountSid and authToken, used in Authorization header
	encoding := b64.StdEncoding.EncodeToString([]byte(authKey + ":" + authToken))

	url := "https://api.exotel.com/v2/accounts/" + accountSid + "/campaigns/491dd6c97d64475ba0ce346a18530ce5"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Basic "+encoding)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))
}

HTTP Response:

  • On success, the HTTP response status code will be 200
  • HTTP body will contain an JSON similar to the one below
  • Response parameters are described above
"request_id": "4ab25b37b89447cb8e1c7d527ae98d2e",
"method": "GET",
"http_code": 200,
"metadata": {
"count": 0,
"offset": 0,
"total": 0,
"limit": 20
},
"response": [
{
"code": 200,
"error_data": null,
"status": "success",
"data": {
"id": "59beaff7d1c887e877a3b5942bc389fd1688",
"account_sid": "Exotel",
"name": "Exotel_2022-08-08 16:33:22",
"type": "trans",
"caller_id": "0XXXX83280",
"campaign_type": "dynamic",
"read_via_text": "Hi @@Name @@Last name , your order ID is @@Order ID . Press 1 to proceed, press 2 to abort",
"repeat_menu_attempts": 0,
"flow_type": "ivr",
"lists": [
"b7799a24becf436da672163858e8165d"
],
"url": "http://my.exotel.com/Exotel/exoml/start_voice/528696",
"retries": {
"number_of_retries": 1,
"interval_mins": 1,
"mechanism": "Exponential",
"on_status": [
"failed",
"busy"
]
},
"schedule": {
"send_at": "2022-08-08T16:34:23+05:30",
"end_at": "2022-09-07T16:34:23+05:30"
},
"status_callback": "https://webhook.site/59590860-f765-499c-bf45-47e14676b1f1",
"call_status_callback": "https://webhook.site/59590860-f765-499c-bf45-47e14676b1f1",
"call_schedule_callback": "https://webhook.site/59590860-f765-499c-bf45-47e14676b1f1",
"custom_field": "{"name": "yo"}",
"date_created": "2022-08-08T16:33:23+05:30",
"date_updated": "2022-08-08T16:40:42+05:30",
"status": "Completed",
"report_url": "https://campaigns-reports.s3.ap-southeast-1.amazonaws.com/59beaff7d1c887e877a3b5942bc389fd1688.csv",
"call_status_callback_params": null,
"call_duplicate_numbers": false,
"stats": {
"created": 0,
"in-progress": 0,
"retry": 0,
"retrying": 0,
"failed": 0,
"failed-dnd": 0,
"invalid": 0,
"paused": 0,
"failed-no-attempt": 0,
"completed": 2,
"pending": 0
},
"mode": "auto"
},
"summary": {
"campaign_sid": "59beaff7d1c887e877a3b5942bc389fd1688",
"call_scheduled": 0,
"call_initialized": 2,
"call_completed": 2,
"call_failed": 0,
"call_inprogress": 0,
"DateCreated": "2022-08-08T16:33:23+05:30"
}
}
]
}