LiveZilla Live Chat
EN  DE Please sign in or register Hi
Livezilla is a very important sales tool to our business. We have had a success rate of closing sale...
Tony Powell
Show all reviews


LiveZilla API V2




Ticket
Ticket Object Format
Ticket is represented as JSON objects having the following keys:


JSON Key Type Required Read only Comment Example
IdintNoYesThe serial ticket ID11123
GroupstringYesNoGroup Idgroupid1
ChannelintNoNo
Channel

[0] = Web
[1] = Email
[2] = Phone
[3] = Misc
[4] = Chat
[5] = Rating
Read more
SubChannelstringNoNoSub-Channel NameSub Channel Name
LanguagestringNoNoTicket's Langauge (ISO two letter)EN
LastUpdatedintNoYesLast updated time (UNIX Timestamp)1395332206
WaitBeginintNoYesWait begin time (UNIX Timestamp)1395332157
Messagesarray<TicketMessage>NoYesTicket Messages
EditorTicketEditorNoYesTicket Editor (Operator)


Ticket Functions


List Tickets
Function
As of version 5.2.5.0


POST /api/v2/api.php p_tickets_list=1


Filters


Name POST Key Type Required Comment Example  
Idp_idstringNoReturn the ticket matching this Id.11123
Groupp_groupstringNoReturn all tickets of this group.groupid1
Operatorp_operatorstringNoReturn all tickets of this operator.john_doe
Created Afterp_created_afterstringNoReturn all tickets created later than
YYYY-MM-DD HH:MM:SS
2014-01-01 23:59:59
Created Beforep_created_beforestringNoReturn all tickets created earlier than
YYYY-MM-DD HH:MM:SS
2014-01-03 00:00:00
Limitp_limitintNoMaximum number of tickets to return.100
Statusp_statusstringNoReturn all tickets with specific status. Comma-separated list of statuses

[0] = Open
[1] = In Progress
[2] = Closed
[3] = Deleted
[4] = Pending
0,2,3


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_tickets_list=1
-d p_limit=10 -X POST

Response


200 Ok: {
    "Tickets": [
        {
            "Ticket": {
                "Messages": "",
                "Group": "groupid1",
                "Channel": "0",
                "SubChannel": "Sub Channel Name",
                "Language": "EN",
                "LastUpdated": "1395332206",
                "WaitBegin": "1395332157",
                "Editor": "",
                "Id": "11123"
            }
        }
    ]
}

Error Codes


                            403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
                        


Example: PHP code to list all yesterday's tickets



    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_tickets_list"]=1;
            $postd["p_json_pretty"]=1;

            // filter parameters to include yesterday's tickets (100 maximum)
            $yesterdayBegin = strtotime("yesterday");
            $yesterdayEnd = strtotime("today");

            $postd["p_created_after"]=$yesterdayBegin;
            $postd["p_created_before"]=$yesterdayEnd;
            $postd["p_limit"]=100;

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
                exit(curl_error($ch));

            echo $server_output;
            echo "<hr>";
            curl_close($ch);

            $response = json_decode($server_output);

            if(count($response->Tickets) == 0)
            exit("No tickets found");

            foreach($response->Tickets as $obj)
            {
                echo "New ticket: " . $obj->Ticket->Id;
                echo "<br>";
                // further processing ...
            }
    ?>
        



Create Ticket
Function
As of version 5.2.5.0


POST /api/v2/api.php p_ticket_create=1


Filters


Name POST Key Type Required Comment Example  


CURL Example


curl {yourdomain}{livezilla_folder}/api/v2/api.php
-d {authenthication}
-d p_ticket_create=1
-d p_data={ "Ticket": { "Group": "groupid1", "Channel": "0", "SubChannel": "Sub Channel Name", "Language": "EN" } } -X POST

Response


200 Ok: {
    "Ticket": {
        "Messages": "",
        "Group": "groupid1",
        "Channel": "0",
        "SubChannel": "Sub Channel Name",
        "Language": "EN",
        "LastUpdated": "1395332206",
        "WaitBegin": "1395332157",
        "Editor": "",
        "Id": "11123"
    }
}

Error Codes


                            403 Forbidden: Invalid or no user authentication data sent (see General API Authentication)
400 Bad Data: Invalid or missing POST parameters (see required fields/filters and data types)
                        


Example: PHP code to create a ticket


    <?php
            $livezillaURL = "http(s)://{yourdomain}/livezilla/";
            $apiURL = $livezillaURL . "api/v2/api.php";

            // authentication parameters
            $postd["p_user"]='{user_id}';
            $postd["p_pass"]=md5('{user_password}');

            // function parameter
            $postd["p_ticket_create"]=1;
            $postd["p_json_pretty"]=1;

            class Ticket
            {
                public $Group = "support";
                public $CreationType = 0;
                public $Language = "en";
                public $Messages = array();
            }

            $newTicket = new Ticket();
            $postd["p_data"]= json_encode(array("Ticket"=>$newTicket));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$apiURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($postd));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);

            if($server_output === false)
            exit(curl_error($ch));

            // Please don't miss to add a message to your ticket.
            // Tickets with no messages will not be displayed in the operator client software.

            echo $server_output;
            curl_close($ch);
    ?>





Something missing?


If you find anything missing please let us know and we will add the missing structures right away. Thanks.