create_campaign
Create and configure new email campaigns in Mailchimp by specifying audience, subject line, sender details, and campaign type for marketing automation.
Instructions
Create a new Mailchimp email campaign. Returns the campaign ID for use with set_campaign_content and send_campaign.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | Audience/list ID (get from list_audiences) | |
| subject_line | Yes | Email subject line | |
| from_name | Yes | Sender name shown to recipients | |
| reply_to | Yes | Reply-to email address | |
| type | No | Campaign type (default: regular) | |
| preview_text | No | Preview text shown in inbox | |
| title | No | Internal campaign title (for your reference) | |
| segment_id | No | Segment ID to send to a subset of the audience |
Implementation Reference
- server.js:106-156 (handler)The implementation of the 'create_campaign' tool, which uses the Mailchimp API to create a campaign and returns its ID.
server.tool( "create_campaign", "Create a new Mailchimp email campaign. Returns the campaign ID for use with set_campaign_content and send_campaign.", { list_id: z.string().describe("Audience/list ID (get from list_audiences)"), subject_line: z.string().describe("Email subject line"), from_name: z.string().describe("Sender name shown to recipients"), reply_to: z.string().describe("Reply-to email address"), type: z.enum(["regular", "plaintext", "absplit", "rss"]).optional().describe("Campaign type (default: regular)"), preview_text: z.string().optional().describe("Preview text shown in inbox"), title: z.string().optional().describe("Internal campaign title (for your reference)"), segment_id: z.number().optional().describe("Segment ID to send to a subset of the audience"), }, async ({ list_id, subject_line, from_name, reply_to, type, preview_text, title, segment_id }) => { const body = { type: type || "regular", recipients: { list_id }, settings: { subject_line, from_name, reply_to, preview_text: preview_text || "", title: title || subject_line, }, }; if (segment_id) { body.recipients.segment_opts = { saved_segment_id: segment_id }; } const response = await mailchimp.campaigns.create(body); return { content: [ { type: "text", text: JSON.stringify( { id: response.id, status: response.status, web_id: response.web_id, subject_line: response.settings?.subject_line, title: response.settings?.title, list_id: response.recipients?.list_id, archive_url: response.archive_url, }, null, 2 ), }, ], }; } );