Skip to content

Uploading chats

Method upload.chats
Description Uploading chats
Who has access Agent, Customer
Components required to work with the method Data API, Uploading offline inquiries from an outside system
Maximum number of inquiries per request 500

Required parameters:
- session_id, campaign_id or site_id (if several parameters are stated, the data should be consistent)
- phone or email

Parameters of a request

Title Type Required Valid value Description
access_token string yes Authentication session key
user_id number no Unique user ID of a customer of an agent who makes request.
Is mandatory for agent
Ypu can get access to a list of customer users via the method "get.customer_users"
chats array yes List of chats.
Maximum 500
start_date_time iso8601 yes YYYY-MM-DD hh:mm:ss Date and time
Can't be in the future.
Can't be later than in a transmitted visitor's session
name string no Username
phone string no Visitor's phone number in the format E164
email string no Visitor's email
status enum yes lost,succeed, refused Chat status
lost (lost);
succeed (succeeded);
refused (refused)
initiator enum no operator, visitor,autoinvite Chat initiator
autoinvite (autoinvite),
visitor (Visitor),
operator(Operator)
If the parameter is not given, the first source of a message will be used ("source")
visitor_session_id number no Unique ID of a visitor's session from CallGear. To get an ID you need to use the method JS API CallGear.getSessionId()
campaign_id number no Unique ID of an advertising campaign in CallGear. To get campaign_id you can use Data API "get.campaigns"
site_id number no Unique website ID
messages array yes List of messages in a chat
date_time iso8601 yes YYYY-MM-DD hh:mm:ss Date and time when a message was sent
Can't be in the future.
Must be later than start_date_time.
If the parameter is not given, time of a call will be used
source enum yes operator, visitor,system Message source
system (autoinvite),
visitor (Visitor),
operator(Operator)
employee_id number no Unique ID of an employee, required if source = operator(Operator)
Chat will be appointed to the last employee who sent a message
message string yes Message

JSON request structure

{
    "jsonrpc": "2.0",
    "id": "number",
    "method": "upload.chats",
    "params": {
        "access_token": "string",
        "user_id": "number",
        "chats": [
            {
                "start_date_time": "iso8601",
                "name": "string",
                "phone": "string",
                "email": "string",
                "status": "enum [lost,succeed, refused]",
                "initiator": "enum [operator, visitor,autoinvite]",
                "visitor_session_id": "number",
                "campaign_id": "number",
                "site_id": "number",
                "messages": [
                    {
                        "date_time": "iso8601",
                        "source": "enum [operator, visitor, system]",
                        "employee_id": "number",                      
                        "message": "string"
                    }
                ]
            }
        ]
    }
}

JSON reply structure

{
    "jsonrpc": "2.0",
    "id": "number",
    "result": {
        "data": [
            {
                "id": "number"
            }
        ],
        "metadata": "object"
    }
}

List of returning errors

Refer to "List of errors common for methods with the verb upload"