//native
/**
* Archive Thread
* Archive a conversation thread. It is permanently deleted after 30 days unless restored with Unarchive Thread. Requires conversations.write.
*/
export async function main(auth: RT.Hubspot, thread_id: string) {
const url = new URL(
`https://api.hubapi.com/conversations/v3/conversations/threads/${thread_id}`
)
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
if (response.status === 204) return { success: true }
return await response.json()
}
Submitted by hugo989 4 hours ago