0

Cancel a Campaign

by
Published Nov 28, 2022

Cancel a Regular or Plain-Text Campaign after you send, before all of your recipients receive it. This feature is included with Mailchimp Pro.

Script mailchimp Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
2

3
type Mailchimp = {
4
  api_key: string;
5
  server: string;
6
};
7
export async function main(auth: Mailchimp, campaign_id: string) {
8
  const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}/actions/cancel-send`;
9
  const response = await fetch(url, {
10
    method: "POST",
11
    headers: {
12
      Authorization: `Bearer ${auth.api_key}`,
13
    },
14
  });
15

16
  if (!response.ok) {
17
    throw Error(await response.text());
18
  }
19
  return await response.json();
20
}
21

Other submissions
  • Submitted by adam186 Deno
    Created 398 days ago
    1
    type Mailchimp = {
    2
      api_key: string;
    3
      server: string;
    4
    };
    5
    export async function main(auth: Mailchimp, campaign_id: string) {
    6
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}/actions/cancel-send`;
    7
      const response = await fetch(url, {
    8
        method: "POST",
    9
        headers: {
    10
          Authorization: `Bearer ${auth.api_key}`,
    11
        },
    12
      });
    13
    
    
    14
      if (!response.ok) {
    15
        throw Error(await response.text());
    16
      }
    17
      return await response.json();
    18
    }
    19