Tickets

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.

Status Reference

Possible status at the system:

ValueStatus
1Open
2Solved
3Closed
4Deleted
5On hold
6Pending
7Spam
8New
9Newsletter 
10Merged

List of tickets

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

The method returns tickets to the company. It is possible to use filters. The method returns 100 records; argument “offset” is used for offset/ displacement.

*required fields

Argument/ParameterValue
api_token*Api channel token
fchannelChannel id filter. Pass multiple values separated by commas
fassigned

Filtering by assignee_id and group_id, the values ​​of which can be passed in an array or one at a time.

There are the following cases of behavior:

  1. Possibility to specify in the parameter assignee_id the agent's id and in the parameter group_id the group id - then the system sends all tickets in which an agent within a certain group is specified as the Executor
  2. Possibility not to specify the group_id parameter and specify agent's id in the assignee_id parameter - then the system sends all tickets in which an agent is specified as an Executor, without taking into account which group it is added to
  3. Possibility to specify the parameter assignee_id = unassigned - then the system gives all tickets in which a group is specified as the Executor
  4. Possibility to specify parameter assignee_id = unassigned and indicate in parameter group_id = unassigned - then the system gives all tickets with "No performer" as an Executor

Deprecated (version 1.0) does not recommend using deprecated ways of behavior:

  1. Possibility to specify agent's id as a string
  2. Possibility to specify group id+agent id to specify within which group the performer is specified: {Group id}_{agent id}

fstatus

Status id filter

  • 1 (Open)
  • 2 (Solved)
  • 3 (Closed)
  • 4 (Deleted)
  • 5 (On hold)
  • 6 (Pending)
  • 7 (Spam)
  • 8 (New)
  • 9 (Newsletter)

ftype

Type filter

  • question
  • task
  • problem
  • incident

fpriority

Priority filter

  • low
  • medium
  • urgent
  • extreme

accessible_for_agent_id

User id filter учитывает права сотрудника. It takes into account the rights of the user.

Server returns rights:

write - if there is access to work with a ticket in the current channel;
read - if there is access to viewing the ticket in the current channel.


offsetOffset. Offset by 1, will show the following 100 records
tags

Tag filtration. If there are multiple values, the values must be passed through the comma:

"tag" : "1,4,23"


created_afterThe issue will get tickets created after the date at the parameter. Example: '2016-11-25 00:00'
created_beforeThe issue will get tickets created before the date at the parameter. Example: '2016-11-25 00:00'
updated_afterThe issue will get tickets changed after the date at the parameter. Example: '2016-11-25 00:00'
updated_beforeThe issue will get tickets changed before the date at the parameter. Example: '2016-11-25 00:00'
querySearch line. Search by ticket topic and content at all comments. A limit of 10 requests per minute is set for requests containing this parameter.
client_id

Client id, the system will send a list of tickets for a specific client if you specify it.


fields

Filtering by identifier and value of the additional field.

The array contains parameters:

id - id of the additional field;
value - the value of the additional field


a) empty - when this value is specified, the system will filter out all queries that have at least one empty field.

For fields with type checkbox "not filled" this value is 0 or empty value  " "

b) not_empty - if this value is specified, the system will filter out all queries with at least one filled field.

For fields with the checkbox type "filled", this value is 1

c) value - when specifying a value, the system will filter out all queries in which the given value will be selected in any of the additional fields. Only one value can be specified


Deprecated (version 1.0) do not recommend using outdated behaviors:

field_id - Filtering by additional field identifier. If you specify a value, the system will filter out all queries in which this field will be filled. Only one value can be specified.

field_value - Filter by the value of the additional field.

  • empty - if this value is specified, the system will filter out all queries that have at least one empty field
         For fields with the checkbox type "not filled in" this value is false
  • not_empty - if this value is specified, the system will filter out all queries that have at least one filled field.
        For fields with the checkbox type "filled" this value is true
  • value - when specifying a value, the system will filter out all queries in which the given value will be selected in any of the additional fields.
        Only one value can be specified

Identifier of the additional field that will be searched.

  • If you specify a value, the system will filter all tickets in which this field will be filled.
  • You can specify only one value

sort

The sorting parameter by which the list of tickets can be sorted: id, status_id, client_id, assignee_id, group, last_updated_at, published_at

Default: id



orders

Sort order of tickets:

asc - ascending
desc - descending


By default: desc



