Create a comment
POST https://secure.usedesk.com/uapi/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
Parameter | Value |
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 |
type | Comment type
|
files | An array of attached files multipart/form-data |
from | The side on whose behalf the comment is created Possible values:
|
template_id | WhatsApp 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://secure.usedesk.com/uapi/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.
{ "status":"success", "comment_id":2154861 }
$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.
$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://secure.usedesk.com/uapi/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;