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:

  1. Using ssid (Session ID)

  2. Using userId and token

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

Update

https://ctv3-dev.sarv.com/api/v2/Agent/update

Endpoint

Description

The Update Agent endpoint allows you to modify the details of an existing agent in the system. This endpoint can be used to update various attributes of an agent, including personal information, contact details, working hours, group assignments, and status. It provides a flexible way to keep agent information up-to-date and manage their settings within the system.

Use Cases

Request Details

Parameter Type Required Description
userId string Yes User ID of the account making the request
token string Yes Authentication token for the account
agentId number Yes The ID of the agent to update
NAme string No Agent's name
mobile number No Agent's mobile number
email string No Agent's email address
address string No Agent's address
destination object No Agent's destination details for call routing
role number No Agent's role ID
type string No Agent's type (e.g., "Both", "IBD", "OBD")
parent string No Agent's parent (e.g., "root" or another agent ID)
callpwd string No Agent's call password
working object No Agent's working hours, organized by day of the week
group object No Agent's group assignments
did array No Agent's DID (Direct Inward Dialing) numbers
status number No Agent's status (0 for inactive, 1 for active)

Response Details

Success Response Structure

Field Type Description
status string Response status ("success")
code number Response code (200 for success)
message string Success message

Error Response Examples

Error Code Description Message
1507 Invalid AgentID Invalid AgentID
1514 Invalid Mobile Invalid mobile Number
1512 Email Exists Email already exists
1511 Invalid Time Working time format is invalid

Notes

Update

var axios = require('axios');
var data = '{"userId":"{{userid}}","token":"{{token}}","NAme": "Manoj Kumar111","mobile": 9887613096,"email": "manoj.rao1@snet.in","address": "address ","destination": {"type": "MOBILE","value": "9887613096"},"role": 1,"type": "Both","parent": "root","callpwd": "98765432","working": {"MON": [{"from": 0,"to": 1137},{"from": 1139,"to": 1239},{"from": 1339,"to": 1439}]},"group": {"90": "Y"},"agentId": 7,"status": 0}';

var config = {
 method: 'post',
 url: 'https://ctv3-dev.sarv.com/api/v2/Agent/update',
 headers: { 
'Content-Length': ''
 },
 data : data
};

