Clients

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 clients

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

The method returns the company's clients. The method returns 100 records; argument “offset” is used for offset.

* required fields

ParameterValue
api_token*Token
created_afterThe issue will get tickets created after the date at the argument. Example: '2016-11-25 00:00'
created_beforeThe issue will get tickets created before the date at the argument. Example: '2016-11-25 00:00'
offsetOffset
querySearch string. Search by client’s name, address, telephone..
search_type

If not specified, the parameter is selected by default partial_match

Accepts 2 values:

  • partial_match - search by occurrence of% like%
  • full_match - full match search.
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'offset'=>0,
	'created_after' =>'2016-11-25 00:00',
	'created_before'=>'2016-11-25 15:08',
);
$mch_api = curl_init();

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/clients');
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": 1,
		"name": "UseDesk",
		"emails": "support@usedesk.ru",
		"phone": null,
		"tickets": [
			1,
			3089372,
			3091416
		]
	},
	{
		"id": 16,
		"name": "Google+",
		"emails": null,
		"phone": null,
		"tickets": []
	},
	{
		"id": 17,
		"name": "Shazam",
		"emails": "shazam@email.shazam.com",
		"phone": null,
		"tickets": []
	},
	{
		"id": 18,
		"name": "Google Play",
		"emails": "news-googleplay@google.com",
		"phone": null,
		"tickets": [
			3088240
		]
	}
]

Single client

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

The method returns information about the company's client by id. It gets one parameter – client’s id

* required fields

ParameterValue
api_token*api channel's token
client_id*client’s id
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'client_id'=>'2261648',
);
$mch_api = curl_init(); 

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/client');
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
[
	{
		"client": {
			"id": 2,
			"name": "Ekaterina Arhipova",
			"avatar": null,
			"position": null,
			"note": null,
			"company_id": 153561,
			"zendesk_id": null,
			"spammer": 0,
			"vip": 0,
			"client_company_id": null,
			"created_at": "2015-02-24 19:50:03",
			"tickets": [
				2,
				3000640,
				3000652,
				3000708,
				3000784,
				3000794,
				3027058
			],
			"emails": [
				{
					"id": 2,
					"email": "arhipova1206@gmail.com",
					"client_id": 2,
					"fullcontact": 0,
					"status": ""
				}
			],
			"phones": [],
			"social_networks": [],
			"messengers": [],
			"addresses": [],
			"sites": [],
			"client_company": null
		},
		"emails": [
			null
		],
		"phones": [],
		"social_networks": [],
		"messengers": [],
		"addresses": [],
		"sites": [],
		"client_company": null
	}
]

Update a client

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

The method allows you to edit client information.

ParameterValue
api_tokenToken
client_idRequired argument. Client id
nameNew client's name
emailsArray with postal addresses. The system will add addresses to existing addresses
messengers

An array of messenger data that can be updated or added to a client card

Contains parameters:

  • id - messenger id (not required). If specified, the existing instant messenger will be changed
  • identity - nickname, phone number, other identifiers, which are displayed in the client's card, the limit of 64 symbols (mandatory). If an empty value is transmitted and the id parameter is set, the instant messenger shall be deleted
  • type - messenger type (required). Accepts values: telegram, whatsapp, viber, skype, gtalk, imessage, other 
  • uid - user id in messenger (not required)
noteNote text
is_new_noteIf the parameter is set to false or missing, it allows to continue the text of the note
phoneClient’s phone. The system will add the phone to the existing
avatarFile containing image. Format: multipart/form-data
statusClient status - vip, spammer
positionСlient position
merge_idClient’s identifier with which the user with the identifier "client_id" will be merged
client_countryClient’s country
client_cityClient’s city
client_addressClient’s address
new_addressIt is sent if you want to create an additional address.
phone_typePhone type when saving. Gets the values home, mobile, stationary, fax, other.
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'client_id'=>1234,
	'name' =>'Jon',
	'emails'=>['test@gmail.com'],
);
$mch_api = curl_init();

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/update/client');
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;

Create a client

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

The method allows you to create a new client.

ParameterValue
api_tokenToken
nameNew client name
emailsArray with postal addresses
messengers

An array of messenger data that can be updated or added to a client card

Contains parameters:

  • id - messenger id (not required)
  • identity - nickname, phone number, other identifiers, which are displayed in the client's card, the limit of 64 symbols (mandatory)
  • type - messenger type (required). Accepts values: telegram, whatsapp, viber, skype, gtalk, imessage, other 
  • uid - user id in messenger (not required)
noteNote text
is_new_noteIf the parameter is set to false or missing, it allows to continue the text of the note
phoneClient’s phone
avatarFile containing image. Format: multipart/form-data
statusClient’s status  - vip, spammer
positionClient position
merge_idClient identifier with which the user with the identifier “client_id” will be merged
client_countryClient’s country
client_cityClient’s city
client_addressClient’s address
new_addressIt is passed if you want to create an additional address
phone_typePhone type when saving. Gets the values home,mobile,stationary,fax,other
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'name' =>'Jon',
	'emails'=>['test@gmail.com'],
);
$mch_api = curl_init();

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/create/client');
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;