Get Chat
curl --request GET \
--url https://api.example.com/api/v1/chats/{chat_id} \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://api.example.com/api/v1/chats/{chat_id}"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://api.example.com/api/v1/chats/{chat_id}', 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.example.com/api/v1/chats/{chat_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$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.example.com/api/v1/chats/{chat_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/chats/{chat_id}")
.header("X-API-Key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/chats/{chat_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"user_id": "user123",
"tenant_id": "tenant-uuid-here",
"title": "Support Session",
"config": {
"metadata": {
"department": "technical",
"priority": "high",
"category": "account_issue"
}
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:35:00Z",
"last_message_at": "2024-01-15T10:35:00Z",
"message_count": 12,
"status": "active"
}
Chats
Get Chat
GET
/
api
/
v1
/
chats
/
{chat_id}
Get Chat
curl --request GET \
--url https://api.example.com/api/v1/chats/{chat_id} \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://api.example.com/api/v1/chats/{chat_id}"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://api.example.com/api/v1/chats/{chat_id}', 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.example.com/api/v1/chats/{chat_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$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.example.com/api/v1/chats/{chat_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/chats/{chat_id}")
.header("X-API-Key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/chats/{chat_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"user_id": "user123",
"tenant_id": "tenant-uuid-here",
"title": "Support Session",
"config": {
"metadata": {
"department": "technical",
"priority": "high",
"category": "account_issue"
}
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:35:00Z",
"last_message_at": "2024-01-15T10:35:00Z",
"message_count": 12,
"status": "active"
}
Get Chat
This endpoint retrieves detailed information about a specific chat session, including its configuration and metadata.Authentication
string
required
Authentication header with your tenant’s API key
Path Parameters
string
required
The unique identifier (UUID) of the chat to retrieve
Response
string
Unique identifier for the chat session
string
The ID of the user who owns this chat
string
The tenant identifier
string
The title of the chat session
object
Configuration object containing metadata and chat settings
string
Timestamp when the chat was created
string
Timestamp when the chat was last updated
string | null
Timestamp of the last message in this chat
integer
Total number of messages in this chat
string
Current status of the chat (e.g., “active”, “closed”)
{
"id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"user_id": "user123",
"tenant_id": "tenant-uuid-here",
"title": "Support Session",
"config": {
"metadata": {
"department": "technical",
"priority": "high",
"category": "account_issue"
}
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:35:00Z",
"last_message_at": "2024-01-15T10:35:00Z",
"message_count": 12,
"status": "active"
}
Error Responses
401: Unauthorized
401: Unauthorized
Invalid or missing API key
404: Not Found
404: Not Found
Chat not found or doesn’t belong to your tenant
500: Internal Server Error
500: Internal Server Error
Server error processing the request
Example Usage
cURL
curl -X GET "http://localhost:8000/api/v1/chats/a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d" \
-H "X-API-Key: your-tenant-api-key"
JavaScript
const chatId = 'a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d';
fetch(`http://localhost:8000/api/v1/chats/${chatId}`, {
method: 'GET',
headers: {
'X-API-Key': 'your-tenant-api-key'
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(chat => {
console.log(`Chat: ${chat.title}`);
console.log(`Messages: ${chat.message_count}`);
console.log(`Last activity: ${chat.last_message_at}`);
console.log(`Status: ${chat.status}`);
})
.catch(error => console.error('Error:', error));
Python
import requests
chat_id = "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
url = f"http://localhost:8000/api/v1/chats/{chat_id}"
headers = {"X-API-Key": "your-tenant-api-key"}
response = requests.get(url, headers=headers)
if response.status_code == 200:
chat = response.json()
print(f"Chat: {chat['title']}")
print(f"Messages: {chat['message_count']}")
print(f"Last activity: {chat['last_message_at']}")
print(f"Status: {chat['status']}")
elif response.status_code == 404:
print("Chat not found")
else:
print(f"Error: {response.status_code}")
React Hook Example
import { useState, useEffect } from 'react';
function useChat(chatId) {
const [chat, setChat] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
if (!chatId) return;
fetch(`http://localhost:8000/api/v1/chats/${chatId}`, {
headers: {
'X-API-Key': 'your-tenant-api-key'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Chat not found');
}
return response.json();
})
.then(setChat)
.catch(setError)
.finally(() => setLoading(false));
}, [chatId]);
return { chat, loading, error };
}
// Usage in component
function ChatHeader({ chatId }) {
const { chat, loading, error } = useChat(chatId);
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
if (!chat) return null;
return (
<div>
<h1>{chat.title}</h1>
<p>{chat.message_count} messages</p>
<p>Status: {chat.status}</p>
</div>
);
}
Notes
- Only chats belonging to your tenant can be accessed
- This endpoint is useful for retrieving chat metadata before connecting via WebSocket
- The
configobject contains any custom metadata you stored when creating the chat message_countgives you a quick overview without fetching all messages- Use this endpoint to validate chat existence before establishing WebSocket connections