Archive a conversation thread.
1
//native
2
3
/**
4
* Archive Thread
5
* Archive a conversation thread. It is permanently deleted after 30 days unless restored with Unarchive Thread. Requires conversations.write.
6
*/
7
export async function main(auth: RT.Hubspot, thread_id: string) {
8
const url = new URL(
9
`https://api.hubapi.com/conversations/v3/conversations/threads/${thread_id}`
10
)
11
12
const response = await fetch(url, {
13
method: "DELETE",
14
headers: {
15
Authorization: `Bearer ${auth.token}`,
16
Accept: "application/json",
17
},
18
})
19
20
if (!response.ok) {
21
throw new Error(`${response.status} ${await response.text()}`)
22
}
23
if (response.status === 204) return { success: true }
24
25
return await response.json()
26
27