Restore an archived conversation thread.
1
//native
2
3
/**
4
* Unarchive Thread
5
* Restore an archived conversation thread. Requires conversations.write.
6
*/
7
export async function main(auth: RT.Hubspot, thread_id: string) {
8
const response = await fetch(
9
`https://api.hubapi.com/conversations/v3/conversations/threads/${thread_id}?archived=true`,
10
{
11
method: "PATCH",
12
headers: {
13
Authorization: `Bearer ${auth.token}`,
14
"Content-Type": "application/json",
15
Accept: "application/json",
16
},
17
body: JSON.stringify({ archived: false }),
18
}
19
)
20
21
if (!response.ok) {
22
throw new Error(`${response.status} ${await response.text()}`)
23
24
25
return await response.json()
26
27