# Create Campaign — Elastic Email

> Create a campaign in an Elastic Email account. See the documentation

- Key: `elastic_email-create-campaign`
- Type: Action (Write)
- Version: 0.0.1
- App: Elastic Email (`elastic_email`) — https://pipedream.com/apps/elastic-email.md
- This page (HTML): https://pipedream.com/apps/elastic-email/actions/create-campaign
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/elastic_email/actions/create-campaign/create-campaign.mjs

## Description

Create a campaign in an Elastic Email account. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/campaignsPost)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | The name of the campaign |
| `from` | `string` | Yes | Your e-mail with an optional name (e.g.: email@domain.com or John Doe <email@domain.com>) |
| `recipientListNames` | `string[]` | No | Names of lists from your Account to read recipients from Options are loaded from the connected account. |
| `recipientSegmentNames` | `string[]` | No | Names of segments from your Account to read recipients from Options are loaded from the connected account. |
| `replyTo` | `string` | Yes | To what address should the recipients reply to (e.g. email@domain.com or John Doe <email@domain.com>) |
| `status` | `string` | Yes | The status of a campaign |
| `subject` | `string` | No | Default subject of email |
| `templateName` | `string` | No | The name of template Options are loaded from the connected account. |
| `excludeRecipientListNames` | `string[]` | No | Names of lists from your Account to exclude from the campaign Options are loaded from the connected account. |
| `excludeRecipientSegmentNames` | `string[]` | No | Names of segments from your Account to exclude from the campaign Options are loaded from the connected account. |

## 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": "elastic_email",
      },
    },
  },
)

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: "elastic_email-create-campaign",
  arguments: {
    name: "Campaign Name",
    from: "From",
  },
})
```

**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: "elastic_email-create-campaign",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    elastic_email: { authProvisionId: "apn_xxxxxxx" },
    name: "Campaign Name",
    from: "From",
  },
})

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": "elastic_email-create-campaign",
    "configured_props": {
      "elastic_email": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Campaign Name",
      "from": "From"
    }
  }'
```

---

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