This API allows you to create one or more new lists. A list name has to be unique within an account.
The Lists created using this API can only be used within Call Campaigns.
https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/lists
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
The following are the POST parameters:
Parameter Name | Mandatory/Optional | Value |
name |
Mandatory |
Name of list (unique within an account) |
tag |
optional |
Tag value for the list |
curl -X POST 'https://<your_api_key>:<your_api_token>@<subdomain>/v2/accounts/exotel8u3/lists' --header 'Content-Type: application/json' --data-raw '{ "lists": [ { "name": "new-csv_list2" } ] }'
var unirest = require('unirest'); var accountSid = "XXXXXXXXX"; var accountToken = "YYYYYYYYY"; var authKey = "ZZZZZZZZZZ"; var encoding = Buffer.from(authKey + ':' + accountToken).toString('base64'); var req = unirest('POST', "https://<subdomain>/v2/accounts/"+accountSid+"/lists") .headers({ Authorization: 'Basic ' + encoding, 'Content-Type': 'application/json' }) .send(JSON.stringify({"lists":[ { "name":"list123" }, { "name":"list345" } ]})) .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/exotel8u3/lists', 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 =>'{ "lists": [ { "name": "list123" }, { "name": "list345" } ] }', CURLOPT_HTTPHEADER => array( "Authorization: Basic ".$encoding, 'Content-Type: application/json' ), )); $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" payload = json.dumps({ "lists": [ { "name": "list123", }, { "name": "list345", } ] }) headers = { 'Authorization': "Basic " + encoding, 'Content-Type': 'application/json' } response = requests.request("POST", 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" "strings" ) 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" method := "POST" payload := strings.NewReader(`{ "lists": [ { "name": "list31@3" } ] }`) 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", "Basic "+encoding) 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": "b45f202e1ec14b37bc459235a65f8712", "method": "POST", "http_code": 207, "metadata": { "failed": 0, "total": 1, "success": 1 }, "response": [ { "code": 200, "error_data": null, "status": "success", "data": { "sid": "46cd9106113f4920be56811382ebefba", "date_created": "2021-05-23T14:09:32.143446635+05:30", "date_updated": "2021-05-23T14:09:32.143446635+05:30", "account_sid": "exotel8u3", "name": "new-csv_list2", "uri": "/v2/accounts/exotel8u3/lists/46cd9106113f4920be56811382ebefba", "tag": null, "contact_count": null } } ] }