×

This API allows to update GreenVN in an existing active allocation. 

While placing the request for the new VN, the number and the region can also be provided as a preference. If requested, without a request body, ExoBridge system will allocate an available number from the VN pool.

Other parameters will be inherited from the original allocation and passed in the API response.

PUT

https://leadassist.exotel.in/v1/tenants/<your_sid>/greenvn/<greenvn_id>/vn

Replace <your_sid> with your tenant ID.

Please refer 'Create a VN Allocation' (POST) API for details on request parameters.

curl --location --request PUT 'https://<your_api_key>:<your_api_token>@leadassist.exotel.in/v1/tenants/<account_sid>/greenvn/<greenvn_id>/vn' \
--header 'Content-Type: application/json' \
--data-raw '{
    "strictness": "false",
    "preferences": {
        "greenvn": "+917205827365",
        "region": "KA",
        "number_type": "landline"
    }
}'
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+'/greenvn/<greenvn_id>/vn',
    'headers': {
        'Authorization': 'Basic'+ encoding,
        'Content-Type': 'application/json'
    },
  body: JSON.stringify({"strictness":"false","preferences":{"greenvn":"+9172xxxxxx65"}})

};
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+'/greenvn/<greenvn_id>/vn',
  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 =>'{
    "strictness": "false",
    "preferences": {
        "greenvn": "+91720XXXXX65"
    }
}',
  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+"/greenvn/<greenvn_id>/vn"

payload = json.dumps({
    "strictness": "false",
    "preferences": {
        "greenvn": "+91720XXXXX65"
    }
})

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 + "/greenvn/<greenvn_id>/vn"

	payload := strings.NewReader(`{
    "strictness": "false",
    "preferences": {
		"greenvn": "+9172xxxx7365",
		"region": "KA",
		"number_type": "landline"
    }
}`)

	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:

  • On success, the HTTP response status code will be 200
  • The connection_id is the unique identifier of the original allocation, and it will be referred in HTTP body will contain a JSON similar to the one below
{
           "success": true,
           "status": 200,
           "data":{
                   "connection_id":"abcd12345",
                   "aparty_numbers":[
                                   "+919176226528", "+911234567891"
                                    ],
                   "bparty_numbers":[
                                   "+918136966620",
                                    ],
            "usage":"oneway|twoway",
            "state": "active",
            "green_vn":"+917205827365",
            "greenvn_id":"123456"
           }
}