...

API version

RTM API Reference

Introduction

Versioning

This document describes the Customer Chat Real-Time Messaging API v3.2. This is the legacy version. We encourage you to migrate to the latest stable version. Read more about versioning...

Lifecycle headers

When opening a WebSocket connection, the API responses will contain one of two headers related to the API lifecycle: Legacy or Deprecation. These headers specify when the associated stage ends (in the YYYY-MM-DD format).

What is RTM API

Real-Time Messaging API (RTM API) is based on a websocket-like connection. Client can send a request message that results in getting a response message. It's also possible to get push messages.

When to use RTM API

If you're wondering which API to use - Customer Chat RTM API or Web API, keep on reading.

Real-Time Messaging API allows for building stateful integrations that require logging in and maintaining the connection. Since connection maintenance is required, the implementation might be more challenging than with Web API.

Customer Chat RTM API enables communication in real time. It supports pushes like sneak peek, typing indicator, and other. Web API doesn’t have equivalent webhooks, which means you won't be informed about certain events using Web API.

Also, the RTM API will be a better choice if you want to avoid time delays or presume significant traffic.

Not what you're looking for? Perhaps, you need to use Customer Chat Web API instead.

Access

The basics on authorization and server pinging in the Customer Chat RTM API.

Authorization

Customer authorization is handled with access tokens. Find out how to get an access token from Customer authorization flow. You need to authorize within 30 seconds from establishing the connection. Otherwise, the connection will be closed. Given that the connection is continuosly maintained, you only need to authorize once.

Server pinging

After successful authorization, the client needs to ping the server every 15 seconds. Otherwise, the connection will be closed after about 30 seconds of inactivity. Until authorization is completed, ping is a no-op.

Use one of these 2 ways of pinging the server:

  • Protocol message with the ping action

For web applications and backend integrations (e.g. in Python, Go). Send the following request every 15 seconds:

{
  "action": "ping",
  "payload": {}
}

After pinging the server, the client will receive a response with the ping action. Thanks to that, the client can make sure the connection is still alive.

  • The control frame ping in the websocket protocol

For backend integrations; unavailable in web browsers. Read more about the control frame ping.

Data centers

LiveChat system operates in two data centers: dal (USA) and fra (Europe). The default data center is dal.

For backend applications, you can specify the region in the request header. The mechanism is the same as in Customer Chat Web API reference. It doesn't work for frontend applications, though. Instead, frontend apps connect to a region different than the default one by specifying the region suffix in the URL.

fra: wss://api-fra.livechatinc.com/v3.2/customer/rtm/ws

dal: wss://api.livechatinc.com/v3.2/customer/rtm/ws

Data structures

To find sample payloads of events, users, and other common structures such as chats or threads visit the Data structures document.

Methods

The API endpoint
wss://api.livechatinc.com/v3.2/customer/rtm/ws

When connecting to the Customer Chat RTM API, clients have to send over the required query string parameters.

Required parameterData typeNotes
license_idintegerLiveChat account ID

Available methods

Chatslist_chats list_threads get_chat start_chat activate_chat deactivate_chat
Eventssend_event send_rich_message_postback send_sneak_peek
Propertiesupdate_chat_properties delete_chat_properties update_thread_properties delete_thread_properties update_event_properties delete_event_properties
Customersupdate_customer update_customer_page set_customer_session_fields get_customer
Statuslogin list_group_statuses
Otherget_form get_predicted_agent get_url_info mark_events_as_seen accept_greeting cancel_greeting
GENERAL RTM API REQUEST FORMAT
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "<action>",
  "payload": {
  // optional
  }
}
GENERAL RTM API RESPONSE FORMAT
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "<action>",
  "type": "response",
  "success": true,
  "payload": {
  // optional
  }
}

Chats

List Chats

It returns summaries of the chats a Customer participated in.

