V 2.0
Employee
Description
The Employee API provides comprehensive functionality to manage employees (agents) in a call center environment. It offers detailed capabilities for creating, updating, listing, and managing employee information including their roles, working hours, group assignments, and destination configurations. This API is essential for HR managers, administrators, and supervisors to maintain and monitor employee data in real-time.
Authentication
All endpoints require authentication using either:
-
A session ID (SSID), or
-
A combination of User ID and Token
Ensure that you provide the necessary authentication parameters with each request.
Authentication Methods
-
Session ID Authentication
-
Use the
ssidparameter -
Provides a quick and simple authentication method
-
-
User ID and Token Authentication
-
Requires both
userIdandtokenparameters -
Offers more granular access control
-
Note: When userId and token are used, ssid should not be present in the request.
Error Codes
Employee API Specific Error Codes
| Error Code | Description | Potential Cause | Recommended Action |
|---|---|---|---|
| 1000 | Invalid parameters | The provided parameters are incorrect or malformed | Review and correct the request parameters |
| 1014 | Invalid token | Authentication token is invalid or expired | Re-authenticate and obtain a new token |
| 1015 | Permission denied | User lacks required permissions | Verify user permissions (ADD_EMPLOYEE, EDIT_EMPLOYEES, VIEW_AGENTS, etc.) |
| 1047 | Invalid request (empty body) | Request body is empty or not provided | Ensure request body contains required data |
| 1501 | Data already in processing | A similar request is currently being processed | Wait and retry the request after a short interval |
| 1502 | Invalid filter value | The provided filter parameters are incorrect or malformed | Review and correct the filter parameters |
| 1503 | Invalid role id | The provided role ID does not exist | Verify the role ID exists in your account |
| 1504 | Invalid parent | Parent employee ID is invalid or not found | Provide a valid parent ID or use "root" |
| 1505 | Invalid group data | Group assignment data is malformed or group IDs don't exist | Verify all group IDs exist in your account |
| 1506 | Employee and parent could not be same | Attempting to set employee as their own parent | Choose a different parent employee |
| 1507 | Invalid AgentID | The provided agent/employee ID is invalid | Verify the employee ID is correct |
| 1508 | Invalid status value | Status value must be 0 or 1 | Use 0 for inactive, 1 for active |
| 1509 | Invalid employee | Employee not found or user unauthorized to access | Verify employee exists and you have access |
| 1510 | Invalid destination | Destination type or value is invalid | Verify destination type (MOBILE, SIP, etc.) and value |
| 1511 | Working time format is invalid | Working hours are not in correct format or range | Use minutes from midnight (0-1439) |
| 1512 | Email already exists | The email address is already registered | Use a unique email address |
| 1513 | Invalid type | Employee type is invalid | Use valid types: "Both", "Inbound", "Outbound" |
| 1514 | Invalid mobile number | Mobile number format is incorrect | Provide a valid mobile number |
| 1515 | Invalid name | Employee name is empty or invalid | Provide a valid employee name |
| 1516 | Invalid DID number | DID number format is incorrect | Verify DID number format |
| 1517 | Your agentid and your loginid must be same | Agent trying to modify another agent's data | Agents can only modify their own data |
| 1518 | Data could not be updated | Database update operation failed | Try again or contact support |
| 1519 | Call password must be minimum 6 digits (update) / 8 digits (create) | Call password length requirement not met | Provide password meeting length requirement |
| 1520 | You must be single field update | Multiple fields provided when single field expected | Update only one field at a time |
| 1521 | Please provide only valid fields | Request contains invalid or unknown fields | Remove invalid fields from request |
| 1522 | Data could not be inserted | Database insert operation failed | Try again or contact support |
| 1523 | Your agent information is already added | Duplicate employee creation attempt | Employee already exists with this information |
| 1524 | Invalid action | The requested action is not valid | Verify the action parameter |
| 1525 | Invalid target agent ID | Target agent ID for operation is invalid | Provide a valid target agent ID |
| 1526 | Invalid ID | The provided ID is invalid | Verify the ID parameter |
| 1527 | Invalid type | Type parameter value is invalid | Use a valid type value |
| 1528 | Invalid favorite data | Favorite data format is incorrect | Verify favorite data structure |
| 1529 | Invalid domain | Domain parameter is invalid | Provide a valid domain |
| 1530 | Invalid agent timing | Agent timing data is incorrect | Verify timing format and values |
| 1532 | Employee limit reached | Account has reached maximum employee limit | Upgrade plan or deactivate unused employees |
| 1534 | PreDelete value exceeds limit of 2 | PreDelete counter exceeds maximum allowed value | Contact support to resolve |
Additional Error Handling Guidelines
-
Always check the response status before processing the data
-
Implement error handling mechanisms in your application
-
Log error codes for troubleshooting and monitoring
-
Consult the main SarvErrors documentation for comprehensive error code references
Best Practices
-
Validate all input parameters before making a request
-
Handle potential authentication failures gracefully
-
Implement appropriate error handling and retry mechanisms
-
Use the most specific authentication method for your use case
-
Be mindful of request frequency to prevent server overload
-
Check employee limits before creating or activating employees
-
Ensure email uniqueness across all employees
-
Use proper working hours format (minutes from midnight: 0-1439)
-
Validate role and group IDs before assignment
-
Use partial updates when modifying employee data - only send fields that need to change
-
Monitor change logs for audit trail and compliance
-
Test with single employee before performing bulk operations
Working Hours Format
Working hours are specified in minutes from midnight (0-1439):
- 0 = 12:00 AM (midnight)
- 60 = 1:00 AM
- 540 = 9:00 AM
- 1080 = 6:00 PM
- 1439 = 11:59 PM
Example:
{
"MON": [
{ "from": 540, "to": 1080 } // 9:00 AM to 6:00 PM
],
"TUE": [
{ "from": 540, "to": 1080 }
]
}
Multiple time slots per day:
{
"MON": [
{ "from": 0, "to": 1137 }, // 12:00 AM to 6:57 PM
{ "from": 1139, "to": 1239 }, // 6:59 PM to 8:39 PM
{ "from": 1339, "to": 1439 } // 10:19 PM to 11:59 PM
]
}
Destination Types
Common destination types for employee call routing:
| Type | Description | Example Value |
|---|---|---|
| MOBILE | Mobile phone number | "9876543210" |
| SIP | SIP endpoint/extension | "sip:user@domain.com" |
| LANDLINE | Landline phone number | "0123456789" |
| WEBRTC | WebRTC endpoint | "webrtc:endpoint" |
Employee Status Values
| Status | Value | Description |
|---|---|---|
| Active | 1 | Employee is active and can receive calls |
| Inactive | 0 | Employee is inactive and cannot receive calls |
Parent Hierarchy Values
Valid parent values for employee hierarchy:
- "root" - Top level parent
- "ROOT" - Top level parent (alternative)
- "START" - Top level parent (alternative)
- Employee ID - Any existing employee's unique_id
Permissions Required
Different operations require different permissions:
| Operation | Permission |
|---|---|
| Create Employee | ADD_EMPLOYEE |
| Update Employee | EDIT_EMPLOYEES |
| View Employees | VIEW_AGENTS or VIEW_ALL_AGENTS |
| Delete Employee | DELETE_EMPLOYEE |
Note: Permissions can be bypassed by setting forward=true in the request (admin only).
Recommendation
For a complete understanding of all possible error codes and their implications, refer to the comprehensive SarvErrors documentation.
The documentation now provides a clear, structured overview of the Employee API's error handling, authentication methods, and best practices. The error codes table includes additional context like potential causes and recommended actions to help developers better understand and resolve issues.
Create
Introduction
This document provides detailed information about the Employee Create API endpoint. It includes request parameters, response formats, and examples.
Base URL
The base URL for this API endpoint is: {{domain}}/api/v2/Employee
Authentication
Authentication is required for this endpoint. It can be done in two ways:
- Using
ssid(Session ID) - Using
userIdandtoken
Note: When userId and token are used, ssid should not be present in the request.
Create Employee
Endpoint
- Method: POST
-
Path:
{{domain}}/api/v2/Employee/create
Description
The Create Employee endpoint allows you to add a new employee to the system. This endpoint validates all input data, checks employee limits, and creates the employee with proper group assignments and working hours.
Use Cases
- Adding a new employee to the call center system
- Setting up employee accounts during onboarding
- Creating employee profiles with specific roles and permissions
- Assigning employees to groups and setting working hours
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes* | User ID for authentication (*required if ssid not provided) |
| token | string | Yes* | Authentication token (*required if ssid not provided) |
| ssid | string | Yes* | Session ID (*required if userId/token not provided) |
| name | string | Yes | Employee's full name |
| string | Yes | Employee's email address (must be unique) | |
| mobile | number | Yes | Employee's mobile number |
| address | string | No | Employee's address |
| destination | object | Yes | Destination configuration for call routing |
| destination.type | string | Yes | Destination type (e.g., "MOBILE", "SIP", "LANDLINE") |
| destination.value | string | Yes | Destination value (phone number or endpoint) |
| role | number | Yes | Employee's role ID (must exist in system) |
| type | string | Yes | Employee type (e.g., "Both", "Inbound", "Outbound") |
| parent | string | No | Parent employee ID or "root" (default: "root") |
| callpwd | string | No | 8-digit call password (auto-generated if not provided) |
| working | object | Yes | Working hours configuration by day |
| working.[DAY] | array | Yes | Array of time slots for each day (MON, TUE, WED, THU, FRI, SAT, SUN) |
| working.[DAY][].from | number | Yes | Start time in minutes from midnight (0-1439) |
| working.[DAY][].to | number | Yes | End time in minutes from midnight (0-1439) |
| group | object | No | Group assignments (key: group ID, value: "Y" or "N") |
| forward | boolean | No | Skip permission check if true (default: false) |
Request Example
With Token and UserId
{
"userId": "{{userid}}",
"token": "{{token}}",
"name": "XXXX XXXXX",
"mobile": 91XXXXXXXXXX,
"email": "xxxx.xxxx@example.com",
"address": "XXXXXXX",
"destination": {
"type": "MOBILE",
"value": "XXXXXXXXXX"
},
"role": XX,
"type": "Both",
"parent": "root",
"callpwd": "XXXXXXXX",
"working": {
"MON": [
{
"from": 0,
"to": 1137
},
{
"from": 1139,
"to": 1239
},
{
"from": 1339,
"to": 1439
}
]
},
"group": {
"{{groupid}}": "Y"
}
}
Working Hours Format
Working hours are specified in minutes from midnight (0-1439):
- 0 = 12:00 AM (midnight)
- 60 = 1:00 AM
- 540 = 9:00 AM
- 1080 = 6:00 PM
- 1137 = 6:57 PM
- 1439 = 11:59 PM
Example:
{
"MON": [
{ "from": 540, "to": 1080 } // 9:00 AM to 6:00 PM
],
"TUE": [{ "from": 540, "to": 1080 }]
}
Multiple time slots per day:
{
"MON": [
{ "from": 0, "to": 1137 }, // 12:00 AM to 6:57 PM
{ "from": 1139, "to": 1239 }, // 6:59 PM to 8:39 PM
{ "from": 1339, "to": 1439 } // 10:19 PM to 11:59 PM
]
}
Response Details
Success Response
Status Code: 200
{
"status": "success",
"code": 200,
"message": "Your data successfully inserted.",
"empId": XXX
}
| Field | Type | Description |
|---|---|---|
| status | string | Response status ("success" or "error") |
| code | number | Response code (200 for success) |
| message | string | Success message |
| empId | number | Newly created employee ID |
Error Response Examples
Error 1: Email Already Exists
Status Code: 200
{
"status": "error",
"message": "email is alreday exists",
"code": 1512
}
Error 2: Invalid Fields Provided
Status Code: 200
{
"status": "error",
"message": "Please Provide Only Valid fields",
"code": 1521
}
Error 3: Invalid Role ID
Status Code: 200
{
"status": "error",
"message": "invalid role id",
"code": 1503
}
Error 4: Employee Limit Reached
Status Code: 200
{
"status": "error",
"message": "The limit for creating or activating employees has been reached, so you cannot create or activate a new employee now.",
"code": 1532
}
Error Codes
| Error Code | Description |
|---|---|
| 1000 | Invalid parameters |
| 1047 | Invalid request (empty body) |
| 1503 | Invalid role id |
| 1504 | Invalid parent |
| 1505 | Invalid group data |
| 1509 | Invalid employee |
| 1510 | Invalid destination |
| 1511 | Working time format is invalid |
| 1512 | Email already exists |
| 1513 | Invalid type |
| 1514 | Invalid mobile number |
| 1515 | Invalid name |
| 1519 | Call password must be integer and eight digit |
| 1521 | Please provide only valid fields |
| 1522 | Data could not be inserted |
| 1532 | Employee limit reached |
Notes
-
Authentication: Either
ssidOR (userId+token) must be provided -
Permission Required: ADD_EMPLOYEE permission is required (can be bypassed with
forward=true) - Employee Limit: System checks if the account has reached its employee limit before creation
- Email Uniqueness: Email address must be unique across all employees
- Call Password: If not provided, an 8-digit password is auto-generated
- Working Hours: Must be provided in minutes from midnight (0-1439)
- Multiple Time Slots: You can specify multiple working time slots per day
- Group Assignment: Groups are specified as key-value pairs (group ID: "Y"/"N")
- Parent Hierarchy: Parent can be "root", "ROOT", "START", or an existing employee ID
- Destination Types: Common types are "MOBILE", "SIP", "LANDLINE", "WEBRTC"
Example cURL Request
curl -X POST "{{domain}}/api/v2/Employee/create" \
-H "Content-Type: application/json" \
-d '{
"userId": "{{userid}}",
"token": "{{token}}",
"name": "XXXX XXXXX",
"mobile": 91XXXXXXXXXX,
"email": "xxxx@example.com",
"destination": {
"type": "MOBILE",
"value": "XXXXXXXXXX"
},
"role": XX,
"type": "Both",
"working": {
"MON": [{"from": 540, "to": 1080}]
}
}'
Validation Process
The API performs the following validations in order:
-
Request Validation
- Checks if request body is not empty
- Validates API request format
-
Authentication Validation
- Validates SSID or userId/token combination
- Checks if session is valid
-
Permission Check
- Verifies ADD_EMPLOYEE permission (unless
forward=true)
- Verifies ADD_EMPLOYEE permission (unless
-
Employee Limit Check
- Validates current employee count against account limit
-
Field Validation
- Name: Must be provided and valid
- Email: Must be unique and valid format
- Mobile: Must be valid phone number
- Role: Must exist in user's role list
- Working hours: Must be in valid range (0-1439)
- Destination: Must have valid type and value
- Call password: Must be 8 digits (if provided)
- Groups: All group IDs must exist
-
Data Creation
- Creates employee record in database
- Assigns groups
- Sets up working hours
- Updates search indexes
Best Practices
- Always provide working hours for all operational days
- Use valid email addresses to avoid duplicate errors
- Check employee limits before bulk employee creation
- Provide 8-digit call passwords or let system auto-generate
- Use proper destination types matching your telephony setup
- Assign appropriate roles based on employee responsibilities
- Set realistic working hours matching business operations
Create
var axios = require('axios');
var data = '{"userId":"{{userid}}","token":"{{token}}","NAme": "Manoj Kumar111","mobile": 9887613096,"email": "manoj.rao@snet.in","address": "address ","destination": {"type": "MOBILE","value": "9887613096"},"role": 12,"type": "Both","parent": "root","callpwd": "98765432","working": {"MON": [{"from": 0,"to": 1137},{"from": 1139,"to": 1239},{"from": 1339,"to": 1439}]},"group": {"90": "Y"}}';
var config = {
method: 'post',
url: '{{brand}}/api/v2/Employee/Create',
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/Employee/Create');
$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.rao@snet.in","address": "address ","destination": {"type": "MOBILE","value": "9887613096"},"role": 12,"type": "Both","parent": "root","callpwd": "98765432","working": {"MON": [{"from": 0,"to": 1137},{"from": 1139,"to": 1239},{"from": 1339,"to": 1439}]},"group": {"90": "Y"}}');
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 = "{\"userId\":\"{{userid}}\",\"token\":\"{{token}}\",\"NAme\": \"Manoj Kumar111\",\"mobile\": 9887613096,\"email\": \"manoj.rao@snet.in\",\"address\": \"address \",\"destination\": {\"type\": \"MOBILE\",\"value\": \"9887613096\"},\"role\": 12,\"type\": \"Both\",\"parent\": \"root\",\"callpwd\": \"98765432\",\"working\": {\"MON\": [{\"from\": 0,\"to\": 1137},{\"from\": 1139,\"to\": 1239},{\"from\": 1339,\"to\": 1439}]},\"group\": {\"90\": \"Y\"}}"
headers = {
'Content-Length': ''
}
conn.request("POST", "/api/v2/Employee/Create", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))var client = new RestClient("{{brand}}/api/v2/Employee/Create");
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.rao@snet.in""," + "\n" +
@" ""address"": ""address ""," + "\n" +
@" ""destination"": {" + "\n" +
@" ""type"": ""MOBILE""," + "\n" +
@" ""value"": ""9887613096""" + "\n" +
@" }," + "\n" +
@" ""role"": 12," + "\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" +
@"}";
request.AddParameter("text/plain", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);curl --location -g --request POST '{{brand}}/api/v2/Employee/Create' \
--data-raw '{
"userId":"{{userid}}",
"token":"{{token}}",
"NAme": "Manoj Kumar111",
"mobile": 9887613096,
"email": "manoj.rao@snet.in",
"address": "address ",
"destination": {
"type": "MOBILE",
"value": "9887613096"
},
"role": 12,
"type": "Both",
"parent": "root",
"callpwd": "98765432",
"working": {
"MON": [
{
"from": 0,
"to": 1137
},
{
"from": 1139,
"to": 1239
},
{
"from": 1339,
"to": 1439
}
]
},
"group": {
"90": "Y"
}
}'var request = http.Request('POST', Uri.parse('{{brand}}/api/v2/Employee/Create'));
request.body = '''{\n "userId":"{{userid}}",\n "token":"{{token}}",\n "NAme": "Manoj Kumar111",\n "mobile": 9887613096,\n "email": "manoj.rao@snet.in",\n "address": "address ",\n "destination": {\n "type": "MOBILE",\n "value": "9887613096"\n },\n "role": 12,\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}''';
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/Employee/Create"
method := "POST"
payload := strings.NewReader(`{
"userId":"{{userid}}",
"token":"{{token}}",
"NAme": "Manoj Kumar111",
"mobile": 9887613096,
"email": "manoj.rao@snet.in",
"address": "address ",
"destination": {
"type": "MOBILE",
"value": "9887613096"
},
"role": 12,
"type": "Both",
"parent": "root",
"callpwd": "98765432",
"working": {
"MON": [
{
"from": 0,
"to": 1137
},
{
"from": 1139,
"to": 1239
},
{
"from": 1339,
"to": 1439
}
]
},
"group": {
"90": "Y"
}
}`)
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/Employee/Create HTTP/1.1
Host: {{brand}}
Content-Length: 685
{
"userId":"{{userid}}",
"token":"{{token}}",
"NAme": "Manoj Kumar111",
"mobile": 9887613096,
"email": "manoj.rao@snet.in",
"address": "address ",
"destination": {
"type": "MOBILE",
"value": "9887613096"
},
"role": 12,
"type": "Both",
"parent": "root",
"callpwd": "98765432",
"working": {
"MON": [
{
"from": 0,
"to": 1137
},
{
"from": 1139,
"to": 1239
},
{
"from": 1339,
"to": 1439
}
]
},
"group": {
"90": "Y"
}
}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.rao@snet.in\",\n \"address\": \"address \",\n \"destination\": {\n \"type\": \"MOBILE\",\n \"value\": \"9887613096\"\n },\n \"role\": 12,\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}");
Request request = new Request.Builder()
.url("{{brand}}/api/v2/Employee/Create")
.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.rao@snet.in\",\n \"address\": \"address \",\n \"destination\": {\n \"type\": \"MOBILE\",\n \"value\": \"9887613096\"\n },\n \"role\": 12,\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}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("{{brand}}/api/v2/Employee/Create", 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/Employee/Create");
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.rao@snet.in\",\n \"address\": \"address \",\n \"destination\": {\n \"type\": \"MOBILE\",\n \"value\": \"9887613096\"\n },\n \"role\": 12,\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}";
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/Employee/Create"]
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.rao@snet.in\",\n \"address\": \"address \",\n \"destination\": {\n \"type\": \"MOBILE\",\n \"value\": \"9887613096\"\n },\n \"role\": 12,\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}" 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.rao@snet.in\",\n \"address\": \"address \",\n \"destination\": {\n \"type\": \"MOBILE\",\n \"value\": \"9887613096\"\n },\n \"role\": 12,\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}";;
let reqBody =
let uri = Uri.of_string "%7B%7Bbrand%7D%7D/api/v2/Employee/Create" 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.rao@snet.in`",`n `"address`": `"address `",`n `"destination`": {`n `"type`": `"MOBILE`",`n `"value`": `"9887613096`"`n },`n `"role`": 12,`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}"
$response = Invoke-RestMethod '{{brand}}/api/v2/Employee/Create' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Jsonrequire "uri"
require "net/http"
url = URI("{{brand}}/api/v2/Employee/Create")
http = Net::HTTP.new(url.host, url.port);
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.rao@snet.in\",\n \"address\": \"address \",\n \"destination\": {\n \"type\": \"MOBILE\",\n \"value\": \"9887613096\"\n },\n \"role\": 12,\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}"
response = http.request(request)
puts response.read_body
printf '{
"userId":"{{userid}}",
"token":"{{token}}",
"NAme": "Manoj Kumar111",
"mobile": 9887613096,
"email": "manoj.rao@snet.in",
"address": "address ",
"destination": {
"type": "MOBILE",
"value": "9887613096"
},
"role": 12,
"type": "Both",
"parent": "root",
"callpwd": "98765432",
"working": {
"MON": [
{
"from": 0,
"to": 1137
},
{
"from": 1139,
"to": 1239
},
{
"from": 1339,
"to": 1439
}
]
},
"group": {
"90": "Y"
}
}'| http --follow --timeout 3600 POST '{{brand}}/api/v2/Employee/Create' \
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.rao@snet.in\",\n \"address\": \"address \",\n \"destination\": {\n \"type\": \"MOBILE\",\n \"value\": \"9887613096\"\n },\n \"role\": 12,\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}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{brand}}/api/v2/Employee/Create")!,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
15 Nov 2025 10:35:26 GMT"}
{"key":"Content-Type"
"value":"application\/json; charset=utf-8"}
{"key":"Content-Length"
"value":"66"}
{"key":"Connection"
"value":"keep-alive"}
{"key":"Access-Control-Allow-Origin"
"value":"*"}
{"key":"Access-Control-Allow-Methods"
"value":"GET
PUT
POST
DELETE
OPTIONS"}
{"key":"Access-Control-Allow-Headers"
"value":"session-token
Authorization
Origin
Accept
Content-Type
DNT
Authorization
Keep-Alive
User-Agent
X-Requested-With
If-Modified-Since
Cache-Control
Content-Type
Content-Range
Range"}
{"key":"Access-Control-Allow-Credentials"
"value":"true"}
{"key":"Vary"
"value":"Origin"}
{"key":"ETag"
"value":"W\/\"42-ywKqgMfSLHm4KGtYFEAdDx9V5ik\""}
{"key":"Strict-Transport-Security"
"value":"max-age=15724800; includeSubDomains"}
{"key":"Access-Control-Max-Age"
"value":"1728000"}]
{
"status": "error",
"message": "email is alreday exists",
"code": 1512
}