Agents

Warning

If you use the on-premise Usedesk version on your own server, then URL of your methods will be different. Specify the URL to work with API by contacting our support team - support@usedesk.ru

Get a list of agents

url: https://api.usedesk.ru/users

The method returns a list of company’s agents with groups. It is possible to use filters.

* required fields

ParameterValue
api_token*

Token

user_typeUser type or role:
● admin
● employee
● support
group_idGroup id, which consists of the agent
querySearch line
user_idAgent’s id, if this field is set, information about one agent will be returned
How to apply filters
{
	'group_id':'123',
	'query': 'Ivan',
	'user_type': 'admin',
}
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'group_id'=> 123,
	'query' =>'Ivan',
	'user_type'=>'admin',
);
$mch_api = curl_init(); // initialize cURL connection

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/users');
curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true);
curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
curl_setopt($mch_api, CURLOPT_POST, true);
curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($mch_api, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($mch_api);
return $result;
Example of a response from server
[
	{
		"id": "558",
		"name": "Agent Name",
		"email": "agent@gmail.com",
		"position": "",
		"role": "admin",
		"phone": null,
		"chat_online_status": "1",
		"online_status": "0",
		"groups": [
			{
				"id": "123",
				"name": "Group",
				"company_id": "153561",
				"deleted": "0",
				"deleted_at": "0000-00-00 00:00:00",
				"pivot": {
					"user_id": "558",
					"user_group_id": "413"
				}
			},
			{
				"id": "354",
				"name": "Group 2",
				"company_id": "153561",
				"deleted": "0",
				"deleted_at": "0000-00-00 00:00:00",
				"pivot": {
					"user_id": "558",
					"user_group_id": "354"
				}
			},
			{
				"id": "127",
				"name": "Group 4",
				"company_id": "153561",
				"deleted": "0",
				"deleted_at": "0000-00-00 00:00:00",
				"pivot": {
					"user_id": "558",
					"user_group_id": "127"
				}
			},
			{
				"id": "415",
				"name": "Test group 3",
				"company_id": "153561",
				"deleted": "0",
				"deleted_at": "0000-00-00 00:00:00",
				"pivot": {
					"user_id": "558",
					"user_group_id": "415"
				}
			}
		]
	}
]

Create an agent

url: https://api.usedesk.ru/create/user

The method creates an agent. It gets the following parameters:

* required fields

ParameterValue
api_token*API channels' token
name*Agent name
email*Agent e-mail
role

String is like:

• admin
• employee
• support

If it’s not set, the default value is "employee"

passwordPassword
group*The default group, the agent will be added to this group, when created.
phoneOptional parameter. Agent's phone
Request example
{
	'name': 'Agent Name',
	'email': 'agentemail@gmail.com',
	'role': 'admin',
	'password': 'qwerty123',
	'group': '123',
	'phone': '89156743287',
}
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'name' => 'Agent Name',
	'email' => 'agentemail@gmail.com',
	'role' => 'admin',
	'password' => 'qwerty123',
	'group' => '123',
	'phone'  => '89156743287'
);
$mch_api = curl_init();

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/create/user');
curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true);
curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
curl_setopt($mch_api, CURLOPT_POST, true);
curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($mch_api, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($mch_api);
return $result;

If the request is successful, the server will return a message about the successful creation and new agent’s id.

Example of a response from server
{
	"status":"success",
	"user_id":2154861
}

Delete an agent

url: https://api.usedesk.ru/delete/user

The method is used to delete the agent, tickets remain assigned to agent.

* required fields

ParameterValue
api_token*Token
user_id*Agent’s id
PHP request example
$data = array(
	'api_token'=> 'ba82c31d43b286e43e0e5489fb522ec57dc4c3fd',
	'user_id'=>'545',
);
$mch_api = curl_init(); // initialize cURL connection

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/create/comment');
curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true);
curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
curl_setopt($mch_api, CURLOPT_POST, true);
curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($mch_api, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($mch_api);
return $result;

Update an agent

url: https://api.usedesk.ru/update/user

The method creates an agent. It gets the following parameters:

* required fields

ParameterValue
api_token*Token
user_id *Agent’s id
nameAgent's name
emailAgent's e-mail
role

String is like:
• admin
• employee
• support

groupThe default group
phoneAgent's phone
chat_online_statusAgent status on the chat. Accepts true/false values
ticket_online_statusAgent status on the ticket. Accepts true/false values
Request example
{
    'user_id': '2154861'	
    'name': 'Agent Name',
	'email': 'agentemail@gmail.com',
	'role': 'admin'
	'group': '123',
	'phone': '89156743287',
    'chat_online_status': 'true',
    'ticket_online_status': 'false'
}
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
    'user_id'=> '2154861'
	'name' => 'Agent Name',
	'email' => 'agentemail@gmail.com',
	'role' => 'admin',
	'group' => '123',
	'phone'  => '89156743287'
);
$mch_api = curl_init();

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/update/user');
curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true);
curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
curl_setopt($mch_api, CURLOPT_POST, true);
curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($mch_api, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($mch_api);
return $result;
Example of a response from server
{
	"status":"success",
	"user_id":2154861
}

Get a list of agent’s groups

url: https://api.usedesk.ru/groups

The method returns a list of groups and agents in them.

* required fields

ParameterValue
api_token*Token
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
);
$mch_api = curl_init();

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/groups');
curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true);
curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
curl_setopt($mch_api, CURLOPT_POST, true);
curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($mch_api, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($mch_api);
return $result;
Example of a response from server
[
	{
		"id": "354",
		"name": "Group 2",
		"company_id": "153561",
		"deleted": "0",
		"deleted_at": "0000-00-00 00:00:00",
		"users": [
			{
				"id": "568",
				"name": "agent1",
				"email": "agent1@usedesk.ru",
				"position": "",
				"role": "admin",
				"phone": null,
				"pivot": {
					"user_group_id": "354",
					"user_id": "568"
				}
			},
			{
				"id": "558",
				"name": "Agent2",
				"email": "agent2@gmail.com",
				"position": "",
				"role": "employee",
				"phone": null,
				"pivot": {
					"user_group_id": "354",
					"user_id": "558"
				}
			}
		]
	},
]