# Create Campaign — Mailchimp

> Creates a new campaign draft. See docs here

- Key: `mailchimp-create-campaign`
- Type: Action (Write)
- Version: 0.2.4
- App: Mailchimp (`mailchimp`) — https://pipedream.com/apps/mailchimp.md
- This page (HTML): https://pipedream.com/apps/mailchimp/actions/create-campaign
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/mailchimp/actions/create-campaign/create-campaign.mjs

## Description

Creates a new campaign draft. [See docs here](https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `type` | `string` | Yes | There are four types of campaigns you can create in Mailchimp. A/B Split campaigns have been deprecated and variate campaigns should be used instead. |
| `listId` | `string` | Yes | The unique ID of the list Options are loaded from the connected account. |
| `savedSegmentId` | `integer` | No | The ID for an existing saved segment. |
| `prebuiltSegmentId` | `string` | No | The prebuilt segment ID, if a prebuilt segment has been designated for this campaign. |
| `segmentMatch` | `string` | No | Segment match type. |
| `segmentConditions` | `any` | No | Segment match conditions. |
| `subjectLine` | `string` | No | The subject line for the campaign. |
| `previewText` | `string` | No | The preview text for the campaign. |
| `title` | `string` | No | The title of the campaign. |
| `fromName` | `string` | No | The 'from' name on the campaign (not an email address). |
| `replyTo` | `string` | No | The reply-to email address for the campaign. Note: while this field is not required for campaign creation, it is required for sending. |
| `useConversation` | `boolean` | No | Use Mailchimp Conversation feature to manage out-of-office replies. |
| `toName` | `string` | No | The campaign's custom to name. |
| `folderId` | `string` | No | If the campaign is listed in a folder, the ID for that folder. |
| `authenticate` | `boolean` | No | Whether Mailchimp authenticated the campaign. Defaults to true. |
| `autoFooter` | `boolean` | No | Automatically append Mailchimp's default footer to the campaign. |
| `inlineCss` | `boolean` | No | Automatically inline the CSS included with the campaign content. |
| `autoTweet` | `boolean` | No | Automatically tweet a link to the campaign archive page when the campaign is sent. |
| `autoFbPost` | `any` | No | An array of Facebook page ID to auto-post to. |
| `fbComments` | `boolean` | No | Allows Facebook comments on the campaign (also force-enables the Campaign Archive toolbar). Defaults to true. |
| `templateId` | `integer` | No | The ID of the template to use. |
| `opens` | `boolean` | No | Whether to track opens. Defaults to true. Cannot be set to false for variate campaigns. |
| `htmlClicks` | `boolean` | No | Whether to track clicks in the HTML version of the campaign. Defaults to true. Cannot be set to false for variate campaigns. |
| `textClicks` | `boolean` | No | Whether to track clicks in the plain-text version of the campaign. Defaults to true. Cannot be set to false for variate campaigns. |
| `goalTracking` | `boolean` | No | Whether to enable Goal tracking. |
| `ecomm360` | `boolean` | No | Whether to enable eCommerce360 tracking. |
| `googleAnalytics` | `string` | No | The custom slug for Google Analytics tracking (max of 50 bytes). |
| `clicktale` | `string` | No | The custom slug for ClickTale tracking (max of 50 bytes). |
| `salesforceCampaign` | `boolean` | No | Create a campaign in a connected Salesforce account. |
| `salesforceNotes` | `boolean` | No | Update contact notes for a campaign based on subscriber email addresses. |
| `capsuleNotes` | `boolean` | No | Update contact notes for a campaign based on subscriber email addresses. Must be using Mailchimp's built-in Capsule integration. |
| `socialImageUrl` | `string` | No | The url for the header image for the preview card. |
| `socialDescritpion` | `string` | No | A short summary of the campaign to display. |
| `socialTitle` | `string` | No | The title for the preview card. Typically the subject line of the campaign. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "mailchimp",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "mailchimp-create-campaign",
  arguments: {
    type: "Type",
    listId: "List Id",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "mailchimp-create-campaign",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    mailchimp: { authProvisionId: "apn_xxxxxxx" },
    type: "Type",
    listId: "List Id",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "mailchimp-create-campaign",
    "configured_props": {
      "mailchimp": { "authProvisionId": "apn_xxxxxxx" },
      "type": "Type",
      "listId": "List Id"
    }
  }'
```

---

- App: https://pipedream.com/apps/mailchimp.md · All apps: https://pipedream.com/apps
