Skip to main content

Rest API

Where can I find available methods?

Chat Rest API modules allows to do the following things

  • Check global status is anyone online
  • Check status for custom users
  • Check status for departments
  • And many more...

How do I authenticate?

You can use rest api using these two options.

  • You can create Rest API Key

System configuration -> Live help configuration -> Rest API

  • Use your regular back office logins. You have to have this permission.


Authentication requires username and password (Basic Authentication method). If you are using Rest API keys. Username is a username of the account under which API key is created.

If you are using direct logins username is the account username and password is your account password.

If for some reasons you can't log in make sure that your .htaccess file has the following lines

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

Where this module can be used?

this module can be used for custom status widget generation. Integration LHC with other applicatios. Writing custom UI from scratch

In what format module exports data?

Chat exports data in JSON format. Module also supports PJSON

How to check is anyone online? -  for general check - for PJSON, callback value can be any

How to check is user online? - last parameters is user id - last parameters is user id

How to check is department online? - last parameters is department id. This function checks for online department explicit. That means if for user is assigned all departments department will be offline. - last parameters is department id

How to log online visitor?

This can be used inside any desktop application to log visitor activity in application itself.

$response = $LHCRestAPI->execute('chatcheckoperatormessage', array(
'ip' => ''
'dt' => 'APPLICATIN_NAME - Some Application Specific Window',
'ua' => '', // User Agent
), array(
'vid' => '',                  // It's new visitor it still has not vid assigned
'count_page' => 1,  // Log it as real page view, not just message check from operator
'tz' => 0,                    // Time Zone offset from GMT
'priority' => 0,         // Chat priority
'operator' => 0,       // Operator
'theme' => 0,            // Theme
'survey' => 0,           // Survey (optional)
'department' => 5,  // Department (optional)
'uactiv' => 1              // Is user considered active or not
), 'POST');

If response does not caontains any errors you can vid by

if ($response->error == false && isset($response->result->vid)) {
$response2 = $LHCRestAPI->execute('chatcheckoperatormessage', array(
'ip' => '',
'dt' => 'APPLICATIN_NAME - About window',
'ua' => '', // User Agent
), array(
'vid' => $response->result->vid,
'count_page' => 1,  
'tz' => 0,          
'priority' => 0,    
'operator' => 0,    
'survey' => 0,      
'uactiv' => 1       
), 'POST',true,'');

 // If there is unread message we can read message from operator

    if ($response->error == false && $response->result->action == 'read_message') {
$urlAppend = $response->result->args->url_append;
echo "Reading message from operator\n";

// @todo add message read from operator
} elseif ($response->error == false && $response->result->action == 'continue') {
// Just repeat request

    echo "Second page view\n";
/ } else {
echo "Some error\n";    

Possible action values

  • disable_check - there should not be any more requests to "chatcheckoperatormessage"
  • continue - just continue sending these request untill user makes some actions or just trigger get's activacted
  • read_message - there is pending message from operator or proactive trigger

How to list chats, departments, messages, get chat information?

Just refer to this example


Required permissions to configure Rest API keys.


Apache tricks

If for some reason you can't authenticate refer to this article.