Edits history of script submission #22447 for ' Delete Campaign (mailchimp)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(auth: Mailchimp, campaign_id: string) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`;
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: `Bearer ${auth.api_key}`,
        },
      });
      if (!response.ok) {
        throw Error(await response.text());
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`;
    }
    

    Submitted by hugo989 3 days ago