Specifics
Actionlist_chats
Web API equivalentlist_chats
Push message-
Request
ParameterRequiredTypeNotes
limitNonumberDefault: 10, maximum: 25
sort_orderNostringPossible values: asc, desc (default). Chat summaries are sorted by the creation date of its last thread.
page_idNostring
Response
FieldData typeNotes
total_chatsnumberAn estimated number. The real number of found chats can slightly differ.
next_page_idstringIn relation to page_id specified in the request. Appears in the response only when there's the next page.
previous_page_idstringIn relation to page_id specified in the request. Appears in the response only when there's the previous page.
chats_summaryarrayArray of Chat summary data structures.
REQUEST
Copied!
{
  "action": "list_chats",
  "payload": {}
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "list_chats",
  "type": "response",
  "success": true,
  "payload": {
    "next_page_id": "MTUxNzM5ODEzMTQ5Ng==",
    "chats_summary": [{
      "id": "PJ0MRSHTDG",
      "last_thread_id": "K600PKZON8",
      "last_thread_created_at": "2020-05-08T08:22:21.128420Z",
      "last_event_per_type": {
        "message": {
          "thread_id": "K600PKZON9",
          "thread_created_at": "2020-05-07T07:11:28.288340Z",
          "event": {
            "id": "Q298LUVPRH_1",
            "created_at": "2019-12-09T12:01:18.909000Z",
            "type": "message",
            "text": "hello world",
            "author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c"
          }
        }
      },
      "users": [{
        "id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
        "type": "customer",
        "present": true
      }, {
        "id": "b5657aff34dd32e198160d54666df9d8",
        "name": "Agent Smith",
        "type": "agent",
        "present": true,
        "avatar": "https://example.com/avatar.png",
        "job_title": "Support Agent"
      }],
      "access": {
        "group_ids": [0]
      },
      "properties": {
        // "Properties" object
      },
      "active": true
    }],
    "total_chats": 1
  }
}

List Threads

It returns threads that the current Customer has access to in a given chat.

Specifics
Actionlist_threads
Web API equivalentlist_threads
Push message-
Request
ParameterRequiredData typeNotes
chat_idYesstring
sort_orderNostringPossible values: asc - oldest threads first and desc - newest threads first (default).
limitNonumberDefault: 3, maximum: 100
page_idNostring
min_events_countNonumberRange: 1-100; Specifies the minimum number of events to be returned in the response. It's the total number of events, so they can come from more than one thread. You'll get as many latest threads as needed to meet the min_events_count condition.

You cannot use both limit and min_events_count at the same time.

REQUEST
Copied!
{
  "action": "list_threads",
    "payload": {
      "chat_id": "PWJ8Y4THAV"
    }
}
Response
Copied!
{
  "request_id": "<request_id>",
  "action": "get_chat",
  "type": "response",
  "success": true,
  "payload": {
    "threads": [{
      "id": "K600PKZON8",
      "created_at": "2019-12-17T07:57:41.512000Z",
      "active": true,
      "user_ids": [
        "b7eff798-f8df-4364-8059-649c35c9ed0c",
        "bbb67d600796e9f277e360e842418833"
      ],
      "events": [{
        "id": "Q20N9CKRX2_1",
        "created_at": "2019-12-17T07:57:41.512000Z",
        "recipients": "all",
        "type": "message",
        "text": "Hello",
        "author_id": "bbb67d600796e9f277e360e842418833"
      }],
      "properties": {
        // "Property" object
      },
      "access": {
        "group_ids": [0]
      },
      "previous_thread_id": "K600PKZOM8", // optional
      "next_thread_id": "K600PKZOO8" // optional
    }],
    "found_threads": 42,
    "next_page_id": "MTUxNzM5ODEzMTQ5Ng==", // optional
    "previous_page_id": "MTUxNzM5ODEzMTQ5Nw==" // optional
  }
}

Get Chat

