# Update or Create Contact — ClickFunnels

> Searches for a contact by email and updates it, or creates a new one if not found. See the documentation

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

## Description

Searches for a contact by email and updates it, or creates a new one if not found. [See the documentation](https://developers.myclickfunnels.com/reference/upsertcontact)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `teamId` | `string` | Yes | The unique identification of the team. Options are loaded from the connected account. |
| `workspaceId` | `string` | Yes | The unique identification of the workspace. Options are loaded from the connected account. |
| `email` | `string` | Yes | The email address of the contact |
| `firstName` | `string` | No | The contact's first name. |
| `lastName` | `string` | No | The contact's last name. |
| `phoneNumber` | `string` | No | The contact's phone number. |
| `timeZone` | `string` | No | The contact's time zone. |
| `fbUrl` | `string` | No | The contact's Facebook URL. |
| `twitterUrl` | `string` | No | The contact's twitter URL. |
| `instagramUrl` | `string` | No | The contact's instagram URL. |
| `linkedinUrl` | `string` | No | The contact's linkedin URL. |
| `websiteUrl` | `string` | No | The contact's website URL. |
| `tagIds` | `string[]` | No | An empty array is ignored here. If you wish to remove all tags for a Contact, use the Update Contact endpoint. A non-empty array overwrites the existing array. Options are loaded from the connected account. |
| `customAttributes` | `object` | No | Custom attributes are usually added in ClickFunnels to a contact when they submit forms that contain custom contact attributes. Here you can directly create them during contact modification. Custom attributes are provided as key-value pairs: A key that does not exist, will create a new custom contact attribute. A key that already exists, will update the value of an existing custom contact attribute. Empty or null values, will set the custom attribute values to empty strings. A key that has special characters or spaces will be automatically converted to snake_case (For example, 'Favorite Food! 🥑' will be converted to 'favorite_food'). Empty keys will trigger a bad request response. Also, non-object inputs for custom_attributes(e.g. an array or string), it will be ignored. Keys that are default properties on the Contact resource or variations of it will result in an error. E.g., 'first_name', 'First Name', etc. are not valid inputs. |

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

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: "clickfunnels-update-create-contact",
  arguments: {
    teamId: "Team Id",
    workspaceId: "Workspace 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: "clickfunnels-update-create-contact",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    clickfunnels: { authProvisionId: "apn_xxxxxxx" },
    teamId: "Team Id",
    workspaceId: "Workspace 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": "clickfunnels-update-create-contact",
    "configured_props": {
      "clickfunnels": { "authProvisionId": "apn_xxxxxxx" },
      "teamId": "Team Id",
      "workspaceId": "Workspace Id"
    }
  }'
```

---

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