How to apply filters
{
	'fchannel':'123',
    'fassigned' : 
    [
       {
            'assignee_id' : 17063,
            'group_id' : 6216
       },
       {
            'assignee_id' : 15023,
            'group_id' : 8294
       } 
    ]
    'fassigned': '45',
    'fgroup': '21',
    'ftype':'1',
    'accessible_for_agent_id':'6339',
    'updated_after':'2016-11-25 00:00';
}


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(); // initialize cURL connection

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/tickets');
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 PHP request with filters
$data = array(
		'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
		'offset'=>0
		'tags'=> 'tag1,tag2',
		'fchannel'=>'123',
		'fgroup'=>'2'
);
$mch_api = curl_init();

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/tickets');
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": "2992803",
    	"subject": "hi",
    	"client_id": "15341",
    	"assignee_id": "2",
    	"channel_id": null,
    	"group": "2",
    	"last_updated_at": "2017-03-29 07:47:30",
    	"channel_email": null,
    	"ticket_fields": [
			{
        		"id": "25",
        		"name": "complain",
        		"value": null
			},
      		{
        		"id": "37",
        		"name": "Request reason",
        		"value": "39"
			}
    	],
    	"tags": [
			{
        		"name": "Request reason:error"
			 }
        ],
        "status": 2,
        "priority": "medium",
        "type": "question",
        "last_comment": "У меня появилась ошибка",
        "remind_at": null,
        "rights": "read"
    },
]

Single ticket

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

The method returns ticket information by its id. It gets one argument: ticket id.

* required fields

ParameterValue
ticket_id*Ticket’s id
api_token*Api channel token
accessible_for_agent_id

User id filter учитывает права сотрудника. It takes into account the rights of the user.

Server returns rights:

write - if there is access to work with a ticket in the current channel;
read - if there is access to viewing the ticket in the current channel.


Request example
$data = array(
		'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
        'accessible_for_agent_id'=>'6339',
		'ticket_id'=>'2261648',
);
$mch_api = curl_init(); 

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

The server returns a ticket, all comments, tags and a history of changes.

Example of a response from server
{
	"ticket":{
		"id":"2265179",
		"status_id":"1",
		"subject":"additional fields",
		"client_id":"261702",
		"assignee_id":"2",
		"group":"0",
		"last_updated_at":"2017-03-01 14:30:49",
		"email":"0",
		"published_at":"2017-03-01 14:30:49",
		"company_id":"153561"
	},
	"comments":[
		{
			"id":"2658287",
			"message":"additional fields",
			"from":"client",
			"user_id":null,
			"client_id":"261702",
			"ticket_id":"2265179",
			"is_first":"0",
			"delivered":"0",
			"readed":"0",
			"published_at":"2017-03-01 14:30:49"
		}
	],
	"changes":[
		{
			"id":"213671",
			"trigger_id":"1260",
			"user_id":null,
			"ticket_id":"2265179",
			"data":[
				{
					"target":"assignee",
					"value":"2"
				}
			],
			"changed_at":"2017-03-01 14:30:49",
			"old_status":"0",
			"new_status":"0",
			"company_id":"153561"
		},
		{
			"id":"213669",
			"trigger_id":null,
			"user_id":null,
			"ticket_id":"2265179",
			"data":[
			],
			"changed_at":"2017-03-01 14:30:49",
			"old_status":"0",
			"new_status":"1",
			"company_id":"153561"
		}
	],
	"tags":[
		"Bycicle Number":"134",
		"Veggies":"tomato"
	],
	"custom_fields":[
		{
			"id":"143",
			"ticket_id":"2265179",
			"ticket_field_id":"10",
			"value":"134"
		},
		{
			"id":"145",
			"ticket_id":"2265179",
			"ticket_field_id":"7",
			"value":"1"
		},
		{
			"id":"147",
			"ticket_id":"2265179",
			"ticket_field_id":"9",
			"value":"9"
 }
    ]
            "rights": "write",
}

Create ticket

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

The method creates a ticket for the API channel. Gets the following arguments:

* required fields

ParameterValue
api_token*Api channel token
subject*Ticket topic. String (255 characters). Any characters are supported, including emoji
message*Ticket message. String ~64kb. HTML markup is supported
client_nameClient's name. String (255 characters)
client_emailClient's e-mail. String (255 characters)
client_idOptional parameter, if it’s set to "new_client", a new client will be created. Numeric identifier or string "new_client" for new client
company_name

Optional parameter, if specified, the system will check if there is a company with this name

