//native
/**
* List Owners
* List the account's owners (users that can be assigned to records), optionally filtered by email.
*/
export async function main(
auth: RT.Hubspot,
email: string | undefined,
limit: number | undefined,
after: string | undefined,
archived: boolean | undefined
) {
const url = new URL(`https://api.hubapi.com/crm/v3/owners`)
if (email != null && email !== "") url.searchParams.append("email", email)
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))
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