//native
/**
* List Forms
* List the account's marketing forms. Requires the forms scope.
*/
export async function main(
auth: RT.Hubspot,
limit: number | undefined,
after: string | undefined,
archived: boolean | undefined,
form_types:
| ("hubspot" | "captured" | "flow" | "blog_comment" | "all")[]
| undefined
) {
const url = new URL(`https://api.hubapi.com/marketing/v3/forms`)
if (limit != null) url.searchParams.append("limit", String(limit))
if (after != null && after !== "") url.searchParams.append("after", after)
if (archived) url.searchParams.append("archived", String(archived))
if (form_types?.length)
url.searchParams.append("formTypes", form_types.join(","))
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