This API allows a contact to be deleted by passing the Contact Sid in the request.

DELETE

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

  • 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 -X DELETE 'https://<your_api_key>:<your_api_token>@<subdomain>/v2/accounts/<account_sid>/contacts/<contact_sid>
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('DELETE', 'https://<subdomain>/v2/accounts/'+accountSid+'/contacts/<contact_sid>')
	.headers({
		Authorization: 'Basic ' + encoding
	})
  .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/'+ $accountSid+'/contacts/<Ccontact_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 => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    "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/"+ accountSid+"/contacts/<contact_id>"

payload={}
headers = {
    'Authorization': "Basic " + encoding
    }

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)
package main

import (
	b64 "encoding/base64"
	"fmt"
	"io/ioutil"
	"net/http"
)

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 := "DELETE"

	client := &http.Client{}
	req, err := http.NewRequest(method, url, nil)
	req.Header.Add("Authorization", "Basic "+encoding)

	if err != nil {
		fmt.Println(err)
		return
	}
	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": "e623a09f108d4fe0b5c442024f3d30bb",
    "method": "DELETE",
    "http_code": 200,
    "response": {
            "code": 200,
            "error_data": null,
            "status": "success",
            "data": {
                "sid": "4440b6e1a85f489b87d76d8779956caf",
                "date_created": "2021-05-23T08:21:30Z",
                "date_updated": "2021-05-23T08:21:30Z",
                "account_sid": "exotel8u3",
                "number": "+919101234511",
                "first_name": "captain",
                "last_name": "exotel",
                "company_name": "Exotel",
                "email": "captain@email.com",
                "tag": "API",
                "custom_field": {
                    "key": {
                        "key1": "values1"
                    }
                },
                "uri": "/v2/accounts/exotel8u3/contacts/4440b6e1a85f489b87d76d8779956caf"
            }
        }
}