If there is no such company, a new company with such name is created and attached to the client for whom the appeal came.

If there is such a company, the client gets attached to that company.

If the client has a company, the client is tied to the one that was transferred.

private_commenttrue. Optional parameter to create a private comment
additional_id

Optional parameter for passing any additional identifier.

String (255 characters)

type

It gets the following parameters/arguments:

  • question
  • task
  • problem
  • incident

By default: question

String (10 characters)

priority

It gets the following parameters/arguments:

  • low
  • medium
  • urgent
  • extreme

Default: medium

String (10 characters)

status

It gets a number that corresponds to the status identifier at the system.


Possible statuses/states:

• 1 (open)
• 2 (solved)
• 3 (closed)
• 4 (deleted)
• 5 (on hold)
• 6 (pending)
• 7 (spam)
• 8 (new)
• 9 (newsletter)

Default: 8 (new)
number

tagA string that contains tags, separated by commas.
assignee_id

The agent identifier to which the request will be assigned.

If the group_id parameter is specified and the agent is in this group, the assignment will be within the specified group.

Numeric identifier 32 bits

group_idThe group identifier to which the request will be assigned. Numeric identifier 32 bits
client_phoneThe phone will be added to the client card if the client is new and this parameter is sent. String (255 characters)
field_idA string that contains additional field identifiers separated by a semicolon. (;).String (255 characters)
field_value

A string that contains additional field identifiers separated by a semicolon (;).

For text fields, the value should not exceed 255 characters
For checkbox fields - true / false
For a list of fields – option id.

An example of a string in which 3 values are passed: "any value; true; 93",

channel_idThe channel identifier on which the request will be created. If it’s not sent, the request will be created at the channel to which the token belongs. The type of request will match the type of channel. 32 bits.
filesArray of attached files. Format: multipart/form-data
fromThis parameter defines the author of the comment. It accepts "user", "client", "trigger". When passing "client", the author of the comment will be assigned to the client on which the ticket is placed. If the parameter other than "client" is passed, the ticket should contain parameters with the necessary identifiers (user_id, trigger_id)
user_idagent id for parameter from
trigger_idtrigger id for parameter from
client_countryClient’s country
client_cityClient’s city
client_addressClient’s address
new_addressIt will be passed if you want to create an additional address 
phone_typePhone type which is used when saving. It gets the values home,mobile,stationary,fax,other
lists

For editing nested lists. Array containing parameters:

  • id - adi fields
  • value - field value

It is important to follow the structure of nested lists. To change the second level, it is necessary to transfer the value of the first level.

 
Request example
{
	'subject': 'Email',
	'message': 'Hi!',
	'client_name': 'Evan',
	'client_email': 'superevan@gmail.com',
	'field_id': '10;12;9',
	'field_value': 'any value;true;93',
	'channel_id': 683,
	'lists':[
		[
			{
				"id":"61",
				"value":"Test"
			},
			{
				"id":"62",
				"value":"Test1"
			},
			{
				"id":"63",
				"value":"Test2"
			}
		]
	]
}
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'client_name' => "JON",
	'client_email' => "jon@bonjovi.com",
	'message' => "Hello World",
	'subject' => 'First msg',
	'client_id' => 'new_client',
	'type'  => 'question',
	'priority'  => 'low',
	'status'  => '3',
	'subject'  => 'POST UPDATE',
	'tag'=>'new ticket,test',
	'field_id'=> '10;12;9',
	'field_value'=> 'any value;true;93',
	'channel_id'=>683
);
$mch_api = curl_init(); // initialize cURL connection

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

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

Example of a request to send a message to the WhatsApp channel

For the client to receive a message in WhatsApp, consider the mandatory parameters from and user_id.

A new client is created in the system if:

  • 'client_id' => 'new_client' or not used at all;
  • 'client_phone'=> '79254697403' and it is not in the system.

A new phone number is added to the current client if:

  • 'client_id' => '27747627';
  • 'client_phone'=> '79254697403' and it is not in the system.

A new number is NOT added to the current client if:

  • 'client_id' => '27747627' or not used at all;
  • 'client_phone'=> '79254697403' and already exists in the system.

If you use only client_id parameter, the message will be sent to the first phone number specified in the system.

Request example
'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
'message' => "Hello",
'subject' => 'First msg',
'channel_id' => '20054',
'from'=>'user',
'user_id'=> '2156',
'client_phone'=> '79254697403',
'client_id'=>'27747627'

