Create a chat

POST https://secure.usedesk.com/uapi/chat/addMessage

Warning. If you use the server version of Usedesk, you will have a different URL of methods. Check the URL for the API with our team — support@usedesk.com.

The method is used to create a chat or send messages to an existing chat on behalf of the client.

You can create a chat only in chat channels, otherwise the system will return the error "status": false.

* — required fields

Parameter Value
api_token* Channel API token

company_id*

Your company ID

It can be found here

channel_id*

The ID of the channel to which the message will be sent

Read about how to set up a channel for chatting here

chat_id

Chat ID

If not specified, the system will create a new chat

message*
text* Message Text
from
client_id ID of the client to which the chat will be bound

If not specified, the system will create a new client
chat_id Chat ID

If not specified, the system will create a new chat
name Client Name
email Client Mail


Request example
{
    "api_token": "e1cbe1c1c9d910ef2ae975215644cb53dd555de4",
    "company_id": 153561,
    "channel_id": 860,
    "chat_id": 1,
    "message":
    {
        "text": "TEST MESSAGE",
        "from":
        {
            "name": "API",
            "email": "api@usedesk.com",
            "client_id": "32917577"
        }
    }
}
        


If the request is successful, the server will return a message about the successful creation.

Request example
{
    "chat_id": 1,
    "company_id": 153561,
    "ticket_id": 3409849,
    "channel_id": 860,
    "client_id": 11115637,
}
        


If this has created a new chat, the system in response will send the data of the new chat.

Request example
{
    "chat_id": 5603949,
    "company_id": 153561,
    "ticket_id": null,
    "channel_id": 860,
    "client_id": 11115637,
}
        


Server response parameters

Parameters Description
chat_id Chat ID
company_id Company ID
ticket_id Ticket ID
channel_id Channel ID
client_id Client ID