curl --request POST \
--url https://api.chatling.ai/v3/conversations/{conversation}/end \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.chatling.ai/v3/conversations/{conversation}/end"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.chatling.ai/v3/conversations/{conversation}/end', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chatling.ai/v3/conversations/{conversation}/end",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.chatling.ai/v3/conversations/{conversation}/end"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.chatling.ai/v3/conversations/{conversation}/end")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/conversations/{conversation}/end")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "conversation",
"id": "5f0c1c2e-6c1d-4a8f-9a59-0d4c4f1b2a10",
"agent": {
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent"
},
"channel": "web",
"user_id": "0b6f3c1e-8d2a-4f5b-9c7e-1a2b3c4d5e6f",
"external_user_id": "<string>",
"status": "open",
"mode": "ai",
"ended_at": "2023-11-07T05:31:56Z",
"read": true,
"important": true,
"priority": "low",
"labels": [
{
"id": "<string>",
"name": "<string>"
}
],
"topics": [
{
"id": "<string>",
"name": "<string>",
"source": "ai"
}
],
"sentiment": "positive",
"assignee": {
"id": "<string>",
"name": "<string>"
},
"team": {
"id": "<string>",
"name": "<string>"
},
"contact": {
"id": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"email": "<string>",
"phone": "<string>",
"job_title": "<string>",
"company": "<string>",
"website": "<string>",
"industry": "<string>",
"address": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"variables": [
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"name": "order_id",
"value": "<string>"
}
],
"locale": "<string>",
"country": "<string>",
"reply_window": {
"closes_at": "2023-11-07T05:31:56Z",
"team_reply_closes_at": "2023-11-07T05:31:56Z"
},
"created_at": "2023-11-07T05:31:56Z",
"last_message_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is invalid or has been revoked.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "permission_error",
"code": "insufficient_permission",
"message": "This API key doesn't have delete access to agents.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "not_found_error",
"code": "resource_not_found",
"message": "No conversation with this ID exists, or this API key can't access it.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "api_error",
"code": "end_failed",
"message": "The conversation couldn't be ended. Retry shortly.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}End a conversation
Ends the user’s session, like ending a chat in the inbox. A “chat ended” message is added, and the user can’t write in the conversation again. Ending an ended conversation has no effect. The conversation’s status doesn’t change. To change it, use Update a conversation.
curl --request POST \
--url https://api.chatling.ai/v3/conversations/{conversation}/end \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.chatling.ai/v3/conversations/{conversation}/end"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.chatling.ai/v3/conversations/{conversation}/end', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chatling.ai/v3/conversations/{conversation}/end",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.chatling.ai/v3/conversations/{conversation}/end"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.chatling.ai/v3/conversations/{conversation}/end")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/conversations/{conversation}/end")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "conversation",
"id": "5f0c1c2e-6c1d-4a8f-9a59-0d4c4f1b2a10",
"agent": {
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent"
},
"channel": "web",
"user_id": "0b6f3c1e-8d2a-4f5b-9c7e-1a2b3c4d5e6f",
"external_user_id": "<string>",
"status": "open",
"mode": "ai",
"ended_at": "2023-11-07T05:31:56Z",
"read": true,
"important": true,
"priority": "low",
"labels": [
{
"id": "<string>",
"name": "<string>"
}
],
"topics": [
{
"id": "<string>",
"name": "<string>",
"source": "ai"
}
],
"sentiment": "positive",
"assignee": {
"id": "<string>",
"name": "<string>"
},
"team": {
"id": "<string>",
"name": "<string>"
},
"contact": {
"id": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"email": "<string>",
"phone": "<string>",
"job_title": "<string>",
"company": "<string>",
"website": "<string>",
"industry": "<string>",
"address": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"variables": [
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"name": "order_id",
"value": "<string>"
}
],
"locale": "<string>",
"country": "<string>",
"reply_window": {
"closes_at": "2023-11-07T05:31:56Z",
"team_reply_closes_at": "2023-11-07T05:31:56Z"
},
"created_at": "2023-11-07T05:31:56Z",
"last_message_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is invalid or has been revoked.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "permission_error",
"code": "insufficient_permission",
"message": "This API key doesn't have delete access to agents.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "not_found_error",
"code": "resource_not_found",
"message": "No conversation with this ID exists, or this API key can't access it.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"type": "api_error",
"code": "end_failed",
"message": "The conversation couldn't be ended. Retry shortly.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}Headers
Response
The ended conversation.
Identifies the person chatting. It's the same in all their conversations with the agent, including for anonymous widget users who aren't contacts. On the web, it's the widget's ID for the user's browser. Through the API, it's derived from external_user_id, or new for each conversation without one. On WhatsApp, it's the user's phone number. On Instagram and Messenger, it's the user's ID for the account or page, and on Telegram, the chat ID. null for some older conversations.
"0b6f3c1e-8d2a-4f5b-9c7e-1a2b3c4d5e6f"