//native
type Brevo = {
apiKey: string;
};
/**
* Enable/disable sub-account application(s)
* API endpoints for the Corporate owner to enable/disable applications on the sub-account
*/
export async function main(
auth: Brevo,
id: string,
body: {
inbox?: false | true;
whatsapp?: false | true;
automation?: false | true;
"email-campaigns"?: false | true;
"sms-campaigns"?: false | true;
"landing-pages"?: false | true;
"transactional-emails"?: false | true;
"transactional-sms"?: false | true;
"facebook-ads"?: false | true;
"web-push"?: false | true;
meetings?: false | true;
conversations?: false | true;
crm?: false | true;
},
) {
const url = new URL(
`https://api.brevo.com/v3/corporate/subAccount/${id}/applications/toggle`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
"api-key": auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago