×

Create SMS Campaign Beta

POST

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

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

<your_api_key> , <your_api_token> and <your_sid> are available in the API settings page of your Exotel Dashboard

The following are the POST parameters:

Parameter Name   Mandatory/Optional Value

name

optional

It's an optional parameter in the request. It is used to define the name of the campaign. It should be greater than 3 characters and if not passed, its default value will be created using the 'AccountSID CurrentDate CurrentTime' and passed in the response.

Example: exotel 2021-06-04 11:11:10

content_type

Mandatory

dynamic or static

choose static, if you want to use the same sms body for all the audience.

choose dynamic, if you want to personalized sms based on the data provided in the list

lists Mandatory

Array of listSid, if content_type=static. Up to 5 listSid can be part of one single campaign. 

Single listsid, if content_type=dynamic

channel Mandatory

SMS

schedule Optional

Determines when to start and end a campaign in RFC 3339 date-time

  • start_time - Time when the campaign should start. start_time should be atleast 10 mins ahead of current time.  
  • end_time - Time when the campaign should end even if all sms are not attempted as part of the campaign. There has to be min 2 hours gap between start_time and end_time. 

dlt_entity_id

Mandatory

Numeric Value

dlt_template_id

Mandatory

Numeric Value ( Provide DLT approved Template ID)

sender_id

Mandatory

Alphabetical string ( tansactional)

Numeric ( Promotional )

sms_type

Mandatory

Transactional/Promotional

template

Mandatory

Body of the Sms (Max 2000 char)

Please provide DLT approved SMS template. Replace the variable with @column_header. For example: let's assume the template is " Hi %var, your account is activated" and you want to replace the variable with First_Name ( which is a column name in the list). You can replace the variable by prefix @ @before the Column name like- "Hi @@First_name, your account is activated". Make sure that the variable name should be exactly the same with the column header. You can replace up to 5 variables.

status_callback

optional

Valid http/https url at the campaign level

When a SMS campaign will start or completed, an HTTP POST will be made to the provided URL with the following four parameters:

  • campaign_sid-an alpha-numeric unique identifier of this campaign
  • date_created- ime when the campaign was created
  • date_updated-  time when the campaign was updated
  • status- one of in-progress OR completed 
  • reports- link to the campaign reports ( null when the status is not completed)

sms_status_callback

optional

Valid http/https url at the sms level

Once SMS reaches terminal state (sent/failed/failed_dnd),  an HTTP POST will be made to the provided URL with the following four parameters:

  • campaign_sid - an alpha-numeric unique identifier of this campaign
  • sms_sid - an alpha-numeric unique identifier of this call
  • date_created - time when the resource was created
  • date_sent - time when the resource was updated
  • number - number to which the SMS was made
  • status -submitted, sent/ failed, Failed_Expired 
curl --location --request POST 'https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns'  
--header 'Content-Type: application/json'  
--data-raw '{ "name": "CampaignABC",
 "content_type": "static",
 "lists": [ "9120d5962d214316b7721de55bb82e03" ],
 "schedule": 
{"start_time": "2022-01-13T13:13:00+05:30", 
"end_time": "2022-01-13T13:16:00+05:30"
 }, 
"dlt_template_id": "1107160086562376233", 
"dlt_entity_id": "1101428740000012125",
 "sender_id": "EXOTEL", 
"channel": "SMS",
"sms_type": "transactional",
 "template": "Prepaid rental charges for the billing cycle starting
 today have been deducted from your Exotel account. 
Your Exotel account balance is now Rs.100. Thank you.", 
"status_callback": "https://webhook.site/9402df04-f971-4a07-9992-27dc042b1c72" 
}'
var request = require('request');

var options = {

'method': 'POST',

'url': 'https://api.exotel.com/v2/accounts/Exotel/message-campaigns',

'headers': {

'Content-Type': 'application/json',

},

body: JSON.stringify({

"smscampaigns": {

"name": "CampaignABC",

"content_type": "static",

"lists": [

"9120d5962d214316b7721de55bb82e03"

],

"schedule": {

"start_time": "2022-01-13T13:13:00+05:30",

"end_time": "2022-01-13T13:16:00+05:30"

},

"dlt_template_id": "1107160086562376233",

"dlt_entity_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS",

"sms_type": "transactional",

"template": "Prepaid rental charges for the billing cycle starting today have been deducted from your Exotel account. Your Exotel account balance is now Rs.100. Thank you.",

"status_callback": "https://webhook.site/9402df04-f971-4a07-9992-27dc042b1c72"

}

})




};

request(options, function (error, response) {

if (error) thrownewError(error);

console.log(response.body);

});


<?php

