# Save Contact — Microsoft Outlook Email

> Create or update an Outlook contact (upsert). Omit contactId to create a new contact; provide contactId to update an existing one. Use Find Contacts first to look up a contact's id before updating. Example (create)…

- Key: `microsoft_outlook-save-contact`
- Type: Action (Write)
- Version: 0.0.6
- App: Microsoft Outlook Email (`microsoft_outlook`) — https://pipedream.com/apps/microsoft-outlook.md
- This page (HTML): https://pipedream.com/apps/microsoft-outlook/actions/save-contact
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/microsoft_outlook/actions/save-contact/save-contact.mjs

## Description

Create or update an Outlook contact (upsert). Omit `contactId` to create a new contact; provide `contactId` to update an existing one. Use **Find Contacts** first to look up a contact's `id` before updating. Example (create): `save-contact(givenName="Cosmo", surname="Kramer", emailAddresses=["kramer@kramerica.com"])` → creates contact, returns new contact object with `id`. Example (update): `save-contact(contactId="AQMk...", businessPhones=["+1-555-0100"])` → patches the existing contact. [See the create documentation](https://docs.microsoft.com/en-us/graph/api/user-post-contacts) [See the update documentation](https://docs.microsoft.com/en-us/graph/api/contact-update)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `contactId` | `string` | No | The Microsoft Graph contact ID. Provide to update an existing contact; omit to create a new one. Obtain from Find Contacts (id field). |
| `givenName` | `string` | No | Given name of the contact |
| `surname` | `string` | No | Surname of the contact |
| `emailAddresses` | `string[]` | No | Array of email address strings, e.g. ["kramer@kramerica.com"]. |
| `businessPhones` | `string[]` | No | Array of phone number strings, e.g. ["+1-555-0100"]. |

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

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: "microsoft_outlook-save-contact",
  arguments: {
    contactId: "Contact ID",
    givenName: "Given 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: "microsoft_outlook-save-contact",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    microsoft_outlook: { authProvisionId: "apn_xxxxxxx" },
    contactId: "Contact ID",
    givenName: "Given 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": "microsoft_outlook-save-contact",
    "configured_props": {
      "microsoft_outlook": { "authProvisionId": "apn_xxxxxxx" },
      "contactId": "Contact ID",
      "givenName": "Given name"
    }
  }'
```

---

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