Create a comment

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

Warning. If you use the server version of Usedesk, you will have a different URL of methods. Check the URL for the API with our team — support@usedesk.com.

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

* — required fields

ParameterValue
api_token*Channel API token
ticket_id*Ticket ID
message*

Message

String, ~64kb. Supports HTML markup

If this is an internal comment private_comment = true, you can add a mention of agent [~test@gmail.com]

ссArray of copies (CCs)
bссArray of hidden copies (BCCs)
user_id

ID of the user on whose behalf the changes will be made

If provided, the response will be on behalf on this user. Otherwise the first user of the company will be selected

typeComment type
  • public;
  • private.
If not set, the comment will be private
filesAn array of attached files
multipart/form-data
fromThe side on whose behalf the comment is created
Possible values:
  • user;
  • client;
  • trigger.
If a user or trigger parameter is passed, the request must contain parameters with the desired identifiers — user_id or trigger_id respectively
trigger_id

The identifier of the trigger for the from parameter

Numeric identifier, 32 bits

N.B.: At this moment, no matter which trigger is selected, the comment will be created on behalf of the Bot

template_idWhatsApp Business template ID (pact)
template_name
WhatsApp Business template name (Landbot, infobip)
template_variables

WhatsApp Business template variables

An array of strings. Variables are substituted in the template in order

template_lang

WhatsApp Business template language

By default: ru

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;