$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => 'https://api.exotel.com/v2/accounts/Exotel/message-campaigns',

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => '',

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => true,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => 'POST',

CURLOPT_POSTFIELDS =>' {

"smscampaigns": {

"name": "CampaignABC",

"content_type": "static",

"lists":[

"9120d5962d214316b7721de55bb82e03"

],

"schedule": {

"start_time": "2022-01-13T13:13:00+05:30",

"end_time": "2022-01-13T13:16:00+05:30"

},

"dlt_template_id" : "1107160086562376233",

"dlt_entity_id" : "1101428740000012125",

"sender_id" : "EXOTEL",

"channel": "SMS",

"sms_type": "transactional",

"template" : "Prepaid rental charges for the billing cycle starting today have been deducted from your Exotel account. Your Exotel account balance is now Rs.100. Thank you.",

"status_callback" : "https://webhook.site/9402df04-f971-4a07-9992-27dc042b1c72"

}

}

',

CURLOPT_HTTPHEADER => array(

'Content-Type: application/json',

),

));




$response = curl_exec($curl);




curl_close($curl);

echo $response;
import requests

import json

url = "https://api.exotel.com/v2/accounts/Exotel/message-campaigns"

payload = json.dumps({

"smscampaigns": {

"name": "CampaignABC",

"content_type": "static",

"lists": [

"9120d5962d214316b7721de55bb82e03"

],

"schedule": {

"start_time": "2022-01-13T13:13:00+05:30",

"end_time": "2022-01-13T13:16:00+05:30"

},

"dlt_template_id": "1107160086562376233",

"dlt_entity_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS",
"sms_type": "transactional",

"template": "Prepaid rental charges for the billing cycle starting today have been deducted from your Exotel account. Your Exotel account balance is now Rs.100. Thank you.",

"status_callback": "https://webhook.site/9402df04-f971-4a07-9992-27dc042b1c72"

}

})

headers = {

'Content-Type': 'application/json',

}




response = requests.request("POST", url, headers=headers, data=payload)




print(response.text)


package main

import (

"fmt"

"strings"

"net/http"

"io/ioutil"

)




func main() {




url := "https://api.exotel.com/v2/accounts/Exotel/message-campaigns"

method := "POST"




payload := strings.NewReader(` {

"smscampaigns": {

"name": "CampaignABC",

"content_type": "static",

"lists":[

"9120d5962d214316b7721de55bb82e03"

],

"schedule": {

"start_time": "2022-01-13T13:13:00+05:30",

"end_time": "2022-01-13T13:16:00+05:30"

},

"dlt_template_id" : "1107160086562376233",

"dlt_entity_id" : "1101428740000012125",

"sender_id" : "EXOTEL",

"channel": "SMS",

"sms_type": "transactional",

"template" : "Prepaid rental charges for the billing cycle starting today have been deducted from your Exotel account. Your Exotel account balance is now Rs.100. Thank you.",

"status_callback" : "https://webhook.site/9402df04-f971-4a07-9992-27dc042b1c72"

}

}

`)




client := &http.Client {

}

req, err := http.NewRequest(method, url, payload)




if err != nil {

fmt.Println(err)

return

}

req.Header.Add("Content-Type", "application/json")

req.Header.Add("Authorization", "your token")




res, err := client.Do(req)

if err != nil {

fmt.Println(err)

return

}

defer res.Body.Close()




body, err := ioutil.ReadAll(res.Body)

if err != nil {

fmt.Println(err)

return

}

fmt.Println(string(body))

}
{
"request_id":"745d624f47004b71bf72e6cb7d58a25b",
"method":"POST",
"http_code":200,
"response":[
{
"code":200,
"error_data":null,
"status":"success",
"data":{
"name":"test_campaign",
"content_type":"static",
"sid":"909d2a2ba53ce07f3784668b938eb44914bo",
"account_sid":"<your_sid>",
"lists":[
"68f443cd3e764ad1ae7d82ad27f0af72"
],
"schedule":{
"start_time":"2019-01-20T21:15:00+05:30",
"expiry_time":"2019-01-20T21:16:00+05:30"
},
"status_callback":"https://mycallback.sampledomain.in/1gvta9f1",
"date_created":"2019-01-20T21:10:00+05:30",
"date_updated":"2019-01-20T21:10:00+05:30",
"status":"scheduled",
“report_url”: null,
“dlt_entity_id”: “123478”,
“dlt_template_id”: “098765432”,
“sender_id”: “ADFGH”,
"channel": "SMS",
“sms_type”: “transactional”,
“template”: “Hi, your account is activated”.
}
}
]
}

HTTP Response:

  • On success, the HTTP response status code will be 200
  • The id is the unique identifier of the campaign, and it will be useful to log this for future debugging
  • HTTP body will contain an JSON similar to the one below

