V 2.0
Agent
Introduction
This document provides detailed information about the API endpoints available in the Agent.js file. It includes request parameters, response formats, and examples for each endpoint.
Base URL
The base URL for all API endpoints is: deepcall/api/v2/Agent
Authentication
Authentication is required for all endpoints. It can be done in two ways:
-
Using
ssid
(Session ID) -
Using
userId
andtoken
Note: When userId
and token
are used, ssid
should not be present in the request.
Error Codes
Error Code | Description |
---|---|
1501 | Data already in processing |
1502 | Invalid filter value |
1503 | Invalid role id |
1504 | Invalid parent |
1505 | Invalid group data |
1506 | AgentId and parent could not be same |
1507 | Invalid AgentID |
1508 | Invalid status value |
1509 | Invalid agentId |
1510 | Invalid Destination |
1511 | Working time format is invalid |
1512 | Email already exists |
1513 | Invalid type |
1514 | Invalid mobile Number |
1515 | Invalid Name |
1516 | Invalid Did Number |
1517 | Your agentid and your loginid must be same |
1518 | Data could not be updated |
1519 | Call Password must be Integer and Eight digit |
1520 | You must be single field update |
1521 | Please Provide Only Valid fields |
1522 | You could not inserted your data. Please try again |
1523 | Your agent information is already added |
1524 | Invalid Action |
1525 | Invalid Targetagent Id |
1526 | Invalid Id |
1527 | Invalid Type |
1528 | Invalid Favorite Data |
1529 | Invalid Domain |
1530 | Invalid Agent Timing |
List
Endpoint
- Method: POST
-
Path:
deepcall/api/v2/Agent/list/
Description
The List Agents endpoint provides a list of agents based on specified criteria. This endpoint allows you to retrieve agent information, which can be filtered by various parameters such as group, name, or status. It's useful for populating agent lists in user interfaces, generating reports, or performing bulk operations on agents.
Use Cases
- Retrieving a list of all agents in the system
- Filtering agents by group, name, or status
- Populating agent selection dropdowns in user interfaces
- Generating agent reports
- Performing bulk operations on a subset of agents
Request Details
Parameter | Type | Required | Description |
---|---|---|---|
ssid | string | No | Session ID (required if token is not used) |
userId | string | No | User ID (required if ssid is not used) |
token | string | No | Authentication token (required if ssid is not used) |
agentId | string | No | Specific agent ID to retrieve (if omitted, returns all agents) |
name | string | No | Filter agents by name (partial match) |
groupid | string | No | Filter agents by group ID |
quick | boolean | No | Flag for quick fetch (returns minimal agent data) |
Response Details
Success Response Structure
Field | Type | Description |
---|---|---|
response | object | Map of agent IDs to agent details |
response[agentId].nm | string | Agent's name |
response[agentId].email | string | Agent's email address |
response[agentId].phone | string | Agent's phone number |
response[agentId].dest_type | string | Destination type (e.g., "MOBILE", "SIP") |
response[agentId].dest_value | string | Destination value |
response[agentId].group | array | List of group IDs the agent belongs to |
response[agentId].status | number | Agent's status (1: active, 0: inactive) |
status | string | Response status ("success" or "error") |
code | number | Response code (200 for success) |
Error Response Examples
Error Code | Description | Message |
---|---|---|
1014 | Invalid Session/Token | Invalid token |
1006 | Invalid Group ID | GroupId does not exist |
1015 | Permission Denied | Permission denied |
Notes
- Authentication can be done either through
ssid
(Session ID) oruserId
andtoken
combination - If
agentId
is provided, the response will contain information for only that specific agent - The
name
parameter allows partial matching (e.g., "John" matches "John Doe" and "John Smith") - When
quick
is set to true, the response includes only essential agent information - The response is a JSON object where keys are agent IDs and values are agent details
- The
group
field in the response is an array of group IDs that the agent belongs to - The
status
field indicates whether the agent is active (1) or inactive (0) - If no matching agents are found, the response will contain an empty object
- Ensure that the user making the request has the necessary permissions
- This endpoint can be resource-intensive for large numbers of agents
- Consider using pagination or limiting result set size for large numbers of agents
List
var axios = require('axios');
var data = '{"ssid":"{{ssid}}"}';
var config = {
method: 'post',
url: '{{brand}}/api/v2/Agent/list',
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/Agent/list');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Length' => ''
));
$request->setBody('{"ssid":"{{ssid}}"}');
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}}\"}"
headers = {
'Content-Length': ''
}
conn.request("POST", "/api/v2/Agent/list", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var client = new RestClient("{{brand}}/api/v2/Agent/list");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = @"{""ssid"":""{{ssid}}""}";
request.AddParameter("text/plain", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location -g --request POST '{{brand}}/api/v2/Agent/list' \
--data-raw '{"ssid":"{{ssid}}"}'
var request = http.Request('POST', Uri.parse('{{brand}}/api/v2/Agent/list'));
request.body = '''{"ssid":"{{ssid}}"}''';
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/Agent/list"
method := "POST"
payload := strings.NewReader(`{"ssid":"{{ssid}}"}`)
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/Agent/list HTTP/1.1
Host: {{brand}}
Content-Length: 19
{"ssid":"{{ssid}}"}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\"ssid\":\"{{ssid}}\"}");
Request request = new Request.Builder()
.url("{{brand}}/api/v2/Agent/list")
.method("POST", body)
.addHeader("Content-Length", "")
.build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Content-Length", "");
var raw = "{\"ssid\":\"{{ssid}}\"}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("{{brand}}/api/v2/Agent/list", 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/Agent/list");
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 = "{\"ssid\":\"{{ssid}}\"}";
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/Agent/list"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Content-Length": @""
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\"ssid\":\"{{ssid}}\"}" 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 "{\"ssid\":\"{{ssid}}\"}";;
let reqBody =
let uri = Uri.of_string "%7B%7Bbrand%7D%7D/api/v2/Agent/list" 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 = "{`"ssid`":`"{{ssid}}`"}"
$response = Invoke-RestMethod '{{brand}}/api/v2/Agent/list' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "net/http"
url = URI("{{brand}}/api/v2/Agent/list")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Length"] = ""
request.body = "{\"ssid\":\"{{ssid}}\"}"
response = http.request(request)
puts response.read_body
printf '{"ssid":"{{ssid}}"}'| http --follow --timeout 3600 POST '{{brand}}/api/v2/Agent/list' \
Content-Length:
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)
let parameters = "{\"ssid\":\"{{ssid}}\"}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{brand}}/api/v2/Agent/list")!,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":"Sat
16 Nov 2024 10:26:44 GMT"}
{"key":"Content-Type"
"value":"application\/json; charset=utf-8"}
{"key":"Content-Length"
"value":"4071"}
{"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\/\"fe7-30uhzmrg7pv5D\/V6jqxisE0t0xc\""}
{"key":"Strict-Transport-Security"
"value":"max-age=15724800; includeSubDomains"}]
{
"response": [
{
"name": "bhawesh",
"favorite": "",
"email": "bbx12345@gmail.com",
"phone": "918442021533",
"address": "jaipur",
"dest_type": "MOBILE",
"dest_value": "8442021533",
"call_pass": "52597981",
"role": "1",
"password": "37p9PlzD4kUUeHsq",
"parent": ",START,",
"create_date": 1720093436,
"create_by": "29791451",
"create_by_type": "",
"user_id": "29791451",
"unique_id": 2,
"allowDid": "",
"status": 1,
"isDeleted": 0,
"preDeleted": 1,
"group": [
17,
4,
28
],
"working": [
{
"wDays": [
"TUE",
"WED"
],
"from": 60,
"to": 360,
"agentId": 2
}
],
"groupNames": [
{
"17": "Perm"
},
{
"4": "Unknown group (4)"
},
{
"28": "Mahipal singh"
}
],
"roleName": "test"
},
{
"name": "bhawesh",
"favorite": "",
"email": "bbxa12345@gmail.com",
"phone": "918442021533",
"address": "jaipur",
"dest_type": "MOBILE",
"dest_value": "8442021533",
"call_pass": "7672883",
"role": "1",
"password": "O6gPdpU4emnt3lLC",
"parent": ",START,",
"create_date": 1720093558,
"create_by": "29791451",
"create_by_type": "",
"user_id": "29791451",
"unique_id": 3,
"allowDid": "",
"status": 1,
"isDeleted": 0,
"preDeleted": 0,
"group": [
27,
4,
28
],
"working": [
{
"wDays": [
"TUE",
"WED",
"THU",
"FRI"
],
"from": 60,
"to": 360,
"agentId": 3
}
],
"groupNames": [
{
"27": "Perm"
},
{
"4": "Unknown group (4)"
},
{
"28": "Mahipal singh"
}
],
"roleName": "test"
},
{
"name": "vijay developer",
"favorite": "",
"email": "vijay.k@sarv.com",
"phone": "919694730287",
"address": "jaipur",
"dest_type": "MOBILE",
"dest_value": "7976522803",
"call_pass": "91939863",
"role": "1",
"password": "vijay123",
"parent": ",START,",
"create_date": 1720094014,
"create_by": "29791451",
"create_by_type": "",
"user_id": "29791451",
"unique_id": 4,
"allowDid": "",
"status": 1,
"isDeleted": 0,
"preDeleted": 0,
"group": [
17,
18,
4,
28
],
"working": [
{
"wDays": [
"MON",
"TUE",
"WED",
"THU",
"FRI",
"SAT"
],
"from": 0,
"to": 1380,
"agentId": 4
}
],
"groupNames": [
{
"17": "Perm"
},
{
"18": "Manoj Rao"
},
{
"4": "Unknown group (4)"
},
{
"28": "Mahipal singh"
}
],
"roleName": "test"
},
{
"name": "Brijendra",
"favorite": "",
"email": "brijendra.u@sarv.com",
"phone": "919198765432",
"address": "jaipur",
"dest_type": "MOBILE",
"dest_value": "7790985399",
"call_pass": "46876828",
"role": "1",
"password": "jKyhuSn7s945GCm1",
"parent": ",START,4,",
"create_date": 1720094457,
"create_by": "29791451",
"create_by_type": "",
"user_id": "29791451",
"unique_id": 5,
"allowDid": "",
"status": 1,
"isDeleted": 0,
"preDeleted": 0,
"group": [
13,
4,
15,
16,
17
],
"working": [
{
"wDays": [
"MON",
"TUE",
"WED",
"THU",
"FRI",
"SAT",
"SUN"
],
"from": 0,
"to": 1439,
"agentId": 5
}
],
"groupNames": [
{
"13": "Test_Group"
},
{
"4": "Unknown group (4)"
},
{
"15": "Test_Group"
},
{
"16": "Test_Group"
},
{
"17": "Perm"
}
],
"roleName": "test"
},
{
"name": "Bhawna",
"favorite": "",
"email": "bhawna@gmail.com",
"phone": "919680260884",
"address": "Jhotwara",
"dest_type": "MOBILE",
"dest_value": "9680260884",
"call_pass": "26665787",
"role": "1",
"password": "7kqHDrCGoDRpezJs",
"parent": ",START,",
"create_date": 1720182491,
"create_by": "29791451",
"create_by_type": "",
"user_id": "29791451",
"unique_id": 6,
"allowDid": [
"918645313598"
],
"status": 1,
"isDeleted": 0,
"preDeleted": 0,
"group": [
17,
19
],
"working": [
{
"wDays": [
"MON",
"TUE",
"WED",
"THU",
"FRI"
],
"from": 540,
"to": 1260,
"agentId": 6
}
],
"groupNames": [
{
"17": "Perm"
},
{
"19": "Test_Group"
}
],
"roleName": "test"
},
{
"name": "manoj",
"favorite": "",
"email": "manoj.rao@snet.in",
"phone": "919887613096",
"address": "",
"dest_type": "MOBILE",
"dest_value": "9887613096",
"call_pass": "4729184",
"role": "1",
"password": "fSerSQXiEabXQWs6",
"parent": ",START,",
"create_date": 1729839646,
"create_by": "29791451",
"create_by_type": "",
"user_id": "29791451",
"unique_id": 8,
"allowDid": "",
"status": 1,
"isDeleted": 0,
"preDeleted": 0,
"group": [],
"working": [
{
"wDays": [
"FRI"
],
"from": 0,
"to": 0,
"agentId": 8
}
],
"groupNames": [],
"roleName": "test"
},
{
"name": "Sumit",
"favorite": "",
"email": "sdgfajsd@sarv.com",
"phone": "919876543210",
"address": "",
"dest_type": "MOBILE",
"dest_value": "9876543210",
"call_pass": "6218865",
"role": "1",
"password": "QJmpy7KOd3DaLgqu",
"parent": ",START,",
"create_date": 1729840759,
"create_by": "29791451",
"create_by_type": "",
"user_id": "29791451",
"unique_id": 9,
"allowDid": "",
"status": 1,
"isDeleted": 0,
"preDeleted": 0,
"group": [],
"working": [
{
"wDays": [
"FRI"
],
"from": 0,
"to": 0,
"agentId": 9
}
],
"groupNames": [],
"roleName": "test"
}
],
"agtLimit": 12,
"currentPage": 1,
"totalPages": 1,
"totalRecords": 7,
"status": "success",
"code": 200
}