×

This API helps update following parameters for several existing active GreenPin allocations in one go:

  • A-party & B-party
    • Numbers
    • Pins
    • VNs
    • Pin Lengths
  • Deallocation Policy
  • Usage (can be changed from 'oneway' to 'twoway' and vice versa)

Although none of the above parameters are mandatory, at-least one of the parameters have to be passed as a mandate for each allocation that is attempted to be updated.

Please note that in the case of a partial success; due to a request error, you will be able to update all those allocations for which the request was syntactically and semantically correct. 

PUT

https://leadassist.exotel.in/v1/tenants/<your_sid>/greenpin

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'\
    --header 'Content-Type: application/json'\
    --data - raw '{
"greenpins": [{
        "greenpin_id": "GREENPIN_ID1",
        "a": {
            "vns": [
                "62XXXXXX71",
                "62XXXXXX64"
            ],
            "numbers": [
                "79XXXXXX44"
            ],
            "pin": "123",
            "pin_length": 3
        },
        "b": {
            "vns": [
                "62XXXXXX65",
                "62XXXXXX64"
            ],
            "numbers": [
                "99XXXXXX25"
            ],
            "pin": "234",
            "pin_length": "3"
        },
        "usage": "twoway",
        "deallocation_policy": {
            "duration": "1200s"
        }
    },
    {
        "greenpin_id": "GREENPIN_ID2",
        "a": {
            "vns": [
                "62XXXXXX71",
                "62XXXXXX64"
            ],
            "numbers": [
                "79XXXXXX44"
            ],
            "pin": "123",
            "pin_length": 3
        },
        "b": {
            "vns": [
                "62XXXXXX65",
                "629XXXXX64"
            ],
            "numbers": [
                "9XXXXXX625"
            ],
            "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',
    'headers': {
        'Authorization': 'Basic'+ encoding,
        'Content-Type': 'application/json'
    },
  body: JSON.stringify({"greenpins":[{"greenpin_id":"GREENPIN_ID1","a":{"vns":["62XXXXXX71","62XXXXXX64"],"numbers":["79XXXXXX44"],"pin":"123","pin_length":3},"b":{"vns":["62XXXXXX65","62XXXXXX64"],"numbers":["99XXXXXX25"],"pin":"234","pin_length":"3"},"usage":"twoway","deallocation_policy":{"duration":"1200s"}},{"transaction_id":"random_string","greenpin_id":"GREENPIN_ID2","a":{"vns":["62XXXXXX71","62XXXXXX64"],"numbers":["79XXXXXX44"],"pin":"123","pin_length":3},"b":{"vns":["62XXXXXX65","629XXXXX64"],"numbers":["9XXXXXX625"],"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',
    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 => '{
    "greenpins": [{
            "greenpin_id": "GREENPIN_ID1",
            "a": {
                "vns": [
                    "62XXXXXX71",
                    "62XXXXXX64"
                ],
                "numbers": [
                    "79XXXXXX44"
                ],
                "pin": "123",
                "pin_length": 3
            },
            "b": {
                "vns": [
                    "62XXXXXX65",
                    "62XXXXXX64"
                ],
                "numbers": [
                    "99XXXXXX25"
                ],
                "pin": "234",
                "pin_length": "3"
            },
            "usage": "twoway",
            "deallocation_policy": {
                "duration": "1200s"
            }
        },
        {
            "greenpin_id": "GREENPIN_ID2",
            "a": {
                "vns": [
                    "62XXXXXX71",
                    "62XXXXXX64"
                ],
                "numbers": [
                    "79XXXXXX44"
                ],
                "pin": "123",
                "pin_length": 3
            },
            "b": {
                "vns": [
                    "62XXXXXX65",
                    "629XXXXX64"
                ],
                "numbers": [
                    "9XXXXXX625"
                ],
                "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"
payload = json.dumps({
    "greenpins": [{
            "greenpin_id": "GREENPIN_ID1",
            "a": {
                "vns": [
                    "62XXXXXX71",
                    "62XXXXXX64"
                ],
                "numbers": [
                    "79XXXXXX44"
                ],
                "pin": "123",
                "pin_length": 3
            },
            "b": {
                "vns": [
                    "62XXXXXX65",
                    "62XXXXXX64"
                ],
                "numbers": [
                    "99XXXXXX25"
                ],
                "pin": "234",
                "pin_length": "3"
            },
            "usage": "twoway",
            "deallocation_policy": {
                "duration": "1200s"
            }
        },
        {
            "greenpin_id": "GREENPIN_ID2",
            "a": {
                "vns": [
                    "62XXXXXX71",
                    "62XXXXXX64"
                ],
                "numbers": [
                    "79XXXXXX44"
                ],
                "pin": "123",
                "pin_length": 3
            },
            "b": {
                "vns": [
                    "62XXXXXX65",
                    "629XXXXX64"
                ],
                "numbers": [
                    "9XXXXXX625"
                ],
                "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(`{
"greenpins": [
{
"greenpin_id": "GREENPIN_ID1",
"a": {
"vns": [
"62XXXXXX71",
"62XXXXXX64"
],
"numbers": [
"79XXXXXX44"
],
"pin": "123",
"pin_length": 3
},
"b": {
"vns": [
"62XXXXXX65",
"62XXXXXX64"
],
"numbers": [
"99XXXXXX25"
],
"pin": "234",
"pin_length": "3"
},
"usage": "twoway",
"deallocation_policy": {
"duration": "1200s"
}
},
{
"greenpin_id": "GREENPIN_ID2",
"a": {
"vns": [
"62XXXXXX71",
"62XXXXXX64"
],
"numbers": [
"79XXXXXX44"
],
"pin": "123",
"pin_length": 3
},
"b": {
"vns": [
"62XXXXXX65",
"629XXXXX64"
],
"numbers": [
"9XXXXXX625"
],
"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:

  • On success, the HTTP response status code will be 200
  • The 'metadata' is a nested JSON block that will give an overall summary status of the number of allocations that were updated. 
  • A statuscode and message will be associated with each of the GreenPin allocations that sought to be updated.
  • All the parameters associated with an allocation will be returned for each allocation updated, irrespective of the number of parameters that actually sought an update.  
{
  "request_id": "b45f202x5a65f8712",
  "method": "PUT",
  "http_code": 207,
  "metadata": {
    "failed": 0,
    "total": 2,
    "success": 2
  },
  "response": [
    {
      "success": true,
      "status": 200,
      "code": null,
      "message": null,
      "data": {
        "transaction_id": "random_string",
        "greenpin_id": "ibitifda-c861-4bda-a024-9cef1ae2f2a8",
        "a": {
          "vns": [
            "+91XXXXXX4471",
            "+91XXXXXX4464"
          ],
          "numbers": [
            "+91XXXXXX6144"
          ],
          "pin": "123"
        },
        "b": {
          "vns": [
            "+91XXXXXX4465",
            "+91XXXXXX4464"
          ],
          "numbers": [
            "+9199XXXXXX25"
          ]
        },
        "usage": "twoway",
        "state": "active",
        "deallocation_time": "2020-03-27 12:17:09"
      }
    },
    {
      "success": true,
      "status": 200,
      "code": null,
      "message": null,
      "data": {
        "transaction_id": "random_string",
        "greenpin_id": "yabadan-c861-4bda-a024-9cef1ae2f2a8",
        "a": {
          "vns": [
            "+9162XXXXXX71",
            "+9162XXXXXX64"
          ],
          "numbers": [
            "+9179XXXXXX44"
          ],
          "pin": "123"
        },
        "b": {
          "vns": [
            "+9162XXXXXX65",
            "+9162XXXXXX64"
          ],
          "numbers": [
            "+9199XXXXXX25"
          ]
        },
        "usage": "twoway",
        "state": "active",
        "deallocation_time": "2020-03-27 12:17:09"
      }
    }
  ]
}