Get SMS Campaign Details Beta

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>/message-campaigns/<campaign_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>/message-campaigns/<campaign_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 +'/message-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."/message-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 +"/message-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 + "/message-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": "56887c647e644f96aa9bc43c4f347e9f",
"method": "GET",
"http_code": 200,
"response": {
"code": 200,
"status": "success",
"data": {
"name": "new camp",
"content_type": "static",
"sid": "af7826e2c40b40faa53d1a1653905879",
"account_sid": "Exotel",
"lists": [
"088d92cb349844008fcb97cdf5a52cb7"
],
"schedule": {
"start_time": "2022-05-30T15:57:00+05:30",
"end_time": "2022-06-29T15:57:00+05:30"
},
"status_callback": null,
"sms_status_callback": null,
"status": "completed",
"report_url": null,
"dlt_template_id": "1107159950325048979",
"dlt_entitiy_id": "1101428740000012125",
"sender_id": "EXOTEL",
"channel": "SMS",
"sms_type": "transactional",
"template": "Hi user,Thank you for registering; Your account has been activated",
"estimated_cost": 0.17,
"date_created": "2022-05-30T15:47:59+05:30",
"date_updated": "2022-05-30T16:19:14+05:30",
"stats": {
"scheduled": 0,
"submitted": 0,
"failed": 0,
"failed-dnd": 0,
"invalid": 0,
"failed-no-attempt": 0,
"sent": 2,
"failed-expired": 0,
"failed-no-balance": 0
},
}
}
}

Update SMS Campaign Beta

While you can update all the parameters of a campaign that has not started. For a campaign that is in progress you can 'pause' or 'resume' or 'mark as completed' specified by the parameter below. Additionally, any completed campaign can be marked as 'archived'.

PUT

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-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.

Parameter Name

Type & Value

action

A parameter which can control the action of a created campaign. The below values (string) can be passed:

  • pause - Stop calling more numbers as part of the campaign that is in progress. We can pause only created and in-progress campaign
  • resume - Resume calling numbers that were not called. We can resume only paused campaign
  • complete - Mark the entire campaign as Completed. Remaining numbers are marked as Failed. We can mark only paused campaign as completed
  • archive - Mark a campaign as archived. Only completed campaign can be marked as archived
curl --location --request PUT 'https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns/<id>'  
--header 'content-type: application/json'  
--data-raw '{     "action":"archive" }'
var request = require('request');

var options = {

'method': 'PUT',

'url': 'https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns/<id>',

'headers': {

'content-type': 'application/json'

},

body: JSON.stringify({

"action": "archive"

})

};

request(options, function (error, response) {

if (error) thrownewError(error);

console.log(response.body);

});
<?php

$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => 'https://%3Cyour_api_key%3E:%3Cyour_api_token%3E%3Csubdomain%3E/v2/accounts/%3Cyour_sid%3E/message-campaigns/%3Cid%3E',

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => '',

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => true,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => 'PUT',

CURLOPT_POSTFIELDS =>'{

"action":"archive"

}',

CURLOPT_HTTPHEADER => array(

'content-type: application/json'

),

));

$response = curl_exec($curl);

curl_close($curl);

echo $response;
import requests

import json

url = "https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns/<id>"

payload = json.dumps({

"action": "archive"

})

headers = {

'content-type': 'application/json'

}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
package main

import (

"fmt"

"strings"

"net/http"

"io/ioutil"

)

func main() {

url := "https://%3Cyour_api_key%3E:%3Cyour_api_token%3E%3Csubdomain%3E/v2/accounts/%3Cyour_sid%3E/message-campaigns/%3Cid%3E"

method := "PUT"

payload := strings.NewReader(`{

"action":"archive"

}`)

client := &http.Client {

}

req, err := http.NewRequest(method, url, payload)

if err != nil {

fmt.Println(err)

return

}

req.Header.Add("content-type", "application/json")

res, err := client.Do(req)

if err != nil {

fmt.Println(err)

return

}

defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)

if err != nil {

fmt.Println(err)

return

}

