List Threads
curl --request GET \
--url https://{appId}.api-{region}.cometchat.io/v3/threads \
--header 'apikey: <api-key>'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/threads"
headers = {"apikey": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {apikey: '<api-key>'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/threads', 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://{appId}.api-{region}.cometchat.io/v3/threads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"apikey: <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://{appId}.api-{region}.cometchat.io/v3/threads"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apikey", "<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://{appId}.api-{region}.cometchat.io/v3/threads")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/threads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["apikey"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "4002",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "message",
"type": "text",
"data": {
"entities": {
"receiver": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "George Alan",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-2"
},
"entityType": "user"
},
"sender": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "Andrew Joseph",
"role": "default",
"status": "offline",
"tags": [
"abc"
],
"uid": "cometchat-uid-1",
"updatedAt": 1783944695
},
"entityType": "user"
}
},
"moderation": {
"rule": {
"id": "customrule",
"name": "custom-rule"
},
"status": "disapproved"
},
"text": "123"
},
"sentAt": 1784014343,
"updatedAt": 1784014370,
"replyCount": 1,
"lastReply": {
"id": "4003",
"muid": "",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "message",
"type": "text",
"data": {
"entities": {
"receiver": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "George Alan",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-2"
},
"entityType": "user"
},
"sender": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "Andrew Joseph",
"role": "default",
"status": "offline",
"tags": [
"abc"
],
"uid": "cometchat-uid-1",
"updatedAt": 1783944695
},
"entityType": "user"
}
},
"moderation": {
"status": "approved"
},
"text": "Hello in thread"
},
"sentAt": 1784014370,
"editedAt": null,
"editedBy": "",
"deliveredAt": null,
"readAt": null,
"deletedAt": null,
"updatedAt": 1784014370
}
}
],
"meta": {
"current": {
"limit": 100,
"count": 1
},
"next": {
"affix": "append",
"updatedAt": 1784014370
}
}
}Messages
List Threads
List CometChat message threads with REST API to fetch thread conversations across your app.
GET
/
threads
List Threads
curl --request GET \
--url https://{appId}.api-{region}.cometchat.io/v3/threads \
--header 'apikey: <api-key>'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/threads"
headers = {"apikey": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {apikey: '<api-key>'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/threads', 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://{appId}.api-{region}.cometchat.io/v3/threads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"apikey: <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://{appId}.api-{region}.cometchat.io/v3/threads"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apikey", "<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://{appId}.api-{region}.cometchat.io/v3/threads")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/threads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["apikey"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "4002",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "message",
"type": "text",
"data": {
"entities": {
"receiver": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "George Alan",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-2"
},
"entityType": "user"
},
"sender": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "Andrew Joseph",
"role": "default",
"status": "offline",
"tags": [
"abc"
],
"uid": "cometchat-uid-1",
"updatedAt": 1783944695
},
"entityType": "user"
}
},
"moderation": {
"rule": {
"id": "customrule",
"name": "custom-rule"
},
"status": "disapproved"
},
"text": "123"
},
"sentAt": 1784014343,
"updatedAt": 1784014370,
"replyCount": 1,
"lastReply": {
"id": "4003",
"muid": "",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "message",
"type": "text",
"data": {
"entities": {
"receiver": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "George Alan",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-2"
},
"entityType": "user"
},
"sender": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"createdAt": 1783932561,
"lastActiveAt": 1783932561,
"name": "Andrew Joseph",
"role": "default",
"status": "offline",
"tags": [
"abc"
],
"uid": "cometchat-uid-1",
"updatedAt": 1783944695
},
"entityType": "user"
}
},
"moderation": {
"status": "approved"
},
"text": "Hello in thread"
},
"sentAt": 1784014370,
"editedAt": null,
"editedBy": "",
"deliveredAt": null,
"readAt": null,
"deletedAt": null,
"updatedAt": 1784014370
}
}
],
"meta": {
"current": {
"limit": 100,
"count": 1
},
"next": {
"affix": "append",
"updatedAt": 1784014370
}
}
}For the complete error reference, see Error Guide.
Authorizations
API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
Headers
UID of the user on whose behalf the action is performed.
Query Parameters
Number of threads to be fetched in a request. The default value is 100 and the maximum value is 1000.
Cursor direction used for pagination.
Available options:
append, prepend Cursor value (updatedAt) used for pagination.
Lists only the threads the user has participated in.
Enriches each thread with the per-user unread reply count.
Enriches each thread with the per-user unread mention count.
Was this page helpful?
⌘I