# Create Marketing Email — HubSpot

> Create a marketing email in Hubspot. See the documentation

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

## Description

Create a marketing email in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/emails/marketing-emails#post-%2Fmarketing%2Fv3%2Femails%2F)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | The name of the email |
| `campaign` | `string` | No | The ID of the campaign to create the email in. Options are loaded from the connected account. |
| `customReplyTo` | `string` | No | The custom reply to address for the email |
| `fromName` | `string` | No | The name of the sender |
| `replyTo` | `string` | No | The reply to address for the email |
| `limitSendFrequency` | `boolean` | No | Whether to limit the send frequency for the email |
| `suppressGraymail` | `boolean` | No | Whether to suppress graymail for the email |
| `includeContactLists` | `string[]` | No | The contact lists to include Options are loaded from the connected account. |
| `excludeContactLists` | `string[]` | No | The contact lists to exclude Options are loaded from the connected account. |
| `feedbackSurveyId` | `string` | No | Hubspot's internal ID for the feedback survey. From the Hubspot UI, go to Service -> Feedback Surveys and the ID will be in the URL. |
| `rssData` | `object` | No | An object with the RSS data for the email. See the documentation for more information. |
| `subject` | `string` | No | The subject of the email |
| `testing` | `object` | No | An object with the testing data for the email. See the documentation for more information. |
| `language` | `string` | No | The language of the email |
| `content` | `object` | No | An object with the content data for the email. See the documentation for more information. |
| `webversion` | `object` | No | An object with the webversion data for the email. See the documentation for more information. |
| `subscriptionDetails` | `object` | No | An object with the subscription details for the email. See the documentation for more information. |
| `sendOnPublish` | `boolean` | No | Whether to send the email on publish |

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

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: "hubspot-create-email",
  arguments: {
    name: "Name",
    campaign: "Campaign 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: "hubspot-create-email",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    hubspot: { authProvisionId: "apn_xxxxxxx" },
    name: "Name",
    campaign: "Campaign 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": "hubspot-create-email",
    "configured_props": {
      "hubspot": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Name",
      "campaign": "Campaign ID"
    }
  }'
```

---

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