V 2.0
Directory
Overview
The Directory API provides functionality to manage contact information. With this API, you can create, update, and retrieve contacts, as well as manage sticky agents, account managers, and other related operations.
Authentication
Authentication is required for all endpoints. You can use either:
-
SSID (Session ID)
-
User ID and Token
These must be included in the request body for each API call.
Base URL
The base URL for all API endpoints is: deepcall/api/v2/Directory
Error Codes
The following table shows specific error codes for the Directory API, extracted from SarvErrors.js:
Error Code | Description |
---|---|
1501 | Sticky agent error |
1502 | Type is not valid |
1503 | Account manager error |
1504 | Failed to create directory |
1505 | CLI does not exist |
1506 | Group ID does not exist |
1507 | Agent does not exist in the given group ID |
1508 | Expiry must be greater than or equal to -1 |
1509 | Expiry must be integer value |
1510 | DNC error |
In addition to these specific error codes, there may also be general error codes such as:
Error Code | Description |
---|---|
1000 | Invalid parameter |
1005 | Invalid contact number |
1012 | No data found |
These error codes will help developers better understand and troubleshoot API responses.
Update
Endpoint
-
Method: POST
-
Path:
deepcall/api/v2/Directory/update
Description: This endpoint allows you to update an existing contact's information in the user's directory.
Use Case: Modifying customer details or updating lead information.
Parameters:
Name | Type | Required | Description |
---|---|---|---|
contact | String | Yes | The contact number to update |
contactinfo | Object | No | Updated contact information (see table below) |
other | Object | No | Other updated information (see table below) |
ssid | String | Conditional | Session ID (required if userId and token not provided) |
userId | String | Conditional | User ID (required if ssid not provided) |
token | String | Conditional | Authentication token (required if ssid not provided) |
contactinfo Object Fields:
Field | Type | Required | Description |
---|---|---|---|
name | String | No | Contact's name. Only letters, whitespace, and dot(.) are allowed |
String | No | Contact's email address. Must be a valid email format | |
dob | String | No | Date of Birth. Format: dd-mm-YYYY |
address | String | No | Contact's address |
company | String | No | Company name |
designation | String | No | Job designation |
custom_field_1 | String | No | User-defined custom field. Validation depends on user configuration |
custom_field_2 | String | No | User-defined custom field. Validation depends on user configuration |
other Object Fields:
Field | Type | Required | Description |
---|---|---|---|
updatetime | String | No | Last update time. Format: dd-mm-YYYY |
lastcalltime | String | No | Last call time. Format: dd-mm-YYYY |
totalcalls | Integer | No | Total number of calls. Must be a non-negative integer |
source | Integer | No | Source of the contact. Must be a non-negative integer |
vip | Boolean | No | VIP status. Must be true or false |
blacklist | Boolean | No | Blacklist status. Must be true or false |
obd | String | No | Outbound Dialer status |
ibd | String | No | Inbound Dialer status |
pc | String | No | Preview Call status |
ctc | String | No | Click to Call status |
Notes:
-
The contact must exist in the directory to be updated.
-
Only provide the fields that need to be updated. Omitted fields will retain their existing values.
-
The API will merge the new information with existing data.
-
Ensure that the contact number is valid and in the correct format.
-
The
contactinfo
andother
objects can contain custom fields as defined in the user's contact list configuration. -
Custom fields in
contactinfo
(likecustom_field_1
,custom_field_2
) depend on the user's configuration and may vary. -
Fields in the
other
object likeobd
,ibd
,pc
,ctc
represent different dialing statuses and can have values specific to your system's configuration. -
The
source
field in theother
object typically represents how the contact was added to the system (e.g., 1 might mean "manually added", 2 might mean "imported from CSV", etc.) -
Be cautious when updating the
blacklist
field. Setting it totrue
might prevent further communication with this contact. -
All date fields should follow the format dd-mm-YYYY for consistency.
-
The API will return appropriate error codes and messages for invalid inputs, non-existent contacts, or server-side issues.
-
The
updatetime
field is typically automatically set by the system and may not be modifiable through this API.
Update
var axios = require('axios');
var data = '{"ssid":"{{ssid}}","contact":"{{callernumber}}","contactinfo":{"name":"Sunil Singh"}, "other":{"IBD":3,"OBD":4}}';
var config = {
method: 'post',
url: '{{brand}}/api/v2/Directory/update',
headers: {
'Content-Length': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
setUrl('{{brand}}/api/v2/Directory/update');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Length' => ''
));
$request->setBody('{"ssid":"{{ssid}}","contact":"{{callernumber}}","contactinfo":{"name":"Sunil Singh"}, "other":{"IBD":3,"OBD":4}}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
import http.client
conn = http.client.HTTPSConnection("{{brand}}")
payload = "{\"ssid\":\"{{ssid}}\",\"contact\":\"{{callernumber}}\",\"contactinfo\":{\"name\":\"Sunil Singh\"}, \"other\":{\"IBD\":3,\"OBD\":4}}"
headers = {
'Content-Length': ''
}
conn.request("POST", "/api/v2/Directory/update", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var client = new RestClient("{{brand}}/api/v2/Directory/update");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = @"{" + "\n" +
@" ""ssid"":""{{ssid}}""," + "\n" +
@" ""contact"":""{{callernumber}}""," + "\n" +
@" ""contactinfo"":{""name"":""Sunil Singh""}," + "\n" +
@" ""other"":{""IBD"":3,""OBD"":4}" + "\n" +
@"" + "\n" +
@"}";
request.AddParameter("text/plain", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location -g --request POST '{{brand}}/api/v2/Directory/update' \
--data-raw '{
"ssid":"{{ssid}}",
"contact":"{{callernumber}}",
"contactinfo":{"name":"Sunil Singh"},
"other":{"IBD":3,"OBD":4}
}'
var request = http.Request('POST', Uri.parse('{{brand}}/api/v2/Directory/update'));
request.body = '''{\n "ssid":"{{ssid}}",\n "contact":"{{callernumber}}",\n "contactinfo":{"name":"Sunil Singh"},\n "other":{"IBD":3,"OBD":4}\n\n}''';
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "%7B%7Bbrand%7D%7D/api/v2/Directory/update"
method := "POST"
payload := strings.NewReader(`{
"ssid":"{{ssid}}",
"contact":"{{callernumber}}",
"contactinfo":{"name":"Sunil Singh"},
"other":{"IBD":3,"OBD":4}
}`)
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))
}
POST /api/v2/Directory/update HTTP/1.1
Host: {{brand}}
Content-Length: 134
{
"ssid":"{{ssid}}",
"contact":"{{callernumber}}",
"contactinfo":{"name":"Sunil Singh"},
"other":{"IBD":3,"OBD":4}
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"ssid\":\"{{ssid}}\",\n \"contact\":\"{{callernumber}}\",\n \"contactinfo\":{\"name\":\"Sunil Singh\"},\n \"other\":{\"IBD\":3,\"OBD\":4}\n\n}");
Request request = new Request.Builder()
.url("{{brand}}/api/v2/Directory/update")
.method("POST", body)
.addHeader("Content-Length", "")
.build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Content-Length", "");
var raw = "{\n \"ssid\":\"{{ssid}}\",\n \"contact\":\"{{callernumber}}\",\n \"contactinfo\":{\"name\":\"Sunil Singh\"},\n \"other\":{\"IBD\":3,\"OBD\":4}\n\n}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("{{brand}}/api/v2/Directory/update", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "%7B%7Bbrand%7D%7D/api/v2/Directory/update");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Length: ");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\n \"ssid\":\"{{ssid}}\",\n \"contact\":\"{{callernumber}}\",\n \"contactinfo\":{\"name\":\"Sunil Singh\"},\n \"other\":{\"IBD\":3,\"OBD\":4}\n\n}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
#import
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"%7B%7Bbrand%7D%7D/api/v2/Directory/update"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Content-Length": @""
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"ssid\":\"{{ssid}}\",\n \"contact\":\"{{callernumber}}\",\n \"contactinfo\":{\"name\":\"Sunil Singh\"},\n \"other\":{\"IBD\":3,\"OBD\":4}\n\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
open Lwt
open Cohttp
open Cohttp_lwt_unix
let postData = ref "{\n \"ssid\":\"{{ssid}}\",\n \"contact\":\"{{callernumber}}\",\n \"contactinfo\":{\"name\":\"Sunil Singh\"},\n \"other\":{\"IBD\":3,\"OBD\":4}\n\n}";;
let reqBody =
let uri = Uri.of_string "%7B%7Bbrand%7D%7D/api/v2/Directory/update" in
let headers = Header.init ()
|> fun h -> Header.add h "Content-Length" ""
in
let body = Cohttp_lwt.Body.of_string !postData in
Client.call ~headers ~body `POST uri >>= fun (_resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body -> body
let () =
let respBody = Lwt_main.run reqBody in
print_endline (respBody)
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Length", "")
$body = "{`n `"ssid`":`"{{ssid}}`",`n `"contact`":`"{{callernumber}}`",`n `"contactinfo`":{`"name`":`"Sunil Singh`"},`n `"other`":{`"IBD`":3,`"OBD`":4}`n`n}"
$response = Invoke-RestMethod '{{brand}}/api/v2/Directory/update' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "net/http"
url = URI("{{brand}}/api/v2/Directory/update")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Length"] = ""
request.body = "{\n \"ssid\":\"{{ssid}}\",\n \"contact\":\"{{callernumber}}\",\n \"contactinfo\":{\"name\":\"Sunil Singh\"},\n \"other\":{\"IBD\":3,\"OBD\":4}\n\n}"
response = http.request(request)
puts response.read_body
printf '{
"ssid":"{{ssid}}",
"contact":"{{callernumber}}",
"contactinfo":{"name":"Sunil Singh"},
"other":{"IBD":3,"OBD":4}
}'| http --follow --timeout 3600 POST '{{brand}}/api/v2/Directory/update' \
Content-Length:
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)
let parameters = "{\n \"ssid\":\"{{ssid}}\",\n \"contact\":\"{{callernumber}}\",\n \"contactinfo\":{\"name\":\"Sunil Singh\"},\n \"other\":{\"IBD\":3,\"OBD\":4}\n\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{brand}}/api/v2/Directory/update")!,timeoutInterval: Double.infinity)
request.addValue("", forHTTPHeaderField: "Content-Length")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
semaphore.signal()
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Example Response
[{"key":"Date"
"value":"Thu
28 Nov 2024 05:11:47 GMT"}
{"key":"Content-Type"
"value":"application\/json; charset=utf-8"}
{"key":"Content-Length"
"value":"74"}
{"key":"Connection"
"value":"keep-alive"}
{"key":"Access-Control-Allow-Origin"
"value":"*"}
{"key":"Access-Control-Allow-Methods"
"value":"POST
GET
OPTIONS
PATCH
DELETE"}
{"key":"Access-Control-Allow-Headers"
"value":"X-Requested-With
content-type"}
{"key":"Access-Control-Allow-Credentials"
"value":"true"}
{"key":"Vary"
"value":"Origin"}
{"key":"ETag"
"value":"W\/\"4a-gQI3LNaPco2fa3tiAZFJ8Qeen2o\""}
{"key":"Strict-Transport-Security"
"value":"max-age=31536000; includeSubDomains"}]
{
"message": "Directory successfully updated",
"status": "success",
"code": 200
}