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
https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/message-campaigns/id/message-details?channel=sms&limit=10&offset=0
This API supports JSON response only
<your_api_key>
and <your_api_token>
with the API key and token created by you.<your_sid>
with your “Account sid”<subdomain>
with the region of your account
<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” } } ] }