# Create Draft Campaign — Sendy

> Creates a new draft campaign ready to be filled in with details. See the documentation

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

## Description

Creates a new draft campaign ready to be filled in with details. [See the documentation](https://sendy.co/api?app_path=https://sendy.email/dev2#create-send-campaigns)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `fromName` | `string` | Yes | The 'From Name' of your campaign. |
| `fromEmail` | `string` | Yes | The 'From Email' of your campaign. |
| `replyTo` | `string` | Yes | The 'Reply To' of your campaign. |
| `title` | `string` | Yes | The 'Title' of your campaign. |
| `subject` | `string` | Yes | The 'Subject' of your campaign. |
| `plainText` | `string` | No | The 'Plain text version' of your campaign. |
| `htmlText` | `string` | Yes | The 'HTML version' of your campaign. |
| `brandId` | `string` | Yes | The ID of the brand. Options are loaded from the connected account. |
| `listIds` | `string[]` | No | A list of List IDs. Options are loaded from the connected account. |
| `segmentIds` | `string[]` | No | A list of segment IDs. Segment ids can be found in the segments setup page. |
| `excludeListIds` | `string[]` | No | Lists to exclude from your campaign. Options are loaded from the connected account. |
| `excludeSegmentIds` | `string[]` | No | Segments to exclude from your campaign. Segment ids can be found in the segments setup page. |
| `queryString` | `string` | No | e.g., Google Analytics tags. |
| `trackOpens` | `string` | Yes | Open tracking behaviour. |
| `trackClicks` | `string` | Yes | Click tracking behaviour. |
| `scheduleDateTime` | `string` | No | Format: June 15, 2021 6:05pm. Minutes in increments of '5', eg. 6pm, 6:05pm, 6:10pm, 6:15pm.. |
| `scheduleTimezone` | `string` | No | e.g., 'America/New_York'. See the list of PHP's supported timezones. This parameter only applies if you're scheduling your campaign with 'Schedule Date Time' parameter. Sendy will use your default timezone if this parameter is empty. |

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

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: "sendy-create-draft-campaign",
  arguments: {
    fromName: "From Name",
    fromEmail: "From Email",
  },
})
```

**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: "sendy-create-draft-campaign",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    sendy: { authProvisionId: "apn_xxxxxxx" },
    fromName: "From Name",
    fromEmail: "From Email",
  },
})

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": "sendy-create-draft-campaign",
    "configured_props": {
      "sendy": { "authProvisionId": "apn_xxxxxxx" },
      "fromName": "From Name",
      "fromEmail": "From Email"
    }
  }'
```

---

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