fmt.Println(string(body))

}
{
"request_id": "cb8733a7c65a4a8586d6d4e8a3357088",
"method": "PUT",
"http_code": 200,
"response": {
"code": 200,
"status": "success",
"data": {
"name": "camp1",
"content_type": "static",
"sid": "90dad70b939f469fbf8b801660148272",
"account_sid": "Exotel",
"lists": [
"f2284e77ea5a4224911251b08f861af2"
],
"schedule": {
"start_time": "2022-08-10T21:57:00+05:30",
"end_time": "2022-09-09T21:57:00+05:30"
},
"status_callback": null,
"sms_status_callback": "https://www.test-campaign.com",
"status": "archived",
"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1660170935/8220cbfd56b04f3db7d885316158fc1f.csv",
"dlt_template_id": "1107160016142600511",
"dlt_entitiy_id": "1101428740000012125",
"sender_id": "EXOTEL",
"channel": "SMS",
"sms_type": "transactional",
"template": "12345 is your One Time Password (OTP) for logging into Exotel dashboard.",
"estimated_cost": 0.17,
"date_created": "2022-08-10T21:47:52+05:30",
"date_updated": "2022-08-19T12:21:34+05:30",
"stats": {
"scheduled": 0,
"submitted": 0,
"failed": 0,
"failed-dnd": 0,
"invalid": 0,
"failed-no-attempt": 0,
"sent": 1,
"failed-expired": 0,
"failed-no-balance": 0
}
}
}
}
  • On success, the HTTP response status code will be 200
  • HTTP body will contain an JSON with details of the updated resource
  • Response parameters are described above

Bulk SMS Campaign Details Beta

This API allows you to fetch bulk campaign details with sorting and searching capabilities. 

GET

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns?channel=sms&limit=10&offset=0

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

channel

Mandatory

SMS

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=50

name

Optional

Search by campaign name. Min 3 letters. (like %xxx%)

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, scheduled etc.

sort_by

Optional

This indicates in what order the campaign records are sorted in the API response. By default records are sorted by ScheduleTime in descending order. However, you can override the same in following way for ascending order: Eg: schedule.start_time:asc, name:asc, name:desc (alphabetical order A-z, Z-A)

curl https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns?channel=sms&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 +'/message-campaigns?channel=sms&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."/message-campaigns?channel=sms&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 +"/message-campaigns?channel=sms&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 + "/message-campaigns?channel=sms&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": "00ecb599425049c69fddf1834921170f",

"method": "GET",

"http_code": 200,

"metadata": {

"count": 20,

"offset": 0,

"total": 108,

"limit": 20

},

"response": [

{

"code": 200,

"status": "success",

"data": {

"name": "new camp1",

"content_type": "static",

"sid": "32c7cf34110c4d249467521660152765",

"account_sid": "Exotel",

"lists": [

"f2284e77ea5a4224911251b08f861af2"

],

"schedule": {

"start_time": "2022-08-10T23:12:00+05:30",

"end_time": "2022-09-09T23:12:00+05:30"

},

"status_callback": null,

"sms_status_callback": "https://www.test-campaign.com",

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1660170889/d62165f646574cb8a01fc9ce59d0ada7.csv",

"dlt_template_id": "1107159950325048979",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel: "SMS",

"sms_type": "transactional",

"template": "Hi user,Thank you for registering; Your account has been activated",

"estimated_cost": 0.17,

"date_created": "2022-08-10T23:02:46+05:30",

"date_updated": "2022-08-11T10:09:58+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 1,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},

}

},

{

"code": 200,

"status": "success",

"data": {

"name": "camp1",

"content_type": "static",

"sid": "90dad70b939f469fbf8b801660148272",

"account_sid": "Exotel",

"lists": [

"f2284e77ea5a4224911251b08f861af2"

],

"schedule": {

"start_time": "2022-08-10T21:57:00+05:30",

"end_time": "2022-09-09T21:57:00+05:30"

},

"status_callback": null,

"sms_status_callback": "https://www.test-campaign.com",

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1660170935/8220cbfd56b04f3db7d885316158fc1f.csv",

"dlt_template_id": "1107160016142600511",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS",

"sms_type": "transactional",

"template": "12345 is your One Time Password (OTP) for logging into Exotel dashboard.",

"estimated_cost": 0.17,

"date_created": "2022-08-10T21:47:52+05:30",

"date_updated": "2022-08-11T10:09:43+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 1,

"failed-expired": 0,

"failed-no-balance": 0

},


}

}

},

