Linking Chat to Contact
Retrieving contact chats
Method
GET https://subdomain.kommo.com/api/v4/contacts/chats
Description
The method allows you to retrieving a contact’s chats.
Authorization type
OAuth 2.0 with Access Token. Review our Step-by-step Example.
Headers
Content-Type: application/json
Get parameters
Only one of the following two parameters should be used when forming the request.
Parameter | Data type | Description |
contact_id | int | Id of the contact in Kommo |
chat_id | int | Chat id in Kommo Chat API |
Example of the cURL request
curl --location --request GET 'https://subdomain.kommo.com/api/v4/contacts/chats?contact_id=8074730' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiI…..' \
Data type header when the request is successful
Content-Type: application/json
Data type header in case of an error
Content-Type: application/json
HTTP Response Codes
Response code | Condition |
200 | Request successful |
401 | User is not authorized |
Response example
{
"_total_items": 1,
"_embedded": {
"chats": [
{
"chat_id": "4a9d72f9-9933-49f0-841d-8380d369ac11",
"contact_id": 8074730,
"id": 6436428
}
]
}
}
Response parameters
Parameter | Description |
chat_id | Chat id in Kommo Chat API |
contact_id | Id of the contact in Kommo |
id | ID of the chat-to-contact link (can change if the chat link is changed) |
Linking chat to contact
Method
POST https://subdomain.kommo.com/api/v4/contacts/chats
Description
The method allows you to link an existing chat to a contact.
Authorization type
OAuth 2.0 with Access Token. Review our Step-by-step Example.
Headers
Content-Type: application/json
Request body example
[
{
"contact_id": 10711214,
"chat_id": "9fb564bb-369e-48f6-87d2-562e77bc59e6"
}
]
Body parameters
The body is an array, each item of it contains the following fields
Parameter | Data type | Description |
contact_id | int | Id of the contact in Kommo |
chat_id | string | Chat id in Kommo Chat API |
Example of the cURL request
curl --location --request POST 'https://subdomain.kommo.com/api/v4/contacts/chats' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiI…..' \
--header 'Cookie: session_id=bmkfag17hofkqjp2a3g521ovpc; user_lang=en' \
--data-raw '[
{
"contact_id": 10711214,
"chat_id": "9fb564bb-369e-48f6-87d2-562e77bc59e6"
}
]'
Data type header when the request is successful
Content-Type: application/json
Data type header in case of an error
Content-Type: application/json
HTTP Response Codes
Response code | Condition |
200 | Entities linked successfully |
403 | Insufficient rights to call this method |
401 | The user is not authorized |
400 | Invalid data are given. Details are available in the request-response |
Response example
{
"_total_items": 1,
"_embedded": {
"chats": [
{
"chat_id": "9fb564bb-369e-48f6-87d2-562e77bc59e6",
"contact_id": 10711214,
"id": 6815808,
"request_id": "0"
}
]
}
}
Response parameters
Parameter | Description |
chats[chat_id] | Chat id in Kommo Chat API |
chats[contact_id] | Id of the contact in Kommo |
chats[id] | ID of the chat-to-contact link |
chats[request_id] | Number of the request in the input array |