×

This API allows a user to be deleted by passing the user-id in the request. Once deleted this action cannot be reversed.

DELETE

https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/users/<user id>

  • 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 @ccm-api.exotel.com
    2. <subdomain> of Mumbai cluster is @ccm-api.in.exotel.com
  • Replace <user_id> with the user's unique identifier as present in GET user details API.
  •  

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

curl --location --request DELETE 'https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/users/<user_id>'
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/users/<user_id>',
  'headers': {
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/users/<user_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(
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
import requests

url = "https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/users/<user_id>"

payload = ""
headers = {}

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

print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://<your_api_key>:<your_api_token><subdomain>/v2/accounts/<your_sid>/users/<user_id>"
  method := "DELETE"

  payload := strings.NewReader(``)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  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))
}

HTTP Response:

  • Response for this request will be 200. In case of non success message, the response body will contain the error message.
  • HTTP body will contain an JSON similar to the one below
{
    "request_id": "6afc1bc48dd742a6b8bb01e9be5e9761",
    "method": "DELETE",
    "http_code": 200,
    "response": {
        "code": 200,
        "error_data": null,
        "status": "success",
        "data": null
    }
}

Description of the response parameters:

Parameter Name  Value
request_id This indicates the unique id of the request. Useful for debugging and tracing purpose.
method This indicates the HTTP method for the request such as GET/POST/PUT/DELETE etc.
http_code This indicates the HTTP code for the request such as 200, 400, 500 etc.
status failed/success
response

Response block contains the user device record matching the request URI. The block contains

  • code - This indicates the http code for the particular record in the response array like 200, 400 etc.
  • error_data - This block will be null if there is no error else contain error information for the response with following fields
    • code - This would be the error code useful for Exotel's team to debug and can be highlighted in case of unexpected errors.
    • description - This describes the details of the error.
    • message - This is the error message corresponding to the error code useful for Exotel's team to debug and can be highlighted in case of unexpected errors.
  • status - This field would indicate status of the response (success/failure).
  • data - This block will contain the information corresponding to the response array element and will contain the fields for a user record as explained below. 

Possible error scenarios in case of this DELETE API:

HttpCode Code Description
400 1007
Request format is invalid
401 1010
Authentication failed
429 NA
Too many requests
500 1004
Internal Server Error
404 10801 User not found
403 1003
API credentials used are unauthorized
403 10814
This account's KYC is incomplete. Operation not permitted
403 10815
This is a trial account. Operation not permitted

*These will be populated under the `error_data` block of response