Retrieve one conversation thread.
1
//native
2
3
/**
4
* Get Thread
5
* Retrieve one conversation thread. Requires conversations.read.
6
*/
7
export async function main(
8
auth: RT.Hubspot,
9
thread_id: string,
10
archived: boolean | undefined
11
) {
12
const url = new URL(
13
`https://api.hubapi.com/conversations/v3/conversations/threads/${thread_id}`
14
)
15
if (archived) url.searchParams.append("archived", String(archived))
16
17
const response = await fetch(url, {
18
headers: {
19
Authorization: `Bearer ${auth.token}`,
20
Accept: "application/json",
21
},
22
})
23
24
if (!response.ok) {
25
throw new Error(`${response.status} ${await response.text()}`)
26
}
27
28
return await response.json()
29
30