Specifics
Actionget_chat
Web API equivalentget_chat
Push message-
Request
ParameterRequiredData type
chat_idYesstring
thread_idNostringDefault: the latest thread (if exists)
REQUEST
Copied!
{
  "action": "get_chat",
  "payload": {
    "chat_id": "PJ0MRSHTDG",
    "thread_id": "K600PKZON8"
  }
}
Response
Copied!
{
  "request_id": "<request_id>",
  "action": "get_chat",
  "type": "response",
  "success": true,
  "payload": {
    "id": "PJ0MRSHTDG",
    "thread": {
      "id": "K600PKZON8",
      "created_at": "2020-05-07T07:11:28.288340Z",
      "active": true,
      "user_ids": [
        "b7eff798-f8df-4364-8059-649c35c9ed0c",
        "b5657aff34dd32e198160d54666df9d8"
      ],
      "events": [{
        "id": "Q20N9CKRX2_1",
        "created_at": "2019-12-17T07:57:41.512000Z",
        "type": "message",
        "text": "Hello",
        "author_id": "b5657aff34dd32e198160d54666df9d8"
      }],
      "properties": {
        "0805e283233042b37f460ed8fbf22160": {
          "string_property": "string_value"
        }
      },
      "access": {
        "group_ids": [0]
      },
      "previous_thread_id": "K600PKZOM8",
      "next_thread_id": "K600PKZOO8"
    },
    "users": [{
      "id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
      "type": "customer",
      "present": true
    }, {
      "id": "b5657aff34dd32e198160d54666df9d8",
      "name": "Agent Smith",
      "type": "agent",
      "present": true,
      "avatar": "https://example.com/avatar.jpg",
      "job_title": "Support Agent"
    }],
    "access": {
      "group_ids": [0]
    },
    "properties": {
      "0805e283233042b37f460ed8fbf22160": {
        "string_property": "string_value"
      }
    }
  }
}

Start Chat

Starts a chat.

Specifics
Actionstart_chat
Web API equivalentstart_chat
Push messageincoming_chat
Request
ParameterRequiredData typeNotes
chatNoobject
chat.propertiesNoobjectInitial chat properties
chat.accessNoobjectChat access to set, default: all agents.
chat.usersNoarrayList of existing users. Only one user is allowed (type customer).
chat.threadNoobject
chat.thread.eventsNoarrayInitial chat events array. Does not support the form type event in the LiveChat app.
chat.thread.propertiesNoobjectInitial thread properties
continuousNoboolStarts chat as continuous (online group is not required); default: false.
Response
FieldData typeNotes
chat_idstring
thread_idstring
event_ids[]stringReturned only when the chat was started with initial events. Returns only the IDs of user-generated events; server-side generated events are not included in the array.
REQUEST
Copied!
{
  "action": "start_chat",
  "payload": {}
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "start_chat",
  "type": "response",
  "success": true,
  "payload": {
  "chat_id": "PJ0MRSHTDG",
  "thread_id": "PGDGHT5G"
  }
}

Activate Chat

Used to restart an archived chat.

