This API allows you to update more than one contact at a time.

PUT

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/contacts

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

<your_api_key> , <your_api_token> and <your_sid> are available in the API settings page of your Exotel Dashboard

curl --location --request PUT 'https://<your_api_key>:<your_api_token>@<subdomain>/v2/accounts/<account_sid>/contacts' \
--header 'Content-Type: application/json' \
--data-raw '
{
    "contacts": [
        {
            "sid":"83ba26b7f11c4e75b4043c8b33ceba49",   
            "first_name": "XYZ" 
        }
        { 
            "sid":"93ba26b7f11c4e75b4043c8b33ceba59",
            "first_name": "ABC" 
         } 
         { 
            "sid":"73ba26b7f11c4e75b4043c8b33ceba69",
            "first_name": "LMN" 
         } 
    ] 
}'
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('PUT', 'https://<subdomain>/v2/accounts/exotel8u3/contacts')
  .headers({
      Authorization: 'Basic ' + encoding,
      'Content-Type': 'application/json'
  })
  .send(JSON.stringify(
{
    "contacts": [
        {
            "sid":"83ba26b7f11c4e75b4043c8b33ceba49",
            "first_name": "XYZ" 
        }
        { 
            "sid":"93ba26b7f11c4e75b4043c8b33ceba59",
            "first_name": "ABC" 
         } 
         { 
            "sid":"73ba26b7f11c4e75b4043c8b33ceba69",
            "first_name": "LMN" 
         } 
    ] 
}
)
  .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 = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<subdomain>/v2/accounts/exotel8u3/contacts/<contact_sid>',
  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 =>'
{
    "contacts": [
        {
            "sid":"83ba26b7f11c4e75b4043c8b33ceba49", 
            "first_name": "XYZ" 
        }
        { 
            "sid":"93ba26b7f11c4e75b4043c8b33ceba59",
            "first_name": "ABC" 
         } 
         { 
            "sid":"73ba26b7f11c4e75b4043c8b33ceba69",
            "first_name": "LMN" 
         } 
    ] 
}',
CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', "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/exotel8u3/contacts/<contact_sid>"

payload = json.dumps(
{
    "contacts": [
        {
            "sid":"83ba26b7f11c4e75b4043c8b33ceba49",        
            "first_name": "XYZ" 
        }
        { 
            "sid":"93ba26b7f11c4e75b4043c8b33ceba59",
            "first_name": "ABC" 
         } 
         { 
            "sid":"73ba26b7f11c4e75b4043c8b33ceba69",
            "first_name": "LMN" 
         } 
    ] 
}
)
headers = {
  'Content-Type': 'application/json',
  'Authorization': "Basic " + encoding
}

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://<subdomain>/v2/accounts/" + accountSid + "/contacts/<contact_sid>"
	method := "PUT"

	payload := strings.NewReader(
{
    "contacts": [
        {
            "sid":"83ba26b7f11c4e75b4043c8b33ceba49",
            "first_name": "XYZ" 
        }
        { 
            "sid":"93ba26b7f11c4e75b4043c8b33ceba59",
            "first_name": "ABC" 
         } 
         { 
            "sid":"73ba26b7f11c4e75b4043c8b33ceba69",
            "first_name": "LMN" 
         } 
    ] 
}
)

	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":"a325d397a29f49698113ad56715dcf23",
  "method":"PUT",
  "http_code":207,
  "metadata":
     {
       "failed":2,
       "total":3,
       "success":1
     },
  "response":[
     {
       "code":200,
       "error_data":null,
       "status":"success",
       "data":{
           "sid":"83ba26b7f11c4e75b4043c8b33ceba49", 
           "date_created":"2017-11-30T11:22:39Z", 
           "date_updated":"2017-12-05T14:24:11Z", 
           "account_sid":"Exotel", 
           "number":"+67420336456", 
           "first_name":"XYZ", 
           "last_name":"ABC", 
           "company_name":"Exotel",
           "email":"shiva@exotel.in",
           "tag":"Member",
           "custom_field":{ "key":{ "a":"b", "c":[1,2,3] } }, 
           "uri":"/v2/Accounts/Exotel/Contacts/4675ce5f21994bcca8cf07c7e0426be7" 
        } 
      }, 
   { 
     "code":404, 
     "error_data":
        { 
           "code":1000, 
           "description":"Contact not found", 
           "message":"Not Found" 
        }, 
     "status":"failure" 
   }, 
   { 
     "code":404, 
     "error_data":
       { 
          "code":1000, 
          "description":"Contact not found", 
          "message":"Not Found" 
       }, 
     "status":"failure" 
   } 
] 
}