# Create Or Update Contact — Constant Contact

> Create a new contact or update an existing one based on their email address. This method is appropriate when a contact has given explicit permission to receive emails. See the documentation

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

## Description

Create a new contact or update an existing one based on their email address. This method is appropriate when a contact has given explicit permission to receive emails. [See the documentation](https://developer.constantcontact.com/api_reference/index.html#tag/Contacts/operation/createOrUpdateContact)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `emailAddress` | `string` | Yes | The email address for the contact. This method identifies each unique contact using their email address. If the email address exists in the account, this method updates the contact. If the email address is new, this method creates a new contact |
| `firstName` | `string` | No | The first name of the contact. |
| `lastName` | `string` | No | The last name of the contact. |
| `jobTitle` | `string` | No | The job title of the contact. |
| `companyName` | `string` | No | The name of the company where the contact works |
| `phoneNumber` | `string` | No | The phone number of the contact |
| `listMemberships` | `string[]` | Yes | Array of lists to which the contact is being subscribed, up to a maximum of 50. At least one list is required Options are loaded from the connected account. |
| `customFields` | `string[]` | No | The custom fields you want to add to the contact as an array of up to 50 custom field objects |
| `anniversary` | `string` | No | The anniversary date for the contact. For example, this value could be the date when the contact first became a customer of an organization in Constant Contact. Valid date formats are MM/DD/YYYY, M/D/YYYY, YYYY/MM/DD, YYYY/M/D, YYYY-MM-DD, YYYY-M-D,M-D-YYYY, or M-DD-YYYY |
| `addressType` | `string` | No | The type of street address for the contact |
| `addressStreet` | `string` | No | The number and street of the contact's address |
| `addressCity` | `string` | No | The name of the city for the contact's address |
| `addressState` | `string` | No | The name of the state or province for the contact's address |
| `addressPostalCode` | `string` | No | The zip or postal code for the contact's address |
| `addressCountry` | `string` | No | The name of the country for the contact's address |
| `smsAddress` | `string` | No | The contact's SMS-capable phone number, excluding the country code |
| `dialCode` | `string` | No | The dial code the country uses. For example, use 1 for the United States dial code |
| `countryCode` | `string` | No | The two-digit code that identifies the country |
| `smsChannelConsents` | `string[]` | No | An array of up to 50 objects that describe the contact's SMS channel consents. See the documentation for more information |

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

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: "constant_contact-create-or-update-contact",
  arguments: {
    emailAddress: "Email Address",
    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: "constant_contact-create-or-update-contact",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    constant_contact: { authProvisionId: "apn_xxxxxxx" },
    emailAddress: "Email Address",
    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": "constant_contact-create-or-update-contact",
    "configured_props": {
      "constant_contact": { "authProvisionId": "apn_xxxxxxx" },
      "emailAddress": "Email Address",
      "firstName": "First Name"
    }
  }'
```

---

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