//native
/**
* Get Thread
* Retrieve one conversation thread. Requires conversations.read.
*/
export async function main(
auth: RT.Hubspot,
thread_id: string,
archived: boolean | undefined
) {
const url = new URL(
`https://api.hubapi.com/conversations/v3/conversations/threads/${thread_id}`
)
if (archived) url.searchParams.append("archived", String(archived))
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 4 hours ago