//native
/**
* Get Subscription Preferences
* Retrieve the email subscription statuses of a contact, by email address. Requires communication_preferences.read_write.
*/
export async function main(auth: RT.Hubspot, email: string) {
const url = new URL(
`https://api.hubapi.com/communication-preferences/v4/statuses/${encodeURIComponent(email)}`
)
url.searchParams.append("channel", "EMAIL")
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