If the request is successful, the server will return a message about the successful creation and id of the new ticket, as well as the status of sending the message.

Example of a response from server
{
    "status": "success",
    "ticket_id": 30745888,
    "message_status": "delivered"
}

A web hook request will be sent to WhatsApp to check the status of sending the message.To do this, enter the address to which the request will be sent in the API channel.To do this, specify the address to which the request will be sent in the UseDesk API channel.

Example of a webhook request sent.
{ "message_status": {"delivery_status": "DELIVERED", "comment_id": 3551632, "extras": {"ticket_id": 1231234}}}


Refresh ticket

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

You can use this method to modify an existing ticket.

It gets the following arguments:

*required fields

ParametersValue
api_token*Api channel token
ticket_id*Ticket id
subjectTicket topic
client_idClient id, if it’s set the client’s ticket will be changed
group_idThe group id to which the ticket will be set
assignee_id

The user id that will be assigned as the executor.

  • if the group_id parameter is passed and the agent is in this group, then the destination will be within the specified group
  • if an incorrect id was specified, the system will not clear the field, but return an error
  • if "null" is passed in group_id and assignee_id, the assignment will be "Not assigned"
user_idId of the user on whose behalf changes will be made
tagA string that contains tags, separated by commas
priorityPriority, may contain: 'low', 'medium', 'urgent', 'extreme'
status

Ticket status, Numeric argument. Possible values for the status field:

ValueStatus
1Open
2Solved
3Closed
4Deleted
5On hold
6Pending
7Spam
9Newsletter
10Merged
typeType, may contain: 'question', 'task', 'problem', 'incident'
field_idA string that contains additional field identifiers separated by a semicolon. (;)
field_value

A string that contains additional field identifiers separated by a semicolon (;).

For text fields, the value should not exceed 256 characters

For checkbox fields - true / false

For a list of fields – option id and field value

lists

For editing nested lists. Array containing parameters:

  • id - adi fields
  • value - field value

It is important to follow the structure of nested lists

Use an empty value or "null" to clear the field.

Request example
{
	'ticket_id': '123',
	'subject': 'Email',
	'field_id': '10;12;9',
	'field_value': 'any field;true;93'
    'lists': [
		[ 
			{
				"id": 1347,
				"value": "1"
			}, 
			{
				"id": 1348,
				"value": "22"
			}
 		]
 	]
}
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'client' => "JON",
	'email' => "jon@bonjovi.com",
	'message' => "Hello World",
	'subject' => 'First msg',
	'client_id' => 'new_client',
	'ticket_id'=>'2154827',
	'priority'  => 'medium',
	'type'=>'task'
	'status'  => '2',
	'subject'  => 'POST UPDATE',
	'field_id'=> '10;12;9',
	'field_value'=> 'any field;true;93'
);
$mch_api = curl_init(); 

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

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

Asynchronous ticket creation

url: https://api.usedesk.ru/create/ticket/async

Asynchronous ticket creation method. Information about the created ticket comes on the webhook specified at the API channel. Gets the following parameters:
* required fields

ParameterValue
api_token*Api channel’s token
subject*Ticket topic. String (255 characters). Any characters are supported, including emoji
message*Ticket message. String ~64kb. HTML markup is supported
client_nameClient’s name. String (255 characters)
client_emailClient’s e-mail. String (255 characters)
client_idOptional parameter, if it is set to "new_client", a new client will be created. Numeric identifier or string "new_client" for new client
additional_idOptional parameter for passing any additional identifier. String (255 characters)
type

It gets the following parameters:

  • question
  • task
  • problem
  • incident

Default: question

String (10 characters)

priority

It gets the following parameters:

  • low
  • medium
  • urgent
  • extreme

Default: medium

String (10 characters)

status

Accepts the value equal the status id in the system.

Potential statuses:

• 1 (open)
• 2 (solved)
• 3 (closed)
• 4 (deleted)
• 5 (on hold)
• 6 (pending)
• 7 (spam)
• 8 (new)
• 9 (newsletter)

Default: 8 (new)
Number

tagA string that contains tags, separated by commas
assignee_idThe agent identifier to which the request will be assigned. Numeric identifier 32 bits
group_idThe group identifier to which the request will be assigned. Numeric identifier 32 bits
client_phoneThe phone will be added to the client card if the client is new and this parameter is passed. String (255 characters)
field_idA string that contains additional field identifiers separated by a semicolon. (;).String (255 characters)
field_value