axios(config)
.then(function (response) {
 console.log(JSON.stringify(response.data));
})
.catch(function (error) {
 console.log(error);
});
setUrl('https://ctv3-dev.sarv.com/api/v2/Agent/update');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
 'follow_redirects' => TRUE
));
$request->setHeader(array(
 'Content-Length' => ''
));
$request->setBody('{"userId":"{{userid}}","token":"{{token}}","NAme": "Manoj Kumar111","mobile": 9887613096,"email": "manoj.rao1@snet.in","address": "address ","destination": {"type": "MOBILE","value": "9887613096"},"role": 1,"type": "Both","parent": "root","callpwd": "98765432","working": {"MON": [{"from": 0,"to": 1137},{"from": 1139,"to": 1239},{"from": 1339,"to": 1439}]},"group": {"90": "Y"},"agentId": 7,"status": 0}');
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("ctv3-dev.sarv.com")
payload = "{\"userId\":\"{{userid}}\",\"token\":\"{{token}}\",\"NAme\": \"Manoj Kumar111\",\"mobile\": 9887613096,\"email\": \"manoj.rao1@snet.in\",\"address\": \"address \",\"destination\": {\"type\": \"MOBILE\",\"value\": \"9887613096\"},\"role\": 1,\"type\": \"Both\",\"parent\": \"root\",\"callpwd\": \"98765432\",\"working\": {\"MON\": [{\"from\": 0,\"to\": 1137},{\"from\": 1139,\"to\": 1239},{\"from\": 1339,\"to\": 1439}]},\"group\": {\"90\": \"Y\"},\"agentId\": 7,\"status\": 0}"
headers = {
 'Content-Length': ''
}
conn.request("POST", "/api/v2/Agent/update", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var client = new RestClient("https://ctv3-dev.sarv.com/api/v2/Agent/update");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = @"{" + "\n" +
@"    ""userId"":""{{userid}}""," + "\n" +
@"    ""token"":""{{token}}""," + "\n" +
@"    ""NAme"": ""Manoj Kumar111""," + "\n" +
@"    ""mobile"": 9887613096," + "\n" +
@"    ""email"": ""manoj.rao1@snet.in""," + "\n" +
@"    ""address"": ""address ""," + "\n" +
@"    ""destination"": {" + "\n" +
@"        ""type"": ""MOBILE""," + "\n" +
@"        ""value"": ""9887613096""" + "\n" +
@"    }," + "\n" +
@"    ""role"": 1," + "\n" +
@"    ""type"": ""Both""," + "\n" +
@"    ""parent"": ""root""," + "\n" +
@"    ""callpwd"": ""98765432""," + "\n" +
@"    ""working"": {" + "\n" +
@"        ""MON"": [" + "\n" +
@"            {" + "\n" +
@"                ""from"": 0," + "\n" +
@"                ""to"": 1137" + "\n" +
@"            }," + "\n" +
@"            {" + "\n" +
@"                ""from"": 1139," + "\n" +
@"                ""to"": 1239" + "\n" +
@"            }," + "\n" +
@"            {" + "\n" +
@"                ""from"": 1339," + "\n" +
@"                ""to"": 1439" + "\n" +
@"            }" + "\n" +
@"        ]" + "\n" +
@"    }," + "\n" +
@"    ""group"": {" + "\n" +
@"        ""90"": ""Y""" + "\n" +
@"    }," + "\n" +
@"    ""agentId"": 7," + "\n" +
@"    ""status"": 0" + "\n" +
@"}" + "\n" +
@"";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'https://ctv3-dev.sarv.com/api/v2/Agent/update' \
--data-raw '{
    "userId":"{{userid}}",
    "token":"{{token}}",
    "NAme": "Manoj Kumar111",
    "mobile": 9887613096,
    "email": "manoj.rao1@snet.in",
    "address": "address ",
    "destination": {
        "type": "MOBILE",
        "value": "9887613096"
    },
    "role": 1,
    "type": "Both",
    "parent": "root",
    "callpwd": "98765432",
    "working": {
        "MON": [
            {
                "from": 0,
                "to": 1137
            },
            {
                "from": 1139,
                "to": 1239
            },
            {
                "from": 1339,
                "to": 1439
            }
        ]
    },
    "group": {
        "90": "Y"
    },
    "agentId": 7,
    "status": 0
}'
var request = http.Request('POST', Uri.parse('https://ctv3-dev.sarv.com/api/v2/Agent/update'));
request.body = '''{\n    "userId":"{{userid}}",\n    "token":"{{token}}",\n    "NAme": "Manoj Kumar111",\n    "mobile": 9887613096,\n    "email": "manoj.rao1@snet.in",\n    "address": "address ",\n    "destination": {\n        "type": "MOBILE",\n        "value": "9887613096"\n    },\n    "role": 1,\n    "type": "Both",\n    "parent": "root",\n    "callpwd": "98765432",\n    "working": {\n        "MON": [\n            {\n                "from": 0,\n                "to": 1137\n            },\n            {\n                "from": 1139,\n                "to": 1239\n            },\n            {\n                "from": 1339,\n                "to": 1439\n            }\n        ]\n    },\n    "group": {\n        "90": "Y"\n    },\n    "agentId": 7,\n    "status": 0\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 := "https://ctv3-dev.sarv.com/api/v2/Agent/update"
   method := "POST"

   payload := strings.NewReader(`{
    "userId":"{{userid}}",
    "token":"{{token}}",
    "NAme": "Manoj Kumar111",
    "mobile": 9887613096,
    "email": "manoj.rao1@snet.in",
    "address": "address ",
    "destination": {
        "type": "MOBILE",
        "value": "9887613096"
    },
    "role": 1,
    "type": "Both",
    "parent": "root",
    "callpwd": "98765432",
    "working": {
        "MON": [
            {
                "from": 0,
                "to": 1137
            },
            {
                "from": 1139,
                "to": 1239
            },
            {
                "from": 1339,
                "to": 1439
            }
        ]
    },
    "group": {
        "90": "Y"
    },
    "agentId": 7,
    "status": 0
}`)

   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/update HTTP/1.1
Host: ctv3-dev.sarv.com
Content-Length: 720

{
    "userId":"{{userid}}",
    "token":"{{token}}",
    "NAme": "Manoj Kumar111",
    "mobile": 9887613096,
    "email": "manoj.rao1@snet.in",
    "address": "address ",
    "destination": {
        "type": "MOBILE",
        "value": "9887613096"
    },
    "role": 1,
    "type": "Both",
    "parent": "root",
    "callpwd": "98765432",
    "working": {
        "MON": [
            {
                "from": 0,
                "to": 1137
            },
            {
                "from": 1139,
                "to": 1239
            },
            {
                "from": 1339,
                "to": 1439
            }
        ]
    },
    "group": {
        "90": "Y"
    },
    "agentId": 7,
    "status": 0
}
OkHttpClient client = new OkHttpClient().newBuilder()
   .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n    \"userId\":\"{{userid}}\",\n    \"token\":\"{{token}}\",\n    \"NAme\": \"Manoj Kumar111\",\n    \"mobile\": 9887613096,\n    \"email\": \"manoj.rao1@snet.in\",\n    \"address\": \"address \",\n    \"destination\": {\n        \"type\": \"MOBILE\",\n        \"value\": \"9887613096\"\n    },\n    \"role\": 1,\n    \"type\": \"Both\",\n    \"parent\": \"root\",\n    \"callpwd\": \"98765432\",\n    \"working\": {\n        \"MON\": [\n            {\n                \"from\": 0,\n                \"to\": 1137\n            },\n            {\n                \"from\": 1139,\n                \"to\": 1239\n            },\n            {\n                \"from\": 1339,\n                \"to\": 1439\n            }\n        ]\n    },\n    \"group\": {\n        \"90\": \"Y\"\n    },\n    \"agentId\": 7,\n    \"status\": 0\n}\n");
Request request = new Request.Builder()
   .url("https://ctv3-dev.sarv.com/api/v2/Agent/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    \"userId\":\"{{userid}}\",\n    \"token\":\"{{token}}\",\n    \"NAme\": \"Manoj Kumar111\",\n    \"mobile\": 9887613096,\n    \"email\": \"manoj.rao1@snet.in\",\n    \"address\": \"address \",\n    \"destination\": {\n        \"type\": \"MOBILE\",\n        \"value\": \"9887613096\"\n    },\n    \"role\": 1,\n    \"type\": \"Both\",\n    \"parent\": \"root\",\n    \"callpwd\": \"98765432\",\n    \"working\": {\n        \"MON\": [\n            {\n                \"from\": 0,\n                \"to\": 1137\n            },\n            {\n                \"from\": 1139,\n                \"to\": 1239\n            },\n            {\n                \"from\": 1339,\n                \"to\": 1439\n            }\n        ]\n    },\n    \"group\": {\n        \"90\": \"Y\"\n    },\n    \"agentId\": 7,\n    \"status\": 0\n}\n";

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: raw,
   redirect: 'follow'
};

fetch("https://ctv3-dev.sarv.com/api/v2/Agent/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, "https://ctv3-dev.sarv.com/api/v2/Agent/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    \"userId\":\"{{userid}}\",\n    \"token\":\"{{token}}\",\n    \"NAme\": \"Manoj Kumar111\",\n    \"mobile\": 9887613096,\n    \"email\": \"manoj.rao1@snet.in\",\n    \"address\": \"address \",\n    \"destination\": {\n        \"type\": \"MOBILE\",\n        \"value\": \"9887613096\"\n    },\n    \"role\": 1,\n    \"type\": \"Both\",\n    \"parent\": \"root\",\n    \"callpwd\": \"98765432\",\n    \"working\": {\n        \"MON\": [\n            {\n                \"from\": 0,\n                \"to\": 1137\n            },\n            {\n                \"from\": 1139,\n                \"to\": 1239\n            },\n            {\n                \"from\": 1339,\n                \"to\": 1439\n            }\n        ]\n    },\n    \"group\": {\n        \"90\": \"Y\"\n    },\n    \"agentId\": 7,\n    \"status\": 0\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:@"https://ctv3-dev.sarv.com/api/v2/Agent/update"]
   cachePolicy:NSURLRequestUseProtocolCachePolicy
   timeoutInterval:10.0];
NSDictionary *headers = @{
   @"Content-Length": @""
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n    \"userId\":\"{{userid}}\",\n    \"token\":\"{{token}}\",\n    \"NAme\": \"Manoj Kumar111\",\n    \"mobile\": 9887613096,\n    \"email\": \"manoj.rao1@snet.in\",\n    \"address\": \"address \",\n    \"destination\": {\n        \"type\": \"MOBILE\",\n        \"value\": \"9887613096\"\n    },\n    \"role\": 1,\n    \"type\": \"Both\",\n    \"parent\": \"root\",\n    \"callpwd\": \"98765432\",\n    \"working\": {\n        \"MON\": [\n            {\n                \"from\": 0,\n                \"to\": 1137\n            },\n            {\n                \"from\": 1139,\n                \"to\": 1239\n            },\n            {\n                \"from\": 1339,\n                \"to\": 1439\n            }\n        ]\n    },\n    \"group\": {\n        \"90\": \"Y\"\n    },\n    \"agentId\": 7,\n    \"status\": 0\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    \"userId\":\"{{userid}}\",\n    \"token\":\"{{token}}\",\n    \"NAme\": \"Manoj Kumar111\",\n    \"mobile\": 9887613096,\n    \"email\": \"manoj.rao1@snet.in\",\n    \"address\": \"address \",\n    \"destination\": {\n        \"type\": \"MOBILE\",\n        \"value\": \"9887613096\"\n    },\n    \"role\": 1,\n    \"type\": \"Both\",\n    \"parent\": \"root\",\n    \"callpwd\": \"98765432\",\n    \"working\": {\n        \"MON\": [\n            {\n                \"from\": 0,\n                \"to\": 1137\n            },\n            {\n                \"from\": 1139,\n                \"to\": 1239\n            },\n            {\n                \"from\": 1339,\n                \"to\": 1439\n            }\n        ]\n    },\n    \"group\": {\n        \"90\": \"Y\"\n    },\n    \"agentId\": 7,\n    \"status\": 0\n}";;

let reqBody = 
   let uri = Uri.of_string "https://ctv3-dev.sarv.com/api/v2/Agent/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    `"userId`":`"{{userid}}`",`n    `"token`":`"{{token}}`",`n    `"NAme`": `"Manoj Kumar111`",`n    `"mobile`": 9887613096,`n    `"email`": `"manoj.rao1@snet.in`",`n    `"address`": `"address `",`n    `"destination`": {`n        `"type`": `"MOBILE`",`n        `"value`": `"9887613096`"`n    },`n    `"role`": 1,`n    `"type`": `"Both`",`n    `"parent`": `"root`",`n    `"callpwd`": `"98765432`",`n    `"working`": {`n        `"MON`": [`n            {`n                `"from`": 0,`n                `"to`": 1137`n            },`n            {`n                `"from`": 1139,`n                `"to`": 1239`n            },`n            {`n                `"from`": 1339,`n                `"to`": 1439`n            }`n        ]`n    },`n    `"group`": {`n        `"90`": `"Y`"`n    },`n    `"agentId`": 7,`n    `"status`": 0`n}`n"

$response = Invoke-RestMethod 'https://ctv3-dev.sarv.com/api/v2/Agent/update' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "net/http"

url = URI("https://ctv3-dev.sarv.com/api/v2/Agent/update")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Length"] = ""
request.body = "{\n    \"userId\":\"{{userid}}\",\n    \"token\":\"{{token}}\",\n    \"NAme\": \"Manoj Kumar111\",\n    \"mobile\": 9887613096,\n    \"email\": \"manoj.rao1@snet.in\",\n    \"address\": \"address \",\n    \"destination\": {\n        \"type\": \"MOBILE\",\n        \"value\": \"9887613096\"\n    },\n    \"role\": 1,\n    \"type\": \"Both\",\n    \"parent\": \"root\",\n    \"callpwd\": \"98765432\",\n    \"working\": {\n        \"MON\": [\n            {\n                \"from\": 0,\n                \"to\": 1137\n            },\n            {\n                \"from\": 1139,\n                \"to\": 1239\n            },\n            {\n                \"from\": 1339,\n                \"to\": 1439\n            }\n        ]\n    },\n    \"group\": {\n        \"90\": \"Y\"\n    },\n    \"agentId\": 7,\n    \"status\": 0\n}"

response = https.request(request)
puts response.read_body
printf '{
    "userId":"{{userid}}",
    "token":"{{token}}",
    "NAme": "Manoj Kumar111",
    "mobile": 9887613096,
    "email": "manoj.rao1@snet.in",
    "address": "address ",
    "destination": {
        "type": "MOBILE",
        "value": "9887613096"
    },
    "role": 1,
    "type": "Both",
    "parent": "root",
    "callpwd": "98765432",
    "working": {
        "MON": [
            {
                "from": 0,
                "to": 1137
            },
            {
                "from": 1139,
                "to": 1239
            },
            {
                "from": 1339,
                "to": 1439
            }
        ]
    },
    "group": {
        "90": "Y"
    },
    "agentId": 7,
    "status": 0
}
'| http  --follow --timeout 3600 POST 'https://ctv3-dev.sarv.com/api/v2/Agent/update' \
 Content-Length:
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let parameters = "{\n    \"userId\":\"{{userid}}\",\n    \"token\":\"{{token}}\",\n    \"NAme\": \"Manoj Kumar111\",\n    \"mobile\": 9887613096,\n    \"email\": \"manoj.rao1@snet.in\",\n    \"address\": \"address \",\n    \"destination\": {\n        \"type\": \"MOBILE\",\n        \"value\": \"9887613096\"\n    },\n    \"role\": 1,\n    \"type\": \"Both\",\n    \"parent\": \"root\",\n    \"callpwd\": \"98765432\",\n    \"working\": {\n        \"MON\": [\n            {\n                \"from\": 0,\n                \"to\": 1137\n            },\n            {\n                \"from\": 1139,\n                \"to\": 1239\n            },\n            {\n                \"from\": 1339,\n                \"to\": 1439\n            }\n        ]\n    },\n    \"group\": {\n        \"90\": \"Y\"\n    },\n    \"agentId\": 7,\n    \"status\": 0\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://ctv3-dev.sarv.com/api/v2/Agent/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":"Sat
 16 Nov 2024 15:04:50 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-mu7mX6JZ4mg\/ERjl\/DR13l7r6D4\""}
{"key":"Strict-Transport-Security"
"value":"max-age=15724800; includeSubDomains"}]
 {
    "status": "success",
    "code": 200,
    "message": "Your data successfully updated"
}