//native
type Buttondown = {
token: string;
};
/**
* Send Draft
*
*/
export async function main(
auth: Buttondown,
id: string,
body: { subscribers?: string[]; recipients?: string[] },
) {
const url = new URL(`https://api.buttondown.com/v1/emails/${id}/send-draft`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Token " + auth.token,
},
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