//native
/**
* Update Thread
* Open or close a conversation thread. Requires conversations.write.
*/
export async function main(
auth: RT.Hubspot,
thread_id: string,
status: "OPEN" | "CLOSED"
) {
const url = new URL(
`https://api.hubapi.com/conversations/v3/conversations/threads/${thread_id}`
)
const body: { [key: string]: any } = {}
body.status = status
const response = await fetch(url, {
method: "PATCH",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(body),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 4 hours ago