0

List threads

by
Published Oct 17, 2025

List threads of comments on a record or list entry. To view threads on records, you will need the `object_configuration:read` and `record_permission:read` scopes. To view threads on list entries, you will need the `list_configuration:read` and `list_entry:read` scopes. Required scopes: `comment:read`.

Script attio Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Attio = {
3
  token: string;
4
};
5
/**
6
 * List threads
7
 * List threads of comments on a record or list entry.
8

9
To view threads on records, you will need the `object_configuration:read` and `record_permission:read` scopes.
10

11
To view threads on list entries, you will need the `list_configuration:read` and `list_entry:read` scopes.
12

13
Required scopes: `comment:read`.
14
 */
15
export async function main(
16
  auth: Attio,
17
  record_id: string | undefined,
18
  object: string | undefined,
19
  entry_id: string | undefined,
20
  list: string | undefined,
21
  limit: string | undefined,
22
  offset: string | undefined,
23
) {
24
  const url = new URL(`https://api.attio.com/v2/threads`);
25
  for (const [k, v] of [
26
    ["record_id", record_id],
27
    ["object", object],
28
    ["entry_id", entry_id],
29
    ["list", list],
30
    ["limit", limit],
31
    ["offset", offset],
32
  ]) {
33
    if (v !== undefined && v !== "" && k !== undefined) {
34
      url.searchParams.append(k, v);
35
    }
36
  }
37
  const response = await fetch(url, {
38
    method: "GET",
39
    headers: {
40
      Authorization: "Bearer " + auth.token,
41
    },
42
    body: undefined,
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50