# Create Campaign — listmonk

> Creates a new campaign in Listmonk. See the documentation

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

## Description

Creates a new campaign in Listmonk. [See the documentation](https://listmonk.app/docs/apis/campaigns/#post-apicampaigns)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | The name of the campaign to create. |
| `subject` | `string` | Yes | The subject of the campaign. |
| `listIds` | `string[]` | Yes | Array of list IDs to subscribe to (marked as unconfirmed by default). Options are loaded from the connected account. |
| `type` | `string` | Yes | The type of the campaign. |
| `contentType` | `string` | Yes | The content type of the campaign. |
| `body` | `string` | Yes | The body of the campaign. |
| `fromEmail` | `string` | No | From e-mail to show on the campaign e-mails. If left empty, the default value from settings is used. |
| `tags` | `string[]` | No | Array of string tags to mark the campaign. |
| `sendAt` | `string` | No | A timestamp to schedule the campaign at. Eg: 2021-12-25T06:00:00 (YYYY-MM-DDTHH:MM:SS) |
| `templateId` | `string` | No | ID of the template to use. If left empty, the default template is used. 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": "listmonk",
      },
    },
  },
)

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: "listmonk-create-campaign",
  arguments: {
    name: "Campaign Name",
    subject: "Subject",
  },
})
```

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

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": "listmonk-create-campaign",
    "configured_props": {
      "listmonk": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Campaign Name",
      "subject": "Subject"
    }
  }'
```

---

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