//native
/**
* List Channel Accounts
* List channel accounts (a connected mailbox, a chatflow, ...), optionally for one channel or inbox. Their IDs are what Send Message expects as `channel_account_id`. Requires conversations.read.
*/
export async function main(
auth: RT.Hubspot,
channel_id: string | undefined,
inbox_id: string | undefined,
limit: number | undefined,
after: string | undefined
) {
const url = new URL(
`https://api.hubapi.com/conversations/v3/conversations/channel-accounts`
)
if (channel_id != null && channel_id !== "")
url.searchParams.append("channelId", channel_id)
if (inbox_id != null && inbox_id !== "")
url.searchParams.append("inboxId", inbox_id)
if (limit != null) url.searchParams.append("limit", String(limit))
if (after != null && after !== "") url.searchParams.append("after", after)
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 5 hours ago