Ends a chat started with Start widget chat. The chat_ended webhook is sent and post-chat analysis runs, as with End chat. Ending a chat that already ended succeeds and changes nothing.
The chat widget sends this request with navigator.sendBeacon when the visitor leaves the page. The same chat_token and Origin rules as Send widget chat message apply.
Request#
Path parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id |
string | Yes | The chat_id from Start widget chat. |
Body#
| Field | Type | Required | Description |
|---|---|---|---|
chat_token |
string | Yes | The chat_token from Start widget chat. |
Example request#
curl -X POST "https://api.tried.com.au/public/chat/chat_0a1b2c3d4e5f6a7b8c9d0e1f/end" \
-H "Origin: https://www.example.com" \
-H "Content-Type: application/json" \
-d '{
"chat_token": "Xq3v9mZ0b1Rk2LpT8wYc4nHs6aGd5eFj7uQi0oPl1Ns"
}'// Runs in the browser on an allowed domain.
await fetch(`https://api.tried.com.au/public/chat/${chat.chat_id}/end`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ chat_token: chat.chat_token }),
});import requests
requests.post(
"https://api.tried.com.au/public/chat/chat_0a1b2c3d4e5f6a7b8c9d0e1f/end",
headers={"Origin": "https://www.example.com"},
json={"chat_token": "Xq3v9mZ0b1Rk2LpT8wYc4nHs6aGd5eFj7uQi0oPl1Ns"},
)Response#
200 OK
{ "ok": true }Errors#
| Status | When |
|---|---|
400 |
Validation failed, for example a missing chat_token. |
403 |
Invalid chat token, or Origin not allowed. |
404 |
Chat not found. |
429 |
Per-IP rate limit exceeded. See Rate limits. |
See Errors for the body format.