Skip to content
Last updated

GetTicket

Obtain a specific ticket

Request Parameters

ParameterTypeDescriptionRequired
actionstring"GetTicket"Required
ticketnumstringA specific Client Ticket Number to find tickets for.Optional
ticketidintA specific ticket ID to find tickets for (either $ticketnum or $ticketid is required).Optional
repliessortstringASC or DESC. The order to use to organise the ticket replies.Optional

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
ticketidintThe unique ID of the ticket.
tidstringThe unique ticket number string displayed to end users.
cstringThe client unique access of the ticket.
deptidintThe ID of the department the ticket belongs to.
deptnamestringThe name of the department the ticket belongs to.
useridintThe user ID the ticket belongs to.
contactidintThe contact ID the ticket was opened by.
namestringThe ticket submitter's name.
emailstringThe ticket submitter's email.
requestor_namestringThe ticket submitter's name.
requestor_typestringThe ticket submitter's type.
requestor_emailstringThe ticket submitter's email.
ccstringThe CC email addresses for the ticket.
datestringThe date the ticket was opened on. Format: Y-m-d H:i:s
subjectstringThe subject of the ticket.
statusstringThe status of the ticket.
prioritystringThe priority of the ticket.
adminstringThe name of the admin user who opened the ticket.
lastreplystringThe date the ticket was last replied to. Format: Y-m-d H:i:s
flagintThe ID of the admin user a ticket is flagged to.
servicestringThe ID of the service associated with the ticket (Sx for services and Dx for domains).
repliesarrayAn array of replies on the ticket.
notesarrayAn array of notes on the ticket.

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' => 'GetTicket',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'ticketid' => '1',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

$command = 'GetTicket';
$postData = array(
    'ticketid' => '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",
    "tid": "516757",
    "c": "KPqH7yG3",
    "deptid": "1",
    "deptname": "Sample Support Department",
    "userid": "1",
    "contactid": "0",
    "name": "Cynthia Reilly",
    "email": "[email protected]",
    "cc": "",
    "date": "2016-01-01 06:26:29",
    "subject": "This is a sample ticket",
    "status": "Closed",
    "priority": "Medium",
    "admin": "",
    "lastreply": "2016-01-01 06:30:16",
    "flag": "0",
    "service": "",
    "replies": {
        "reply": [
            {
                "replyid": "0",
                "userid": "1",
                "contactid": "0",
                "name": "Cynthia Reilly",
                "email": "[email protected]",
                "requestor_name": "Cynthia Reilly",
                "requestor_email": "[email protected]",
                "requestor_type": "Owner",
                "date": "2016-01-01 06:26:29",
                "message": "Hey, \r\n\r\nThis is the first ticket message!\r\n\r\nThanks\r\n\r\nCynthia",
                "attachment": "123456_attachment_name.png",
                "attachments": [
                    {
                        "filename": "attachment_name.png",
                        "index": 0
                    }
                ],
                "attachments_removed": true,
                "admin": ""
            },
            {
                "replyid": "1",
                "userid": "1",
                "contactid": "0",
                "name": "",
                "email": "",
                "requestor_name": "Demo Admin",
                "requestor_email": "",
                "requestor_type": "Operator",
                "date": "2016-01-01 06:27:01",
                "message": "Hello, \r\n\r\nThis is the first ticket reply by an admin user!\r\n\r\nThanks\r\n\r\nDemo Admin",
                "attachment": "",
                "attachments": [
                    []
                ],
                "attachments_removed": false,
                "admin": "Demo Admin",
                "rating": "0"
            },
            {
                "replyid": "2",
                "userid": "1",
                "contactid": "0",
                "name": "",
                "email": "",
                "requestor_name": "Cynthia Reilly",
                "requestor_email": "[email protected]",
                "requestor_type": "Owner",
                "date": "2016-01-01 06:30:16",
                "message": "Hey, \r\n\r\nThis is a second reply!\r\n\r\nThanks\r\n\r\nCynthia",
                "attachment": "",
                "attachments": [
                    []
                ],
                "attachments_removed": false,
                "admin": "",
                "rating": "0"
            }
        ]
    },
    "notes": {
        "note": [
            {
                "noteid": "1",
                "date": "2016-01-01 06:26:42",
                "message": "This is a ticket note",
                "attachment": "",
                "attachments": [
                    []
                ],
                "attachments_removed": false,
                "admin": "Demo Admin"
            }
        ]
    }
}

Version History

VersionChangelog
1.0Initial Version
7.10Added new return parameter attachments.
8.0Added new return parameters requestor_name, requestor_type, and requestor_email.