Skip to content
Last updated

UpdateTicket

Updates an existing ticket

Request Parameters

ParameterTypeDescriptionRequired
actionstring"UpdateTicket"Required
ticketidintThe ticket Id to updateRequired
deptidintThe department id of the ticketOptional
statusstringThe status of the ticketOptional
subjectstringThe subject of the ticketOptional
useridintIf applicable, the Client ID to update the ticket for.Optional
namestringThe name of the person opening the ticket (if not a client)Optional
emailstringThe email address of the person opening the ticket (if not a client)Optional
ccstringThe cc email addresses for the ticketOptional
prioritystringThe priority of the ticket ('Low', 'Medium', 'High')Optional
createdstringThe date and time the initial message will show as created. Format: ISO8601 or YYYY-MM-DD HH:mm:ssOptional
flagintThe id of the admin to flag the ticket toOptional
removeFlagboolRemove the flag from the ticketOptional
messagestringUpdate the ticket messageOptional
markdownboolShould markdown be used on the ticket output.Optional
customfieldsstringBase64 encoded serialized array of custom field valuesOptional
preventClientClosureboolWhether the client should be allowed to close the ticket. If you do not pass this while also passing a department id, tickets moving to a department with the setting enabled will inherit the department setting.Optional

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
ticketidintThe ticket id that has been updated

Example Request (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'UpdateTicket',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'ticketid' => '1',
            'subject' => 'This is a sample updated ticket subject',
            'clientid' => '1',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

$command = 'UpdateTicket';
$postData = array(
    'ticketid' => '1',
    'subject' => 'This is a sample updated ticket subject',
    'clientid' => '1',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);
print_r($results);

Example Response JSON

{
    "result": "success",
    "ticketid": "1"
}

Error Responses

Possible error condition responses include:

  • Ticket ID Not Found
  • Department ID Not Found
  • Invalid Ticket Priority. Valid priorities are: Low,Medium,High
  • Invalid Ticket Status. Valid statuses are: xxx
  • Invalid Date Format
  • Ticket creation date cannot be in the future

Version History

VersionChangelog
1.0Initial Version
7.7Added message parameter that allows updating primary ticket message.
8.0Added support for ticket creation date.
8.11Added optional preventClientClosure parameter to provide ability to allow client to close the ticket or not.