This API allows you to fetch bulk campaign details with sorting and searching capabilities.
https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/campaigns
This API only supports a JSON response.
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.
The following are the Query parameters:
Parameter Name | Mandatory/Optional | Value |
offset |
Optional |
This is the position in the dataset of a particular record. By specifying offset, you retrieve a subset of records starting with the offset value. Offset is zero-based i.e. the 10th record is at offset 9 |
limit |
Optional |
number of records on single page default:20 maximum=500 |
name |
Optional |
Search on Campaign name |
status |
Optional |
This will respect given statuses. By default all records will be populated of all status. However, you can filter on set of status too. eg, status=in-progress, created |
sort_by |
Optional |
This indicates in what order the campaign records are sorted in the API response. By default records are sorted by DateCreated in ascending order. However, you can override the same in following way for ascending order: Eg: date_created:asc or name:asc |
type | Optional |
It's an optional parameter in the request but mandatory in the response. It's allowed (and default) value is 'trans'. If not passed in the request, we will create campaign as type 'trans' and pass this parameter in the API response. As per regulations, we support only transactional type of campaigns. |
curl https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/campaigns?offset=0&status=Created,Completed&limit=3
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?offset=0&status=Created,Completed&limit=3', 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?offset=0&status=Created,Completed&limit=3", 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?offset=0&status=Created,Completed&limit=3" payload = "" headers = { 'Authorization': "Basic " + encoding } response = requests.request("DELETE", 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?offset=0&status=Created,Completed&limit=3" 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)) }
{ "request_id": "c2cedb1eabb4472da3a6fe4802607410", "method": "GET", "http_code": 207, "metadata": { "count": 3, "offset": 0, "total": 138, "limit": 3 }, "response": [ { "code": 200, "error_data": null, "status": "success", "data": { "id": "046141c8f6edde79938e69af34e560ef156l", "account_sid": "<your_sid>", "name": "<your_sid>_2021-06-21 22:28:47", "type": "trans", "from": [ "9900000017" ], "caller_id": "03349360005", "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/4", "retries": { "number_of_retries": 1, "interval_mins": 1, "mechanism": "Exponential", "on_status": [ "failed", "busy", "no-answer" ] }, "schedule": { "send_at": "2021-06-21T22:29:47+05:30", "end_at": "2021-07-21T22:29:47+05:30" }, "status_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "call_status_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "call_schedule_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "custom_field": "{"name": "time"}", "date_created": "2021-06-21T22:28:47+05:30", "date_updated": "2021-06-21T22:35:54+05:30", "status": "Completed", "uri": "/v2/accounts/<your_sid>/campaigns/046141c8f6edde79938e69af34e560ef156l", "report_url": "https://campaigns-reports-qa-us3.s3.us-west-2.amazonaws.com/046141c8f6edde79938e69af34e560ef156l.csv", "call_status_callback_params": null, "call_duplicate_numbers": true, "stats": { "created": 0, "in-progress": 0, "retry": 0, "retrying": 0, "failed": 0, "failed-dnd": 0, "invalid": 0, "paused": 0, "failed-no-attempt": 0, "completed": 1 } }, "summary": { "campaign_sid": "046141c8f6edde79938e69af34e560ef156l", "call_scheduled": 1, "call_initialized": 1, "call_completed": 1, "call_failed": 0, "call_inprogress": 0, "DateCreated": "2021-06-21T22:28:47+05:30" } }, { "code": 200, "error_data": null, "status": "success", "data": { "id": "391db1c6f28ca06273ba200221767fe3156l", "account_sid": "<your_sid>", "name": "<your_sid>_2021-06-21 21:58:43", "type": "trans", "from": [ "9900000017" ], "caller_id": "03349360005", "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/4", "retries": { "number_of_retries": 1, "interval_mins": 1, "mechanism": "Exponential", "on_status": [ "failed", "busy", "no-answer" ] }, "schedule": { "send_at": "2021-06-21T21:59:43+05:30", "end_at": "2021-07-21T21:59:43+05:30" }, "status_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "call_status_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "call_schedule_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "custom_field": "{"name": "time"}", "date_created": "2021-06-21T21:58:43+05:30", "date_updated": "2021-06-21T21:58:43+05:30", "status": "Created", "uri": "/v2/accounts/<your_sid>/campaigns/391db1c6f28ca06273ba200221767fe3156l", "call_status_callback_params": null, "call_duplicate_numbers": true, "stats": { "created": 0, "in-progress": 0, "retry": 0, "retrying": 0, "failed": 0, "failed-dnd": 0, "invalid": 0, "paused": 0, "failed-no-attempt": 0, "completed": 0 } }, "summary": { "campaign_sid": "391db1c6f28ca06273ba200221767fe3156l", "call_scheduled": 0, "call_initialized": 0, "call_completed": 0, "call_failed": 0, "call_inprogress": 0, "DateCreated": "2021-06-21T21:58:43+05:30" } }, { "code": 200, "error_data": null, "status": "success", "data": { "id": "cff6e2d08f563dc358a9c565e10cd9d3156l", "account_sid": "<your_sid>", "name": "<your_sid>_2021-06-21 21:47:41", "type": "trans", "from": [ "9900000017" ], "caller_id": "03349360005", "url": "https://my.exotel.com/<your_sid>/exoml/start_voice/4", "retries": { "number_of_retries": 1, "interval_mins": 1, "mechanism": "Exponential", "on_status": [ "failed", "busy", "no-answer" ] }, "schedule": { "send_at": "2021-06-21T21:48:42+05:30", "end_at": "2021-07-21T21:48:42+05:30" }, "status_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "call_status_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "call_schedule_callback": "https://webhook.site/65022bd9-a447-4ab8-975a-6ce2bd504843", "custom_field": "{"name": "time"}", "date_created": "2021-06-21T21:47:42+05:30", "date_updated": "2021-06-21T21:47:42+05:30", "status": "Created", "uri": "/v2/accounts/<your_sid>/campaigns/cff6e2d08f563dc358a9c565e10cd9d3156l", "call_status_callback_params": null, "call_duplicate_numbers": true, "stats": { "created": 0, "in-progress": 0, "retry": 0, "retrying": 0, "failed": 0, "failed-dnd": 0, "invalid": 0, "paused": 0, "failed-no-attempt": 0, "completed": 0 } }, "summary": { "campaign_sid": "cff6e2d08f563dc358a9c565e10cd9d3156l", "call_scheduled": 0, "call_initialized": 0, "call_completed": 0, "call_failed": 0, "call_inprogress": 0, "DateCreated": "2021-06-21T21:47:42+05:30" } } ] }