Specifics
Actionactivate_chat
Web API equivalentactivate_chat
Push messageincoming_chat
Request
ParameterRequiredTypeNotes
chatYesobject
chat.idYesstringThe ID of the chat that will be activated.
chat.accessNoobjectChat access to set, default: all agents.
chat.propertiesNoobjectInitial chat properties
chat.threadNoobject
chat.thread.eventsNoarrayInitial chat events array
chat.thread.propertiesNoobjectInitial thread properties
continuousNoboolSets a chat to the continuous mode. When unset, leaves the mode unchanged.
Response
FieldData typeNotes
thread_idstring
event_ids[]stringReturned only when the chat was activated with initial events. Returns only the IDs of user-generated events; server-side generated events are not included in the array.
REQUEST
Copied!
{
  "action": "activate_chat",
  "payload": {
  "chat": {
    "id": "PWJ8Y4THAV"
  }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "activate_chat",
  "type": "response",
  "success": true,
  "payload": {
  "thread_id": "Z8AGR5OUW"
  }
}

Deactivate Chat

Deactivates a chat by closing the currently open thread. Sending messages to this thread will no longer be possible.

Specifics
Actiondeactivate_chat
Web API equivalentdeactivate_chat
Push messageincoming_event and chat_deactivated
Request
ParameterRequiredData type
chat_idYesstring
REQUEST
Copied!
{
  "action": "deactivate_chat",
  "payload": {
  "chat_id": "PJ0MRSHTDG"
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "deactivate_chat",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Events

Send Event

Sends an Event object. Use this method to send a message by specifying the Message event type in the request.

The method updates the requester's events_seen_up_to as if they've seen all chat events.

Specifics
Actionsend_event
Web API equivalentsend_event
Push messageincoming_event
Request
ParametersRequiredData typeNotes
chat_idYesstringId of the chat you want to send the message to.
eventYesobjectEvent object. Does not support the form type event in the LiveChat app.
attach_to_last_threadNoboolThe flag is ignored for active chats. For inactive chats: true – the event will be added to the last thread; false – the request will fail. Default: false.
REQUEST
Copied!
{
  "action": "send_event",
  "payload": {
  "chat_id": "PW94SJTGW6",
  "event": {
    "type": "message",
    "text": "hello world",
    "recipients": "all"
  }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "send_event",
  "type": "response",
  "success": true,
  "payload": {
   "event_id": "K600PKZON8"
  }
}

Send Rich Message Postback

Specifics
Actionsend_rich_message_postback
Web API equivalentsend_rich_message_postback
Push messageincoming_rich_message_postback*

*) incoming_rich_message_postback will be sent only for active threads.

Request
ParameterRequiredData typeNotes
chat_idYesstring
event_idYesstring
postbackYesobject
postback.idYesstringPostback name of the button
postback.toggledYesboolPostback toggled, true or false
thread_idYesstring
REQUEST
Copied!
{
  "action": "send_rich_message_postback",
  "payload": {
  "chat_id": "PJ0MRSHTDG",
  "thread_id": "K600PKZON8",
  "event_id": "a0c22fdd-fb71-40b5-bfc6-a8a0bc3117f7",
  "postback": {
    "id": "Method URL_yes",
    "toggled": true
  }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "send_rich_message_postback",
  "type": "response",
  "success": true,
  "payload": {
  //no response payload
  }
}

Send Sneak Peek

Sends a sneak peek to a chat.

Specifics
Actionsend_sneak_peek
Web API equivalentsend_sneak_peek
Push message-
Request
ParameterRequiredData typeNotes
chat_idYesstringId of the chat to send a sneak peek to.
sneak_peek_textYesstringSneak peek text
REQUEST
Copied!
{
  "action": "send_sneak_peek",
  "payload": {
  "chat_id": "PJ0MRSHTDG",
  "sneak_peek_text": "hello world"
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "send_sneak_peek",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Properties

Update Chat Properties

Specifics
Actionupdate_chat_properties
Web API equivalentupdate_chat_properties
Push messagechat_properties_updated
Request
ParameterRequiredData typeNotes
chat_idYesstringId of the chat you to set a property for.
propertiesYesobjectChat properties to set. You should stick to the general properties format and include namespace, property name and value.
REQUEST
Copied!
{
  "action": "update_chat_properties",
  "payload": {
  "chat_id": "Q1GZ3FNAT9",
  "properties": {
    "0805e283233042b37f460ed8fbf22160": {
      "string_property": "Chat property value updated by Customer"
      }
    }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "update_chat_properties",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Delete Chat Properties

Specifics
Actiondelete_chat_properties
Web API equivalentdelete_chat_properties
Push messagechat_properties_deleted
Request
ParameterRequiredData typeNotes
chat_idYesstringId of the chat you want to delete properties of.
propertiesYesobjectChat properties to delete.
REQUEST
Copied!
{
  "action": "delete_chat_properties",
  "payload": {
  "chat_id": "Q1GZ3FNAT9",
  "properties": {
    "0805e283233042b37f460ed8fbf22160": [
      "string_property"
      ]
    }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "delete_chat_properties",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Update Thread Properties

Specifics
Actionupdate_thread_properties
Web API equivalentupdate_thread_properties
Push messagethread_properties_updated
Request
ParameterRequiredData typeNotes
chat_idYesstringId of the chat you want to set properties for.
thread_idYesstringId of the thread you want to set properties for.
propertiesYesobjectChat properties to set. You should stick to the general properties format and include namespace, property name and value.
REQUEST
Copied!
{
  "action": "update_thread_properties",
  "payload": {
  "chat_id": "Q1GZ3FNAT9",
    "thread_id": "Q1GZ3FNAU9",
  "properties": {
    "0805e283233042b37f460ed8fbf22160": {
      "string_property": "Thread property value updated by Customer"
      }
    }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "update_thread_properties",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Delete Thread Properties

Specifics
Actiondelete_thread_properties
Web API equivalentdelete_thread_properties
Push messagethread_properties_deleted
Request
ParameterRequiredData typeNotes
chat_idYesstringId of the chat you want to delete the properties of.
thread_idYesstringId of the thread you want to delete the properties of.
propertiesYesobjectThread properties to delete.
REQUEST
Copied!
{
  "action": "delete_thread_properties",
  "payload": {
  "chat_id": "Q1GZ3FNAT9",
  "thread_id": "Q1GZ3FNAU9",
  "properties": {
    "0805e283233042b37f460ed8fbf22160": [
      "string_property"
      ]
    }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "delete_thread_properties",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Update Event Properties

Specifics
Actionupdate_event_properties
Web API equivalentupdate_event_properties
Push messageevent_properties_updated
Request
ParameterRequiredData typeNotes
chat_idYesstringId of the chat you want to set properties for.
thread_idYesstringId of the thread you want to set properties for.
event_idYesstringId of the event you want to set properties for.
propertiesYesobjectChat properties to set. You should stick to the general properties format and include namespace, property name and value.
REQUEST
Copied!
{
  "action": "update_event_properties",
  "payload": {
  "chat_id": "Q1GZ3FNAT9",
  "thread_id": "Q1GZ3FNAU9",
  "event_id": "Q1GZ3FNAU9_1",
  "properties": {
    "0805e283233042b37f460ed8fbf22160": {
      "string_property": "Event property value updated by Customer"
      }
    }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "update_event_properties",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Delete Event Properties

Specifics
Actiondelete_event_properties
Web API equivalentdelete_event_properties
Push messageevent_properties_deleted
Request
ParameterRequiredData typeNotes
chat_idYesstringId of the chat you want to delete the properties of.
thread_idYesstringId of the thread you want to delete the properties of.
event_idYesstringId of the event you want to delete the properties of.
propertiesYesobjectEvent properties to delete.
REQUEST
Copied!
{
  "action": "delete_event_properties",
  "payload": {
  "chat_id": "Q1GZ3FNAT9",
  "thread_id": "Q1GZ3FNAU9",
  "event_id": "Q1GZ3FNAU9_1",
  "properties": {
    "0805e283233042b37f460ed8fbf22160": [
      "string_property"
      ]
    }
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "delete_event_properties",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Customers

Update Customer

Specifics
Actionupdate_customer
Web API equivalentupdate_customer
Push messagecustomer_updated
Request
ParameterRequiredData typeNotes
nameNostring
emailNostring
avatarNostringURL of the Customer's avatar.
session_fieldsNo[]objectAn array of custom object-enclosed key:value pairs. Respects the order of items.

At least one optional parameter needs to be included in the request payload.

When updating customer data while the customer has an active chat, the update will take effect after the chat has ended.

REQUEST
Copied!
{
  "action": "update_customer",
  "payload": {
  "name": "Thomas Anderson",
  "email": "t.anderson@example.com",
  "avatar": "https://example.com/avatars/1.png",
  "session_fields": [{
    "custom_key": "custom_value"
  }, {
    "another_custom_key": "another_custom_value"
  }]
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "update_customer",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Update Customer Page

Specifics
Actionupdate_customer_page
Web API equivalent-
Push messagecustomer_page_updated

Agent and referrer are updated by default using the browser’s headers.

Request
ParameterRequiredData type
urlYesstring
titleNostring
REQUEST
Copied!
{
  "action": "update_customer_page",
  "payload": {
  "url": "https://livechatinc.com/pricing"
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "update_customer_page",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Set Customer Session Fields

Specifics
Actionset_customer_session_fields
Web API equivalentset_customer_session_fields
Push messagecustomer_updated
Request
ParameterRequiredData typeNotes
session_fieldsYes[]objectAn array of custom object-enclosed key:value pairs. Respects the order of items. Max keys: 100

Agent and referrer are updated by default using the browser’s headers.

REQUEST
Copied!
{
  "action": "set_customer_session_fields",
  "payload": {
  "session_fields": [{
    "custom_key": "custom_value"
  }, {
    "another_custom_key": "another_custom_value"
  }],
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "set_customer_session_fields",
  "type": "response",
  "success": true,
  "payload": {
  // no response payload
  }
}

Get Customer

Returns the info about the Customer requesting it.

Specifics
Actionget_customer
Web API equivalentget_customer
Push message-
Response
nameCustomer's name. Returned only if set.
emailCustomer's email. Returned only if set.
avatarCustomer's avatar. Returned only if set.
session_fieldsAn array of custom object-enclosed key:value pairs. Returned only if set. Available for the session duration.
REQUEST
Copied!
{
  "action": "get_customer",
  "payload": {
  "session_fields": [{
    "custom_key": "custom_value"
  }, {
    "another_custom_key": "another_custom_value"
  }],
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "get_customer",
  "type": "response",
  "success": true,
  "payload": {
  "id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
  "type": "customer",
  "name": "Thomas Anderson", // optional
  "email": "t.anderson@example.com", // optional
  "avatar": "https://example.com/avatars/1.jpg", // optional
  "session_fields": [{ // optional
    "custom_key": "custom_value"
  }, {
    "another_custom_key": "another_custom_value"
  }]
  }
}

Status

Login

It returns the initial state of the current Customer.

Specifics
Actionlogin
Web API equivalent-
Push message-
Request
ParameterRequiredData typeNotes
tokenYesstringOAuth token from the Customer's account
customerNoobject
customer.avatarNostringThe URL of the Customer's avatar
customer.emailNostring
customer.nameNostring
customer.session_fieldsNo[]objectAn array of custom object-enclosed key:value pairs. Respects the order of items.
customer_page.titleNostring
customer_page.urlNostring
customer_side_storage*NoobjectA map in the "key": "value" format
is_mobileNoboolInforms if logging in is performed from a mobile device.
group_idNonumber
referrerNostring
applicationNoobjectApplication info
application.nameNostringApplication name
application.versionNostringApplication version
application.channel_typeNostringApplication channel type

*) We use customer_side_storage to keep some data on the client side. You should pass a map from the customer_side_storage_updated push payload to this field.

REQUEST
Copied!
{
  "action": "login",
  "payload": {
    "token": "Bearer dal:test_1fgTbfXmgthj4cZSA"
    }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "login",
  "type": "response",
  "success": true,
  "payload": {
    "customer": {
      "id": "a0c22fdd-fb71-40b5-bfc6-a8a0bc3117f5",
      "name": "Thomas Anderson",
      "email": "t.anderson@example.com",
      "avatar": "https://example.com/avatar.png",
      "session_fields": [{
        "custom_key": "custom_value"
      }, {
        "another_custom_key": "another_custom_value"
      }],
      "statistics": {
        "chats_count": 2,
        "threads_count": 9,
        "visits_count": 15,
        "page_views_count": 40,
        "greetings_shown_count": 20,
        "greetings_accepted_count": 1
      }
    },
    "has_active_thread": true,
    "chats": [{
      "chat_id": "PJ0MRSHTDG",
      "has_unread_events": true
    }],
    "greeting": {
      "accepted": true, // Customer has seen the greeting
      "id": 342543723,
      "unique_id": "e35a4fb4106d87e550fe1af480639058",
      "addon": "email",
      "event": {
        // "Event > Message" object
        // or
        // "Event > Rich message" object
      },
      "agent": {
        "id": "b5657aff34dd32e198160d54666df9d8",
        "name": "Agent Smith",
        "type": "agent",
        "avatar": "https://example.com/avatar.png",
        "job_title": "Support Agent",
        "is_bot": false
      },
      "displayed_first_time": true
    },
    "__priv_dynamic_config": {
      "online_groups_ids": [1, 3],
      "customer_groups": {
        "monitoring": {
          "id": 1,
          "static_config_url": "/licence/1520/get_static_config.121.1808829.94.95.39446.4011.2385.398.160.552.58.337.44320.js",
          "language_config_url": "/licence/1520/v2/localization.en.121.004b8e014f50ea0c6ad6227162f7d18f_40d391a9adcdbf190e62fcd21c865bf2.js"
        }
      }
    }
  }
}

List Group Statuses

Specifics
Actionlist_group_statuses
Web API equivalentlist_group_statuses
Push message-
Request
ParameterRequiredData typeNotes
allNoboolIf set to true, you will get statuses of all the groups.
group_idsNoarrayA table of a groups' IDs

One of the optional parameters needs to be included in the request payload.

Response
Group Not FoundIf you send group_id of a group that doesn't exists, the id won't be included in the resposne payload.
REQUEST
Copied!
{
  "action": "list_group_statuses",
  "payload": {
  "all": true
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "list_group_statuses",
  "type": "response",
  "success": true,
  "payload": {
  "groups_status": {
    //1,2,3 are group ids, online/offline/online_for_queue are statuses of the groups

    1: "online",
    2: "offline",
    3: "online_for_queue"
  }
  }
}

Other

Get Form

Returns an empty ticket form of a prechat or postchat survey.

Specifics
Actionget_form
Web API equivalentget_form
Push message-
Request
ParameterRequiredData typeNotes
group_idYesnumberId of the group from which you want the form.
typeYesstringForm type. Possible values: prechat or postchat.
Response
FieldNotes
enabledIf enabled: false, the form object is not returned. Prechat/postchat survey disabled in the LiveChat Agent App UI.
formThe form object
REQUEST
Copied!
{
  "action": "get_form",
  "payload": {
  "group_id": 0,
  "type": "prechat"
  }
}
Response
Copied!
{
  "form": {
    "id": "157986144052005549",
    "fields": [
      {
        "id": "157986144052003238",
        "type": "header",
        "label": "Welcome to our LiveChat! Please fill in the form below before starting the chat."
      },
      {
        "id": "157986144052008371",
        "type": "name",
        "label": "Name:",
        "required": false
      },
      {
        "id": "157986144052005782",
        "type": "email",
        "label": "E-mail:",
        "required": false
      },
      {
        "id": "157986144052009331",
        "type": "group_chooser",
        "label": "Choose a department:",
        "required": true,
        "options": [
          {
            "id": "0",
            "group_id": 1,
            "label": "Marketing"
          },
          {
            "id": "1",
            "group_id": 2,
            "label": "Sales"
          },
          {
            "id": "2",
            "group_id": 0,
            "label": "General"
          }
        ]
      }
    ]
  },
  "enabled": true
}

Get Predicted Agent

Gets the predicted Agent - the one the Customer will chat with when the chat starts.

Specifics
Actionget_predicted_agent
Web API equivalentget_predicted_agent
Push message-
REQUEST
Copied!
{
  "action": "get_predicted_agent",
  "payload": {}
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "get_predicted_agent",
  "type": "response",
  "success": true,
  "payload": {
  "id": "b5657aff34dd32e198160d54666df9d8",
  "name": "Agent Smith",
  "avatar": "https://example.avatar/example.com",
  "is_bot": false,
  "job_title": "support hero",
  "type": "agent"
  }
}

Get URL Info

It returns the info on a given URL.

Specifics
Actionget_url_info
Web API equivalentget_url_info
Push message-
Request
ParameterRequiredData typeNotes
urlYesstringValid website URL
Response
FieldData typeNotes
image_urlstringURL of the minified image hosted on the LiveChat's CDN
image_original_urlstringURL of the original image
REQUEST
Copied!
{
  "action": "get_url_info",
  "payload": {
  "url": "https://livechatinc.com"
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "get_url_info",
  "type": "response",
  "success": true,
  "payload": {
  "title": "LiveChat | Live Chat Software and Help Desk Software",
  "description": "LiveChat - premium live chat software and help desk software for business. Over 24 000 companies from 150 countries use LiveChat. Try now, chat for free!",
  "image_url": "https://example.com/image.png",
  "image_original_url": "https://example-original-url.com/image.png",
  "image_width": 200,
  "image_height": 200,
  "url": "https://livechatinc.com"
  }
}

Mark Events As Seen

Specifics
Actionmark_events_as_seen
Web API equivalentmark_events_as_seen
Push messageevents_marked_as_seen
Request
ParameterRequiredData typeNotes
chat_idYesstring
seen_up_toYesstringRFC 3339 date-time format
Response

No response payload (200 OK).

REQUEST
Copied!
{
  "action": "mark_events_as_seen",
  "payload": {
  "chat_id": "PJ0MRSHTDG",
  "seen_up_to": "2017-10-12T15:19:21.010200Z"
  }
}

Accept Greeting

Marks an incoming greeting as seen.

How it's implemented in LiveChat:

The Chat Widget uses this method to inform that a Customer has seen a greeting. Based on that, the Reports section displays the greetings that were actually seen by Customers, not all the sent greetings. If a Customer started a chat from a greeting, but the Accept Method wasn't executed, the greeting is still counted as seen in Reports.

Specifics
Actionaccept_greeting
Web API equivalentaccept_greeting
Push messagegreeting_accepted
Request
ParameterRequiredData typeNotes
greeting_idYesnumberID of the greeting configured within the license to accept.
unique_idYesstringID of the greeting to accept. You can get it from the incoming_greeting push.
REQUEST
Copied!
{
  "action": "accept_greeting",
  "payload": {
    "greeting_id": 7,
    "unique_id": "Q10X0W041P"
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "accept_greeting",
  "type": "response",
  "payload": {
    // no response payload
  },
  "success": true
}

Cancel Greeting

Cancels a greeting (an invitation to the chat). For example, Customers could cancel greetings by minimizing the chat widget with a greeting.

Specifics
Actioncancel_greeting
Web API equivalentcancel_greeting
Push messagegreeting_canceled
Request
ParameterRequiredData typeNotes
unique_idYesstringID of the greeting to cancel. You can get it from the incoming_greeting push.
REQUEST
Copied!
{
  "action": "cancel_greeting",
  "payload": {
    "unique_id": "Q10X0W041P"
  }
}
Response
Copied!
{
  "request_id": "<request_id>", // optional
  "action": "cancel_greeting",
  "type": "response",
  "payload": {
  // no response payload
  },
  "success": true
}

Pushes

Here's what you need to know about pushes:

  • They are generated primarily by RTM API actions, but also by Web API actions.
  • They notify you when specific events occur.
  • Can be delivered only in the websocket transport.
  • You don't need to register pushes to receive them.
  • Their equivalents in Web API are webhooks. Pushes and webhooks have similar payloads.
  • There are no retries for pushes. To determine if a customer has seen an event, compare the event's created_at parameter with the customer's events_seen_up_to field.
See available pushes
The general push format
Copied!
{
  "request_id": "<request_id>", // optional, applies only to the requester
  "action": "<action>",
  "type": "push",
  "payload": {
  // optional payload
  }
}

Errors

General error format
Copied!
{
  "error": {
    "type": "misdirected_request",
    "message": "Wrong region",
    "data": {
      // optional
      "region": "dal"
    }
  }
}

Possible errors

Error typeDefault messageDescription
authenticationAuthentication errorAn invalid or expired access token.
authorizationAuthorization errorUser is not allowed to perform the action.
chat_inactiveNo active chat threadAn action that requires an active thread performed on a chat with no active threads.
customer_bannedCustomer is bannedThe customer had been banned.
greeting_not_foundGreeting not found
group_not_foundGroup not found
group_offlineGroup is offlineThrown in response to Get Predicted Agent.
group_unavailableNo agent available for groupThrown in response to Get Predicted Agent. The group is online, but there are no available Agents.
groups_offlineGroups offline
internalInternal server error
license_expiredLicense expiredThe end of license trial or subcription.
limit_reachedResource limit reachedResource cannot be created/modified because the change would exceed the limit
not_allowedNot allowedThe action is not allowed.
not_foundNot foundThe requested resource wasn't found.
pending_requests_limit_reachedRequests limit reachedThe limit of pending requests within one websocket connection has been reached. The limit is 10.
request_timeoutRequest timed outTimeout threshold is 15 seconds.
service_unavailableNot accepting new requestsNew requests are temporarily not being accepted.
too_many_requestsToo many requestsThe request's rate limit was exceeded. It'll be unblocked automatically after some time.
unsupported_versionUnsupported versionUnsupported protocol version.
users_limit_reachedUsers limit reached Displayed on the attempt of logging in. The limit of online Customers for a given license has been reached.
validationWrong format of request
wrong_product_versionWrong product versionLicense is not LiveChat 3 (probably still LiveChat 2).

Contact us

If you found a bug or a typo, you can let us know directly on GitHub. In case of any questions or feedback, don't hesitate to contact us at developers@livechat.com. We'll be happy to hear from you!

...