This API helps update following parameters in an existing active GreenPin allocation:
Although none of the above parameters are mandatory, at-least one of the parameters have to be passed as a mandate.
Pricing: The Update API will be charged equivalent to that of a new allocation, as per the price plan. At the time of deallocation, the duration will be computed from the time of original allocation and charged as per the price plan.
https://leadassist.exotel.in/v1/tenants/<your_sid>/greenpin/<greenpin_id>
Replace <your_sid> with your tenant ID.
curl--location--request PUT 'https://<your_api_key>:<your_api_token>@leadassist.exotel.in/v1/tenants/<account_sid>/greenpin/<greenpin_id>'\ --header 'Content-Type: application/json'\ --data - raw '{ "a": { "vns": [ "629XXXXX71", "629XXXXX64" ], "numbers": [ "798XXXXX44" ], "pin": "123", "pin_length": 3 }, "b": { "vns": [ "629XXXXX65", "629XXXXX64" ], "numbers": [ "995XXXXX25" ], "pin": "234", "pin_length": "3" }, "usage": "twoway", "deallocation_policy": { "duration": "1200s" } }'
var request = require("request"); var accountSid = "XXXXXXXXX"; var accountToken = "YYYYYYYYY"; var authKey = "ZZZZZZZZZZ"; var encoding = Buffer.from(authKey + ':' + accountToken).toString('base64') var options = { method: 'PUT', 'url': 'https://leadassist.exotel.in/v1/tenants/'+accountSid+'/greenpin/<greenpin_id>', 'headers': { 'Authorization': 'Basic'+ encoding, 'Content-Type': 'application/json' }, body: JSON.stringify({"a":{"vns":["629XXXXX71","629XXXXX64"],"numbers":["798XXXXX44"],"pin":"123","pin_length":3},"b":{"vns":["629XXXXX65","629XXXXX64"],"numbers":["995XXXXX25"],"pin":"234","pin_length":"3"},"usage":"twoway","deallocation_policy":{"duration":"1200s"}}) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });
<?php $curl = curl_init(); $accountSid = "XXXXXXXXXX"; $accountToken = "YYYYYYYYYY"; $authKey = "ZZZZZZZZZZ"; $encoding = base64_encode($authKey. ":".$accountToken); curl_setopt_array($curl, array( CURLOPT_URL => 'https://leadassist.exotel.in/v1/tenants/' + $accountSid + '/greenpin/<greenpin_id>', 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 => '{ "a": { "vns": [ "629XXXXX71", "629XXXXX64" ], "numbers": [ "798XXXXX44" ], "pin": "123", "pin_length": 3 }, "b": { "vns": [ "629XXXXX65", "629XXXXX64" ], "numbers": [ "995XXXXX25" ], "pin": "234", "pin_length": "3" }, "usage": "twoway", "deallocation_policy": { "duration": "1200s" } } ', CURLOPT_HTTPHEADER => array( 'Authorization: Basic ' + $encoding, 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
import requests, base64, json accountSid = "XXXXXXXXX" authToken = "YYYYYYYYY" authKey = "ZZZZZZZZZZ" encoding = base64.b64encode(authKey + ":" + authToken) url = "https://leadassist.exotel.in/v1/tenants/" + accountSid + "/greenpin/<greenpin_id>" payload = json.dumps({ "a": { "vns": [ "629XXXXX71", "629XXXXX64" ], "numbers": [ "798XXXXX44" ], "pin": "123", "pin_length": 3 }, "b": { "vns": [ "629XXXXX65", "629XXXXX64" ], "numbers": [ "995XXXXX25" ], "pin": "234", "pin_length": "3" }, "usage": "twoway", "deallocation_policy": { "duration": "1200s" } }) headers = { 'Authorization': 'Basic ' + encoding, 'Content-Type': 'application/json' } response = requests.request("PUT", url, headers = headers, data = payload) print(response.text)
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://leadassist.exotel.in/v1/tenants/" + accountSid + "/greenpin/<greenpin_id>" payload := strings.NewReader(`{ "a": { "vns": [ "629XXXXX71", "629XXXXX64" ], "numbers": [ "798XXXXX44" ], "pin": "123", "pin_length": 3 }, "b": { "vns": [ "629XXXXX65", "629XXXXX64" ], "numbers": [ "995XXXXX25" ], "pin": "234", "pin_length": "3" }, "usage": "twoway", "deallocation_policy": { "duration": "1200s" } }`) req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Content-Type", "application/json") req.Header.Add("Authorization", "Basic "+encoding) req.Header.Add("cache-control", "no-cache") res, err := http.DefaultClient.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
HTTP Response:
{ "request_id": "b45f20XXX5f8712", "method": "PUT", "success": true, "status": 200, "code": null, "message": null, "data": { "transaction_id": "random_string", "greenpin_id": "d7ffd4b3-XPYX-4bda-a024-ibidatabatodoo", "a": { "vns": [ "+916XXXXXX471", "+916XXXXXX464" ], "numbers": [ "+917XXXXXX144" ], "pin": "123" }, "b": { "vns": [ "+916XXXXXX465", "+916XXXXXX464" ], "numbers": [ "+919XXXXXX625" ] }, "usage": "twoway", "state": "active", "deallocation_time": "2020-03-27 12:17:09" } }