{

"code": 200,

"status": "success",

"data": {

"name": "tt-1-con",

"content_type": "static",

"sid": "2a6014856e0a4c3096a86d1660024901",

"account_sid": "Exotel",

"lists": [

"8291af18bc52494192510a2f6367ba4d"

],

"schedule": {

"start_time": "2022-08-09T11:41:00+05:30",

"end_time": "2022-08-10T00:00:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1660007688/dc4c1745dd6642f096b8af2c3431a89e.csv",

"dlt_template_id": "1107161882363538670",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS",

"sms_type": "transactional",

"template": "அன்பே KunalKeshri, இது எக்சோடெல் வழியாக ஒரு சோதனை எஸ்.எம்.எஸ்",

"estimated_cost": 0.17,

"date_created": "2022-08-09T11:31:41+05:30",

"date_updated": "2022-08-09T12:50:55+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 1,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "tt-1-contacts",

"content_type": "static",

"sid": "3a8e3328e4304b64a2c6551659971290",

"account_sid": "Exotel",

"lists": [

"48f932ff2cd1464b9a6fececbead5cb9"

],

"schedule": {

"start_time": "2022-08-08T20:48:00+05:30",

"end_time": "2022-08-09T00:00:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1659956496/a91361da70b0462e91dd99b649122d2f.csv",

"dlt_template_id": "1107161882363538670",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS",
"sms_type": "transactional",

"template": "அன்பே kunalkk, இது எக்சோடெல் வழியாக ஒரு சோதனை எஸ்.எம்.எஸ்",

"estimated_cost": 0.17,

"date_created": "2022-08-08T20:38:11+05:30",

"date_updated": "2022-08-08T22:32:43+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 1,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "new camp",

"content_type": "static",

"sid": "8c7383b9797443249d24781659939528",

"account_sid": "Exotel",

"lists": [

"f2284e77ea5a4224911251b08f861af2"

],

"schedule": {

"start_time": "2022-08-08T11:58:00+05:30",

"end_time": "2022-09-07T11:58:00+05:30"

},

"status_callback": "https://www.xyz.com",

"sms_status_callback": "https://www.test-campaign.com",

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1659951676/96435322bf1c4f768cbf4ad9a89dc260.csv",

"dlt_template_id": "1107159950325048979",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS",

"sms_type": "transactional",

"template": "Hi Farhan,Thank you for registering; Your account has been activated",

"estimated_cost": 0.17,

"date_created": "2022-08-08T11:48:48+05:30",

"date_updated": "2022-08-08T21:14:25+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 1,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "Demo_Furlunco",

"content_type": "static",

"sid": "8c15e6db017d4ed5af2c0e1659696039",

"account_sid": "Exotel",

"lists": [

"88f0664972e34d55b1c6d1f778e0e7b1"

],

"schedule": {

"start_time": "2022-08-05T16:20:00+05:30",

"end_time": "2022-09-04T16:20:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1659678797/4406f65c1810488888bcda18804dca1a.csv",

"dlt_template_id": "1107159950276888376",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS"

"sms_type": "transactional",

"template": "Hi, my name is Partha and I'm your account manager at Exotel. I saw that you signed up for a trial account and wanted to have a quick chat about it. You can also reach me on 08033013302 or give miss call or Email to sales@exotel.in. Have a great day.",

"estimated_cost": 0.66,

"date_created": "2022-08-05T16:10:39+05:30",

"date_updated": "2022-08-05T17:24:55+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 1,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 1,

"failed-expired": 0,

"failed-no-balance": 0

},

}

},

{

"code": 200,

"status": "success",

"data": {

"name": "tttkk",

"content_type": "dynamic",

"sid": "e48d9c899b5c4eceb4f7901659678685",

"account_sid": "Exotel",

"lists": [

"d20fcf7fc742411b9f4cb68784714f5e"

],

"schedule": {

"start_time": "2022-08-05T11:31:00+05:30",

"end_time": "2022-08-06T00:02:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "archived",

"state": "prepared",

"report_url": null,

"dlt_template_id": "1107165581344758868",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS"

"sms_type": "transactional",

"template": "Hi @@First_name, your number @@number is now turned @@First_name. -Exotel",

"estimated_cost": 0.33,

"date_created": "2022-08-05T11:21:25+05:30",

"date_updated": "2022-08-05T11:22:12+05:30",

"stats": {

"scheduled": 2,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "test-kkesh",

"content_type": "dynamic",

"sid": "ac84365d7cdd450eba750a1659549795",

"account_sid": "Exotel",

"lists": [

"6c6c1bbdc3174e90948e8c7406d151c8"

],

"schedule": {

"start_time": "2022-08-03T23:49:00+05:30",

"end_time": "2022-08-05T00:12:00+05:30"

},

"status_callback": "https://webhook.site/9e1fa95d-760e-4f60-bbf6-78f9df6850a0",

"sms_status_callback": "https://webhook.site/9e1fa95d-760e-4f60-bbf6-78f9df6850a0",

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1659532994/0a0dd441cb774317a98df4b570230729.csv",

"dlt_template_id": "1107161882363538670",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS"

"sms_type": "transactional",

"template": "அன்பே @@First_name@@Amount, இது எக்சோடெல் வழியாக ஒரு சோதனை எஸ்.எம்.எஸ்",

"estimated_cost": 0.33,

"date_created": "2022-08-03T23:33:15+05:30",

"date_updated": "2022-08-04T00:58:23+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 2,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "test-kkesh",

"content_type": "dynamic",

"sid": "982c6a07cd014eaf85e9371659549581",

"account_sid": "Exotel",

"lists": [

"6c6c1bbdc3174e90948e8c7406d151c8"

],

"schedule": {

"start_time": "2022-08-03T23:39:00+05:30",

"end_time": "2022-08-05T00:12:00+05:30"

},

"status_callback": "https://webhook.site/9e1fa95d-760e-4f60-bbf6-78f9df6850a0",

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1659532362/28d2dba0a1974afbb00c73beb64e1083.csv",

"dlt_template_id": "1107161882363538670",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS"

"sms_type": "transactional",

"template": "அன்பே @@First_name@@Amount, இது எக்சோடெல் வழியாக ஒரு சோதனை எஸ்.எம்.எஸ்",

"estimated_cost": 0.33,

"date_created": "2022-08-03T23:29:42+05:30",

"date_updated": "2022-08-04T00:47:20+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 2,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "new camp",

"content_type": "static",

"sid": "f070d0e331794829b373021659434769",

"account_sid": "Exotel",

"lists": [

"f2284e77ea5a4224911251b08f861af2"

],

"schedule": {

"start_time": "2022-08-02T15:46:00+05:30",

"end_time": "2022-09-01T15:46:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1659658293/245d2716ed0b48328cfc01197228ea8a.csv",

"dlt_template_id": "1107159950325048979",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"channel": "SMS"

"sms_type": "transactional",

"template": "Hi user,Thank you for registering; Your account has been activated",

"estimated_cost": 0.17,

"date_created": "2022-08-02T15:36:09+05:30",

"date_updated": "2022-08-05T11:45:13+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 1,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "Test_Demo",

"content_type": "dynamic",

"sid": "49f5d66c2f7742d78e6dbc1659095370",

"account_sid": "Exotel",

"lists": [

"14362f5dfdc54f45bb92fe3d0c112d3c"

],

"schedule": {

"start_time": "2022-07-29T17:29:00+05:30",

"end_time": "2022-08-28T17:29:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1659078150/7031d55b7f844af8b671ea67061ffff5.csv",

"dlt_template_id": "1107160188990359627",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOSMS",

"sms_type": "transactional",

"template": "This is a test message being sent using Exotel with a (@@Name) and (@@number). If this is being abused, report to 08088919888 - Powered by Exotel",

"estimated_cost": 0.33,

"date_created": "2022-07-29T17:19:30+05:30",

"date_updated": "2022-07-29T18:33:09+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 2,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "testing ak9322",

"content_type": "dynamic",

"sid": "81b69a02d4af4b81a78dae1657826990",

"account_sid": "Exotel",

"lists": [

"c6a5c838e2714d8596f110efaeeb9e64"

],

"schedule": {

"start_time": "2022-07-15T01:09:00+05:30",

"end_time": "2022-07-15T03:09:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1657809800/a4450833ab9d4caa89074953fc68668a.csv",

"dlt_template_id": "1107160086235010042",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional",

"template": "Hey @@first_name, The @@company_name campaign @@last_name that's scheduled to run on @@company_name has started",

"estimated_cost": 0,

"date_created": "2022-07-15T00:59:50+05:30",

"date_updated": "2022-07-15T02:10:57+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 1,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "testing ak932",

"content_type": "dynamic",

"sid": "7e10f52bca2c4b71aeb1af1657825869",

"account_sid": "Exotel",

"lists": [

"c0c5e4b68bad4d1983c8ea626eba1d2a"

],

"schedule": {

"start_time": "2022-07-15T00:52:00+05:30",

"end_time": "2022-07-15T03:05:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1657808723/2f3bc30f0c32467b9e0bb9abb0c76ac0.csv",

"dlt_template_id": "1107159950325048979",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOSMS",

"sms_type": "transactional",

"template": "Hi @@number,Thank you for registering; Your account has been activated",

"estimated_cost": 0,

"date_created": "2022-07-15T00:41:10+05:30",

"date_updated": "2022-07-15T01:53:58+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 1,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},

}

},

{

"code": 200,

"status": "success",

"data": {

"name": "Demo_dunzo",

"content_type": "dynamic",

"sid": "ad8d46ed5dae460ab7e57f1657790121",

"account_sid": "Exotel",

"lists": [

"1bdaeeed4f9f44808736f76011707519"

],

"schedule": {

"start_time": "2022-07-14T14:55:00+05:30",

"end_time": "2022-08-13T14:55:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1657777189/43374033fc684067b067cdb7fe376cf0.csv",

"dlt_template_id": "1107159950276888376",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional",

"template": "Hi, my name is @@First_name and I'm your account manager at Exotel. I saw that you signed up for a trial account and wanted to have a quick chat about it. You can also reach me on 08033013302 or give miss call or Email to sales@exotel.in. Have a great day.",

"estimated_cost": 0.66,

"date_created": "2022-07-14T14:45:22+05:30",

"date_updated": "2022-07-14T17:09:26+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 2,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "vishal dynamic test",

"content_type": "dynamic",

"sid": "da8d32e69e8a4ea081db2f1657356640",

"account_sid": "Exotel",

"lists": [

"db8510ff3e2347b6ae79b4494ab8e6ec"

],

"schedule": {

"start_time": "2022-07-09T14:35:00+05:30",

"end_time": "2022-08-08T14:35:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1657339689/e7dbabd747b747e78187ba82f5115d72.csv",

"dlt_template_id": "1107159950325048979",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional",

"template": "Hi @@first_name,Thank you for registering; Your account has been activated",

"estimated_cost": 0.17,

"date_created": "2022-07-09T14:20:40+05:30",

"date_updated": "2022-07-09T15:37:16+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 1,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},

}

},

{

"code": 200,

"status": "success",

"data": {

"name": "new camp",

"content_type": "static",

"sid": "a84c43446c7245618e2e181655830734",

"account_sid": "Exotel",

"lists": [

"088d92cb349844008fcb97cdf5a52cb7"

],

"schedule": {

"start_time": "2022-06-21T22:43:00+05:30",

"end_time": "2022-07-21T22:43:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1655813757/9d11db000a0a45979b251149ba935683.csv",

"dlt_template_id": "1107165530031626914",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional",

"template": "Your OTP for Exotel is abc. Register for a free trial account on xyz. Immediately report to 08088919888 for any misuse complaints -Exotel.",

"estimated_cost": 0.33,

"date_created": "2022-06-21T22:28:54+05:30",

"date_updated": "2022-06-21T23:40:34+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 2,

"failed-expired": 0,

"failed-no-balance": 0

},

}

},

{

"code": 200,

"status": "success",

"data": {

"name": "new camp",

"content_type": "static",

"sid": "fec62cff05ac444aa768831655804093",

"account_sid": "Exotel",

"lists": [

"088d92cb349844008fcb97cdf5a52cb7"

],

"schedule": {

"start_time": "2022-06-21T15:14:00+05:30",

"end_time": "2022-07-21T15:14:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1655786863/70b376fc4c894cac8a230bcfddc137dc.csv",

"dlt_template_id": "1107161882389930061",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional_opt_in",

"template": "नमस्कार abcxyz, this is a test SMS from Exotel",

"estimated_cost": 0.03,

"date_created": "2022-06-21T15:04:53+05:30",

"date_updated": "2022-06-21T16:10:52+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 2,

"failed-expired": 0,

"failed-no-balance": 0

},

}

},

{

"code": 200,

"status": "success",

"data": {

"name": "test1243",

"content_type": "dynamic",

"sid": "0d5dcefb53c145849006a61655297957",

"account_sid": "Exotel",

"lists": [

"3b75e0d36e0a4165b6fbaff535939e8a"

],

"schedule": {

"start_time": "2022-06-15T18:44:00+05:30",

"end_time": "2022-07-15T18:44:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "completed",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1655281126/8367e46dc2d5495c942f2276fda6074c.csv",

"dlt_template_id": "1107160086556452462",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional",

"template": "Thanks for signing up for an Exotel Trial Account. Your verification code is @@number.n n n n If you did not signup with Exotel, let us know by giving a missed call to 080-67683910.",

"estimated_cost": 0.33,

"date_created": "2022-06-15T18:29:18+05:30",

"date_updated": "2022-06-15T19:42:23+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 1,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "TYrt",

"content_type": "static",

"sid": "8c0840bf9bd04baea2690a1655285272",

"account_sid": "Exotel",

"lists": [

"d370df24f3af4da5b3a4cd7144fe9193"

],

"schedule": {

"start_time": "2022-06-15T15:12:00+05:30",

"end_time": "2022-07-15T15:12:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "archived",

"state": "prepared",

"report_url": null,

"dlt_template_id": "1107159950325048979",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional",

"template": "Hi Test,Thank you for registering; Your account has been activated",

"estimated_cost": 6.77,

"date_created": "2022-06-15T14:57:52+05:30",

"date_updated": "2022-06-15T14:58:13+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 0,

"failed-expired": 0,

"failed-no-balance": 0

},


}

},

{

"code": 200,

"status": "success",

"data": {

"name": "Demo_CF",

"content_type": "dynamic",

"sid": "689abbd91a1649f3975fad1655283641",

"account_sid": "Exotel",

"lists": [

"754d8466996f4fbea062dd77510b3646"

],

"schedule": {

"start_time": "2022-06-15T14:45:00+05:30",

"end_time": "2022-07-15T14:45:00+05:30"

},

"status_callback": null,

"sms_status_callback": null,

"status": "archived",

"state": "list-completed",

"report_url": "https://exotelreports.s3.ap-southeast-1.amazonaws.com/sms-campaign-report/account_sid=Exotel/_timestamp=1655266755/80026cac5b41421da162ef91b23fc128.csv",

"dlt_template_id": "1107159950276888376",

"dlt_entitiy_id": "1101428740000012125",

"sender_id": "EXOTEL",

"sms_type": "transactional",

"template": "Hi, my name is @@Name and I'm your account manager at Exotel. I saw that you signed up for a trial account and wanted to have a quick chat about it. You can also reach me on 08033013302 or give miss call or Email to sales@exotel.in. Have a great day.",

"estimated_cost": 0.83,

"date_created": "2022-06-15T14:30:41+05:30",

"date_updated": "2022-06-20T17:18:20+05:30",

"stats": {

"scheduled": 0,

"submitted": 0,

"failed": 0,

"failed-dnd": 0,

"invalid": 0,

"failed-no-attempt": 0,

"sent": 3,

"failed-expired": 0,

"failed-no-balance": 0

},

}

}

]

}

SMS Details of a Single SMS Campaign Beta

This API allows you to get the details of all the SMS of a Campaign. It's like a summary page or Inbox per campaign.

The SMS level data consists of Name (if saved in Contacts), Number, Date Created, Status, Sender ID & SMSsid

GET

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns/id/message-details?channel=sms&limit=10&offset=0

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com
  • Replace <campaign-id> with the campaign sid of the campaign that you want to view

<your_api_key> , <your_api_token> and <your_sid> are available in the API settings page of your Exotel Dashboard

Path parameters-

Parameter Mandatory/Optional Value
campaign_id Mandatory Campaign SID 
channel Mandatory SMS

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

number

optional

Search by phone number. Exact match

sort_by

optional

sort by the scheduled time. for example: schedule_time:asc, schedule_time:desc

 

curl https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns/id/message-details?channel=sms&sort_by=date_created:desc&limit=3&offset=0
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 +'/sms-campaigns/491dd6c97d64475ba0ce346a18530ce5/sms-details?sort_by=date_created:desc&limit=3&offset=0',
  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."/sms-campaigns/491dd6c97d64475ba0ce346a18530ce5/sms-details?sort_by=date_created:desc&limit=3&offset=0",
  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 +"/sms-campaigns/491dd6c97d64475ba0ce346a18530ce5/sms-details?sort_by=date_created:desc&limit=3&offset=0"

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 + "/sms-campaigns/491dd6c97d64475ba0ce346a18530ce5/sms-details?sort_by=date_created:desc&limit=3&offset=0"

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": "4dee72175b514f3591e153df7c89285d",

  "method": "GET",

  "http_code": 200,

  "metadata": {

    "count": 5,

    "offset": 0,

    "total": 5,

    "limit": 10

  },

  "response": [

    {

      "code": 200,

      "error_data": null,

      "status": "success",

      "data": {

        "number": "XXXXXXXXXX",

        "name": "shubham_t",

        "message": "your account is activated",

        "status": "sent",

        "detailed_status": "DELIVERED_TO_OPERATOR",

        "schedule_time": "2021-11-24T14:55:19+05:30",

        "sender_id": "EXOTEL",

        "direction": "outgoing-api",

        "sid": "34d67d290cb761c0606b7fe9590015bo"

      }

    },

    {

      "code": 200,

      "error_data": null,

      "status": "success",

      "data": {

        "number": "XXXXXXXXXX",

        "name": "shubham_t",

        "body": "your account is activated",

        "status": "failed",

        "detailed_status: "FAILED_SPAM_DETECTED",

        "schedule_time": "2021-11-24T14:55:19+05:30",

        "sender_id": "EXOTEL",

        "direction": "outgoing-api",

        "sid": "34d67d290cb761c0606b7fe9590015bo"

      }

    },

    {

      "code": 200,

      "error_data": null,

      "status": "success",

      "data": {

        "number": "XXXXXXXXXX",

        "name": "shubham_t",

        "body": "your account is activated",

        "status": "failed_dnd"",

        "detailed_status": "FAILED_REJECTED_DND",

        "schedule_time": "2021-11-24T14:55:19+05:30",

        "sender_id": "EXOTEL",

        "direction": outgoing-api,

        "sid": “34d67d290cb761c0606b7fe9590015bf”

      }

    }

  ]

}