Method upload.chats
Description Loading chats
Available to Agent, Client
Necessary components for working with the method Data API, Loading offline applications from an external system
Maximum number of applications in one request 50 pcs

Required parameters:
- visitor_session_id, campaign_id or site_id (if several parameters are specified, the data must be consistent)
- phone or email

Request parameters

Title Type Required Valid values ​​ Description
access_token string yes Authentication session key
user_id number no Unique user identifier of the agent client on behalf of which the request is made
Is required for the agent
To obtain a list of client users, you must use the method "get.customer_users"
chats array yes List of chats.
Maximum 50
start_date_time iso8601 yes YYYY-MM-DD hh:mm:ss Date and time the chat was created
Cannot be in the future.
Must be later than the transmitted visitor session.
phone string no Visitor phone number in E164 format
email string no Visitor Email
status enum yes lost, succeeded, refused Chat status
lost;
succeed;
refused
If the initiator is visitor and there are no message messages from the operator or visitor, then the passed value in status is ignored and the value is set to lost
initiator enum no operator, visitor, autoinvite Chat initiator
autoinvite,
visitor,
operator
If the parameter is not passed, the first message source ("source") will be taken
visitor_session_id number no Unique identifier of the visitor session received from CallGear. To get the ID, you must use the JS API method Comagic.getSessionId() . In this case, the session must be created no earlier than 180 дней to date_time
campaign_id number no Unique identifier for an advertising campaign in CallGear. To get campaign_id you can use the Data API method "get.campaigns". You cannot pass campaign_id = -1.
source_id number no Unique source identifier. It is possible to transfer only a non-remote source in the context of the client. If visitor_session_id is passed, then we will define source_id using the session parameters.
messages array yes List of chat messages
date_time iso8601 yes YYYY-MM-DD hh:mm:ss Date and time the message was sent
Cannot be in the future.
Must be later than start_date_time.
If the parameter is not passed, the time of the call will be entered
source enum yes operator, visitor, system Message Source
system,
visitor,
operator
employee_id number no Unique employee identifier, required parameter if source = operator(Operator)
The last employee who sent the message will be assigned a chat
message string yes Message
ext_id string no Уникальный идентификатор чата в вашей системе

JSON request structure```json

{ "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", "source_id": "number", "site_id": "number", "messages": [ { "date_time": "iso8601", "source": "enum [operator, visitor, system]", "employee_id": "number", "message": "string" } ], "ext_id": "string" } ] } }

### JSON response structure```json
{
    "jsonrpc": "2.0",
    "id": "number",
    "result": {
        "data": [
            {
                "id": "number"
            }
        ],
        "metadata": "object"
    }
}

List of returned errors

Look at the section "List of errors for methods with the verb upload"