0

List Marketing Events

by
Published today

List marketing events (webinars, conferences, ...) created in or synced to the account.

Script hubspot Verified

The script

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

3
/**
4
 * List Marketing Events
5
 * List marketing events (webinars, conferences, ...) created in or synced to the account. Requires crm.objects.marketing_events.read.
6
 */
7
export async function main(
8
  auth: RT.Hubspot,
9
  limit: number | undefined,
10
  after: string | undefined
11
) {
12
  const url = new URL(`https://api.hubapi.com/marketing/v3/marketing-events/`)
13
  if (limit != null) url.searchParams.append("limit", String(limit))
14
  if (after != null && after !== "") url.searchParams.append("after", after)
15

16
  const response = await fetch(url, {
17
    headers: {
18
      Authorization: `Bearer ${auth.token}`,
19
      Accept: "application/json",
20
    },
21
  })
22

23
  if (!response.ok) {
24
    throw new Error(`${response.status} ${await response.text()}`)
25
  }
26

27
  return await response.json()
28
}
29