//native
/**
* List Workflow Emails
* List the marketing emails sent by a workflow, by its v4 flow ID (see Get Migrated Workflow Mappings to convert a legacy workflow ID). Requires the automation scope and a Professional or Enterprise subscription.
*/
export async function main(
auth: RT.Hubspot,
flow_id: string,
limit: number | undefined,
after: string | undefined,
before: string | undefined
) {
const url = new URL(
`https://api.hubapi.com/automation/v4/flows/email-campaigns`
)
url.searchParams.append("flowId", flow_id)
if (limit != null) url.searchParams.append("limit", String(limit))
if (after != null && after !== "") url.searchParams.append("after", after)
if (before != null && before !== "") url.searchParams.append("before", before)
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