V 2.0
Role
Overview
The Role provides endpoints to manage user roles within the system. It enables operations such as creating, updating, and listing roles with their associated permissions.
Key Features:
-
Role Management:
- Create new roles with specific permissions
- Update existing role properties
- List all roles with pagination support
- Filter roles based on status and custom parameters
-
Authentication:
- Supports session-based authentication (SSID)
- Supports token-based authentication
- Role-based access control
-
Access Control:
- Visibility settings for roles
- Status management (active/inactive)
- User-specific role assignments
List
{{brand}}/api/v2/role/list
Endpoint
-
Method:
POST
-
Path:
deepcall/api/v2/role/list/
Description
This endpoint retrieves a paginated list of users based on applied filters and role-based access.
Use Case
- Fetching users based on search parameters.
- Filtering users by status (active, inactive, deleted).
- Implementing role-based access control.
- Paginating results for better performance.
Request Parameters
Name | Type | Required | Description |
---|---|---|---|
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) |
agentid |
String |
No | ID of the agent (default: null ) |
status |
String |
No | User status filter. Possible values: "active" , "inactive" , "deleted" |
search_params |
Object |
No | Additional search filters (default: {} ) |
page |
Integer |
No | Page number for pagination (default: 1 ) |
limit |
Integer |
No | Number of records per page (default: 10 ) |
Status Filtering Logic
Status Value | Effect |
---|---|
active |
Fetches active users (statusFilter = 1 ) |
inactive |
Fetches inactive users (statusFilter = 0 ) |
deleted |
Fetches deleted users (isDelete = 1 ) |
Pagination
- The
page
parameter determines the starting point for data retrieval. - The
limit
parameter sets the number of records per page. - The API calculates
offset = (page - 1) * limit
to fetch paginated results.
List
var axios = require('axios');
var data = '{"ssid":"{{ssid}}","search_params":{}}';
var config = {
method: 'post',
url: '{{brand}}/api/v2/role/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/role/list');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Length' => ''
));
$request->setBody('{"ssid":"{{ssid}}","search_params":{}}');
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}}\",\"search_params\":{}}"
headers = {
'Content-Length': ''
}
conn.request("POST", "/api/v2/role/list", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var client = new RestClient("{{brand}}/api/v2/role/list");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = @"{" + "\n" +
@" ""ssid"":""{{ssid}}""," + "\n" +
@" ""search_params"":{}" + "\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/role/list' \
--data-raw '{
"ssid":"{{ssid}}",
"search_params":{}
}'
var request = http.Request('POST', Uri.parse('{{brand}}/api/v2/role/list'));
request.body = '''{\n "ssid":"{{ssid}}",\n "search_params":{}\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/role/list"
method := "POST"
payload := strings.NewReader(`{
"ssid":"{{ssid}}",
"search_params":{}
}`)
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/role/list HTTP/1.1
Host: {{brand}}
Content-Length: 49
{
"ssid":"{{ssid}}",
"search_params":{}
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"ssid\":\"{{ssid}}\",\n \"search_params\":{}\n}");
Request request = new Request.Builder()
.url("{{brand}}/api/v2/role/list")
.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 \"search_params\":{}\n}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("{{brand}}/api/v2/role/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/role/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 = "{\n \"ssid\":\"{{ssid}}\",\n \"search_params\":{}\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/role/list"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Content-Length": @""
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"ssid\":\"{{ssid}}\",\n \"search_params\":{}\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 \"search_params\":{}\n}";;
let reqBody =
let uri = Uri.of_string "%7B%7Bbrand%7D%7D/api/v2/role/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 = "{`n `"ssid`":`"{{ssid}}`",`n `"search_params`":{}`n}"
$response = Invoke-RestMethod '{{brand}}/api/v2/role/list' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "net/http"
url = URI("{{brand}}/api/v2/role/list")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Length"] = ""
request.body = "{\n \"ssid\":\"{{ssid}}\",\n \"search_params\":{}\n}"
response = http.request(request)
puts response.read_body
printf '{
"ssid":"{{ssid}}",
"search_params":{}
}'| http --follow --timeout 3600 POST '{{brand}}/api/v2/role/list' \
Content-Length:
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)
let parameters = "{\n \"ssid\":\"{{ssid}}\",\n \"search_params\":{}\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{brand}}/api/v2/role/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":"Wed
29 Jan 2025 12:28:04 GMT"}
{"key":"Content-Type"
"value":"application\/json; charset=utf-8"}
{"key":"Content-Length"
"value":"483"}
{"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\/\"1e3-q4ZNGrwMaPdjclB\/i0RMp+yJwlI\""}
{"key":"Strict-Transport-Security"
"value":"max-age=15724800; includeSubDomains"}]
{
"response": [
{
"_id": "668675ac04b7d8d561039cdd",
"name": "test",
"can_see": 1,
"create_date": 1720087980,
"create_by": "29791451",
"create_by_type": "client",
"status": 1,
"user_id": "29791451",
"unique_id": 1,
"agCount": 22
},
{
"_id": "6780f0c16f14caa5d50d5ad8",
"name": "Test me",
"can_see": 1,
"create_date": 1736503489,
"create_by": "29791451",
"create_by_type": "client",
"status": 1,
"user_id": "29791451",
"unique_id": 26,
"agCount": 0
}
],
"currentPage": 1,
"totalPages": 1,
"totalRecords": 2,
"status": "success",
"code": 200
}