# Create or Update Contact in Segmento — MSG91

> Add or update contact information in Segmento (MSG91's contact management system). See the documentation

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

## Description

Add or update contact information in Segmento (MSG91's contact management system). [See the documentation](https://docs.msg91.com/segmento/createupdate-contact)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `phonebook` | `string` | Yes | The ID of the phonebook where the contact will be added or updated |
| `fields` | `boolean` | Yes | If fields is true or not set, dynamic fields are created; if false, they aren't |
| `input` | `string` | Yes | An object containing contact details. Example: { "name": "Name", "email": "email address", "contact_id": "if exists update or create", "new_field": "field_type created based on value ", "date_field": "YYYY-MM-DD HH:MM:SS format", "details": { "qualification": "graduate", "age": 30, "address": "random address" } } |

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

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: "msg91-create-or-update-contact",
  arguments: {
    phonebook: "Phonebook",
    fields: true,
  },
})
```

**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: "msg91-create-or-update-contact",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    msg91: { authProvisionId: "apn_xxxxxxx" },
    phonebook: "Phonebook",
    fields: true,
  },
})

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": "msg91-create-or-update-contact",
    "configured_props": {
      "msg91": { "authProvisionId": "apn_xxxxxxx" },
      "phonebook": "Phonebook",
      "fields": true
    }
  }'
```

---

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