A string that contains additional field identifiers separated by a semicolon (;).

For text fields, the value should not exceed 255 characters
For checkbox fields - true / false
For a list of fields – option id.

An example of a string in which 3 values are passed: "any value; true; 93",

channel_idThe channel identifier on which the request will be created. If it’s not passed, the request will be created at the channel to which the token belongs. The type of request will match the type of channel. 32 bits.
filesArray of attached files. Format: multipart/form-data
Request example
{
	'subject': 'Email',
	'message': 'Hi!',
	'client_name': 'Evan',
	'client_email': 'superevan@gmail.com',
	'field_id': '10;12;9',
	'field_value': 'any value;true;93',
	'channel_id': 683
}
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'client_name' => "JON",
	'client_email' => "jon@bonjovi.com",
	'message' => "Hello World",
	'subject' => 'First msg',
	'client_id' => 'new_client',
	'type'  => 'question',
	'priority'  => 'low',
	'status'  => '3',
	'subject'  => 'POST UPDATE',
	'tag'=>'new ticket,test',
	'field_id'=> '10;12;9',
	'field_value'=> 'any value;true;93',
	'channel_id'=>683
);
$mch_api = curl_init(); // initialize cURL connection

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

Create a comment

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

The method creates a comment inside the ticket. Gets the following parameters:

* required fields

ParametersValue
api_token*Api channel’s token
ticket_id*Ticket id
message*Message 
ссCopy array
bссHidden copies array
user_idOptional parameter, if it’s set the answer will be completed from this user, otherwise the first user of the company will be selected
typeComment type (public / private), if it’s not set comment will beprivate
filesArray of attached files. Format: multipart/form-data
from

The argument defines the author of the comment. Gets "user","client","trigger".When it’s set "client", the client to whom the ticket is entered will be assigned the comment author. If a parameter different from "client" is set, the request must contain arguments with the necessary identifiers. (user_idtrigger_id). 

If user_id is not specified, the comment will be created on behalf of the bot

trigger_idTrigger identifier
PHP request example
$data = array(
	'api_token'=> 'ba82c31d43b286e43e0e5489fb522ec57dc4c3fd',
	'message' => "New message text",
	'user_id'=>'545',
	'ticket_id'=>'2152490',
	'type'  => 'public',
);
$mch_api = curl_init();

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;

If the request is successful, the server will return a message about the successful creation and comment id.

Example of a response from server
{
	"status":"success",
	"comment_id":2154861
}
How to create a comment with an attached file
$file_name_with_full_path = realpath('../1480538622583f39fe53d18_logo.png');
$cFile = curl_file_create($file_name_with_full_path);

If the request is made with CURL, it is important to specify the full path to the file on the server.

PHP request example
$file_name_with_full_path = realpath('../1480538622583f39fe53d18_logo.png');
$cFile = curl_file_create($file_name_with_full_path);

$data = array(
	'api_token'=> 'ba82c31d43b286e43e0e5489fb522ec57dc4c3fd',
	'message' => "New message text",
	'user_id'=>'545',
	'ticket_id'=>'2154814',
	'type'  => 'public',
	'files[]'=>$cFile
);
$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;

Get list of tags

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

The method returns a list of company's tags. The method returns 100 records; argument “offset” is used for offset.

*required fields

api_token*Api channel token
offsetOffset
querySearch line. Search by tag’s text.
PHP request example
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'offset'=>0,
);
$mch_api = curl_init(); // initialize cURL connection

curl_setopt($mch_api, CURLOPT_URL, 'https://api.usedesk.ru/tags');
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
[
	{
		"ticket_tag_id":130,
		"tag_company_id":153909,
		"name":"tag1",
		"ticket_count":2
	},
	{
		"ticket_tag_id":374,
		"tag_company_id":153909,
		"name":"example",
		"ticket_count":25
	}
]

Create a tip

POST /ticket/setAnswer

application/json

The method allows you to create a hint for the answer in the ticket.

*required fields

ParameterValue
api_token*Api chanel token
ticket_id*Ticket's id
answers*Array of answers {"message":"TEST ANSWER", "score":"0.9"}
typeOptional parameter. String - type identifier
Request example
{
	"api_token":"2a6dace2331187de3d9sa234fef2af1eca059",
	"ticket_id":"3474589",
	"answers": [
		{
			"message":"TEST ANSWER",
			"score":"0.9"
		}
	],
	"type":"usedesk"
}