This API allows you get details of lists within an account. This API also allows you to search a particular list by list name and also sort the fetched response by name or date created.
It's a bulk API which which works with offset & limit parameters to fetch specific set of data.
https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/lists?limit=<limit>&offset=<offset>
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
Request 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 |
name |
optional |
Search on lists name |
sort_by |
optional |
This indicates in what order the lists 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 |
curl -X GET 'https://<your_api_key>:<your_api_token>@<subdomain>/v2/accounts/<account_sid>/lists?limit=6'
var unirest = require('unirest'); var unirest = require('unirest'); var accountSid = "XXXXXXXXX"; var accountToken = "YYYYYYYYY"; var authKey = "ZZZZZZZZZZ"; var encoding = Buffer.from(authKey + ':' + accountToken).toString('base64'); var req = unirest('GET', 'https://<subdomain>/v2/accounts/'+accountSid+'/lists?limit=<limit>&offset=<offset>') .headers({ Authorization: 'Basic ' + encoding }) .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); });
<?php $curl = curl_init(); $accountSid = "XXXXXXXXXX"; $accountToken = "YYYYYYYYYY"; $authKey = "ZZZZZZZZZZ"; $encoding = base64_encode($authKey .":". $accountToken); curl_setopt_array($curl, array( CURLOPT_URL => 'https://<subdomain>/v2/accounts/'+ $accountSid+'/lists?limit=<limit>&offset=<offset>', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( "Authorization: Basic ".$encoding ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
import requests import base64 import json accountSid = "XXXXXXXXX" authToken = "YYYYYYYYY" authKey = "ZZZZZZZZZZ" encoding = base64.b64encode(authKey + ":" + authToken) url = "https://<subdomain>/v2/accounts/"+accountSid+"/lists?limit=<limit>&offset=<offset>" payload={} headers = { 'Authorization': "Basic " + encoding } response = requests.request("GET", url, headers=headers, data=payload) print(response.text)
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://<subdomain>/v2/accounts/" + accountSid + "/lists?limit=<limit>&offset=<offset>" method := "GET" client := &http.Client{} req, err := http.NewRequest(method, url, nil) req.Header.Add("Authorization", "Basic "+encoding) if err != nil { fmt.Println(err) return } 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": "bb9f1dca63fa4bc484b1918371f988f3", "method": "GET", "http_code": 200, "metadata": { "count": 6, "offset": 0, "limit": 6, "total": 44 }, "response": [ { "code": 200, "error_data": null, "status": "success", "data": { "sid": "a6683f8a0d3a445183cb3e6bbf911f6d", "date_created": "2021-05-23T06:54:19Z", "date_updated": "2021-05-23T12:24:19Z", "account_sid": "exotel8u3", "name": "21may_csv_list9", "uri": "/v2/accounts/exotel8u3/lists/a6683f8a0d3a445183cb3e6bbf911f6d", "tag": null, "contact_count": null } }, { "code": 200, "error_data": null, "status": "success", "data": { "sid": "5f392c92b4c9414d940e70e1ff25ad41", "date_created": "2021-05-23T06:52:01Z", "date_updated": "2021-05-23T12:22:01Z", "account_sid": "exotel8u3", "name": "21may_csv_list8", "uri": "/v2/accounts/exotel8u3/lists/5f392c92b4c9414d940e70e1ff25ad41", "tag": null, "contact_count": 4 } }, { "code": 200, "error_data": null, "status": "success", "data": { "sid": "d996deee9e424c2ea8e07e3dd1856ea9", "date_created": "2021-05-21T15:08:18Z", "date_updated": "2021-05-21T20:38:17Z", "account_sid": "exotel8u3", "name": "21may_csv_list1", "uri": "/v2/accounts/exotel8u3/lists/d996deee9e424c2ea8e07e3dd1856ea9", "tag": null, "contact_count": null } }, { "code": 200, "error_data": null, "status": "success", "data": { "sid": "26e1ccb8a66c43cb997e7a6a621419ce", "date_created": "2021-05-04T09:53:28Z", "date_updated": "2021-05-04T15:23:28Z", "account_sid": "exotel8u3", "name": "csv_list123", "uri": "/v2/accounts/exotel8u3/lists/26e1ccb8a66c43cb997e7a6a621419ce", "tag": null, "contact_count": null } }, { "code": 200, "error_data": null, "status": "success", "data": { "sid": "98b81a65910646e799c4fac2e3adb191", "date_created": "2021-05-04T09:50:05Z", "date_updated": "2021-05-04T15:20:04Z", "account_sid": "exotel8u3", "name": "new_list1", "uri": "/v2/accounts/exotel8u3/lists/98b81a65910646e799c4fac2e3adb191", "tag": null, "contact_count": null } }, { "code": 200, "error_data": null, "status": "success", "data": { "sid": "85288201fd724e9688d206a05d1f30ca", "date_created": "2021-05-04T09:49:40Z", "date_updated": "2021-05-04T15:19:40Z", "account_sid": "exotel8u3", "name": "new_list", "uri": "/v2/accounts/exotel8u3/lists/85288201fd724e9688d206a05d1f30ca", "tag": null, "contact_count": null } } ] }