0

List Inboxes

by
Published today

List the conversations inboxes of the account.

Script hubspot Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours ago
1
//native
2

3
/**
4
 * List Inboxes
5
 * List the conversations inboxes of the account. Requires conversations.read.
6
 */
7
export async function main(
8
  auth: RT.Hubspot,
9
  limit: number | undefined,
10
  after: string | undefined,
11
  archived: boolean | undefined
12
) {
13
  const url = new URL(
14
    `https://api.hubapi.com/conversations/v3/conversations/inboxes`
15
  )
16
  if (limit != null) url.searchParams.append("limit", String(limit))
17
  if (after != null && after !== "") url.searchParams.append("after", after)
18
  if (archived) url.searchParams.append("archived", String(archived))
19

20
  const response = await fetch(url, {
21
    headers: {
22
      Authorization: `Bearer ${auth.token}`,
23
      Accept: "application/json",
24
    },
25
  })
26

27
  if (!response.ok) {
28
    throw new Error(`${response.status} ${await response.text()}`)
29
  }
30

31
  return await response.json()
32
}
33