Get a thread
One script reply has been approved by the moderators Verified

Get all comments in a thread.

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.

Created by hugo697 51 days ago
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
type Attio = {
3
  token: string;
4
};
5
/**
6
 * Get a thread
7
 * Get all comments in a thread.
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(auth: Attio, thread_id: string) {
16
  const url = new URL(`https://api.attio.com/v2/threads/${thread_id}`);
17

18
  const response = await fetch(url, {
19
    method: "GET",
20
    headers: {
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31