# Create Or Update Subscriber — Drip

> Creates a new subscriber. If the email already exists, it will update the existing subscriber. See the docs here

- Key: `drip-create-or-update-subscriber`
- Type: Action (Write)
- Version: 0.0.4
- App: Drip (`drip`) — https://pipedream.com/apps/drip.md
- This page (HTML): https://pipedream.com/apps/drip/actions/create-or-update-subscriber
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/drip/actions/create-or-update-subscriber/create-or-update-subscriber.mjs

## Description

Creates a new subscriber. If the email already exists, it will update the existing subscriber. [See the docs here](https://developer.drip.com/?javascript#create-or-update-a-subscriber)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `email` | `string` | No | The subscriber's email address. Options are loaded from the connected account. |
| `visitorUuid` | `string` | No | The uuid for a subscriber's visitor record. Either email or visitor_uuid must be included. |
| `newEmail` | `string` | No | A new email address for the subscriber. If provided and a subscriber with the email above does not exist, this address will be used to create a new subscriber. |
| `firstName` | `string` | No | The subscriber's first name. |
| `lastName` | `string` | No | The subscriber's last name. |
| `address1` | `string` | No | The subscriber's mailing address. |
| `address2` | `string` | No | An additional field for the subscriber's mailing address. |
| `city` | `string` | No | The city, town, or village in which the subscriber resides. |
| `state` | `string` | No | The region in which the subscriber resides. Typically a province, a state, or a prefecture. |
| `zip` | `string` | No | The postal code in which the subscriber resides, also known as zip, postcode, Eircode, etc. |
| `country` | `string` | No | The country in which the subscriber resides. |
| `phone` | `string` | No | The subscriber's primary phone number. |
| `smsNumber` | `string` | No | The subscriber's mobile phone number in E.164 formatting. E.g. "+16125551212". Only US-based numbers are supported at this time. |
| `smsConsent` | `boolean` | No | true if the person has granted consent to receive marketing and other communication via SMS; false otherwise. Default: false. If you're unsure whether or not you have gained legal SMS consent, check out our TCPA requirements article. |
| `userId` | `string` | No | A unique identifier for the user in your database, such as a primary key. |
| `timezone` | `string` | No | The subscriber's time zone (in Olson format). Defaults to Etc/UTC |
| `lifetimeValue` | `string` | No | The lifetime value of the subscriber (in cents). |
| `ipAddress` | `string` | No | The subscriber's ip address E.g. "111.111.111.11" |
| `customFields` | `object` | No | An Object containing custom field data. E.g. { "shirt_size": "Medium" } |
| `tags` | `string[]` | No | An Array containing one or more tags. E.g. ["Customer", "SEO"]. |
| `removeTags` | `string[]` | No | An Array containing one or more tags to be removed from the subscriber. E.g. ["Customer", "SEO"]. |
| `prospect` | `boolean` | No | A Boolean specifiying whether we should attach a lead score to the subscriber (when lead scoring is enabled). Defaults to true. Note: This flag used to be called potential_lead, which we will continue to accept for backwards compatibility. |
| `baseLeadScore` | `integer` | No | An Integer specifying the starting value for lead score calculation for this subscriber. Defaults to 30. |
| `euConsent` | `string` | No | A String specifying whether the subscriber granted or denied GDPR consent. |
| `euConsentMessage` | `string` | No | A String containing the message the subscriber granted or denied their consent to. |
| `status` | `string` | No | A String specifying the subscriber's status: either active or unsubscribed. |
| `initialStatus` | `string` | No | A String specifying the subscriber's known status: either active or unsubscribed. To be used if subscriber's status is unchanged. |

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

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: "drip-create-or-update-subscriber",
  arguments: {
    email: "Email",
    visitorUuid: "Visitor UUID",
  },
})
```

**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: "drip-create-or-update-subscriber",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    drip: { authProvisionId: "apn_xxxxxxx" },
    email: "Email",
    visitorUuid: "Visitor UUID",
  },
})

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": "drip-create-or-update-subscriber",
    "configured_props": {
      "drip": { "authProvisionId": "apn_xxxxxxx" },
      "email": "Email",
      "visitorUuid": "Visitor UUID"
    }
  }'
```

---

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