# Add or Update Contact — Freshmarketer

> Create a new contact or updates an existing one.

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

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `email` | `string` | Yes | Email on which enttity needs to be created or updated. |
| `firstName` | `string` | No | First name of the contact. |
| `lastName` | `string` | No | Last name of the contact. |
| `subscriptionStatus` | `string` | No | Status of subscription that the contact is in. |
| `jobTitle` | `string` | No | Designation of the contact in the account he belongs to. |
| `workNumber` | `string` | No | Work phone number of the contact. |
| `externalId` | `string` | No | External ID of the contact. |
| `mobileNumber` | `string` | No | Mobile phone number of the contact. |
| `address` | `string` | No | Address of the contact. |
| `city` | `string` | No | City that the contact belongs to. |
| `state` | `string` | No | State that the contact belongs to. |
| `zipcode` | `string` | No | Zipcode of the region that the contact belongs to. |
| `country` | `string` | No | Country that the contact belongs to. |
| `territoryId` | `string` | No | ID of the territory that the contact belongs to. Options are loaded from the connected account. |
| `leadSourceId` | `string` | No | ID of the source where contact came from. Options are loaded from the connected account. |
| `ownerId` | `string` | No | ID of the user to whom the contact has been assigned. Options are loaded from the connected account. |

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

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: "freshmarketer-add-update-contact",
  arguments: {
    email: "Contact Email",
    firstName: "First Name",
  },
})
```

**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: "freshmarketer-add-update-contact",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    freshmarketer: { authProvisionId: "apn_xxxxxxx" },
    email: "Contact Email",
    firstName: "First Name",
  },
})

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": "freshmarketer-add-update-contact",
    "configured_props": {
      "freshmarketer": { "authProvisionId": "apn_xxxxxxx" },
      "email": "Contact Email",
      "firstName": "First Name"
    }
  }'
```

---

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