# Create New Lead — Mailbluster

> Create a new lead. See the documentation

- Key: `mailbluster-create-lead`
- Type: Action (Write)
- Version: 0.0.3
- App: Mailbluster (`mailbluster`) — https://pipedream.com/apps/mailbluster.md
- This page (HTML): https://pipedream.com/apps/mailbluster/actions/create-lead
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/mailbluster/actions/create-lead/create-lead.ts

## Description

Create a new lead. [See the documentation](https://app.mailbluster.com/api-doc/leads)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `email` | `string` | Yes | Email address of the lead. |
| `subscribed` | `boolean` | Yes | Lead is subscribed to receive email or not. |
| `firstName` | `string` | No | First name of the lead. |
| `lastName` | `string` | No | Last name of the lead. |
| `fields` | `object` | No | An object containing field information of the lead. Field merge tag is the key and field value is the value. |
| `timezone` | `string` | No | Timezone of the lead. View supported timezones from here. |
| `ipAddress` | `string` | No | IP address of the lead. IP address is used to find country, city, latitude, longitude, timezone (if no timezone is given) etc of this lead & store them as meta. |
| `doubleOptIn` | `boolean` | No | If true, the lead will receive the opt-in confirmation email. |
| `tags` | `string[]` | No | Tag(s) name of the lead. For each tag, if tag already exists, it will be only attached to the lead. Otherwise, it will be created first and then get attached. |
| `overrideExisting` | `boolean` | No | If lead exists, should it get overridden? Before creating a lead, we will try to find whether the lead already exists in the system using the provided email. This param controls if lead is found, we should override the lead info or throw an error message. |

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

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: "mailbluster-create-lead",
  arguments: {
    email: "Email",
    subscribed: true,
  },
})
```

**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: "mailbluster-create-lead",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    mailbluster: { authProvisionId: "apn_xxxxxxx" },
    email: "Email",
    subscribed: true,
  },
})

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": "mailbluster-create-lead",
    "configured_props": {
      "mailbluster": { "authProvisionId": "apn_xxxxxxx" },
      "email": "Email",
      "subscribed": true
    }
  }'
```

---

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