# Create Customer — ChartMogul

> Creates a customer object in ChartMogul under the specified data_source See the docs here

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

## Description

Creates a `customer` object in ChartMogul under the specified `data_source` [See the docs here](https://dev.chartmogul.com/reference/create-customer)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `dataSourceId` | `string` | Yes | The ChartMogul UUID of the data source that this customer comes from. Options are loaded from the connected account. |
| `externalId` | `string` | Yes | A unique identifier specified by you for the customer. Typically an identifier from your internal system. Accepts alphanumeric characters. |
| `name` | `string` | Yes | Name of the customer for display purposes. Accepts alphanumeric characters. |
| `email` | `string` | No | Email address of the customer. |
| `company` | `string` | No | The customer's company or organisation. |
| `country` | `string` | No | Country code of customer's location as per ISO-3166 alpha-2 standard. |
| `state` | `string` | No | State code of customer's location as per ISO-3166 alpha-2 standard. |
| `city` | `string` | No | City of the customer's location. |
| `zip` | `string` | No | Zip code of the customer's location. |
| `leadCreatedAt` | `string` | No | Time at which this customer was established as a lead. Must be an ISO 8601 formatted time in the past. The timezone defaults to UTC unless otherwise specified. |
| `freeTrialStartedAt` | `string` | No | Time at which this customer started a free trial of your product or service. Must be an ISO 8601 formatted time in the past. The timezone defaults to UTC unless otherwise specified. This is expected to be the same as, or after the lead_created_at value. |
| `tags` | `string[]` | No | An Array of tags to be added to the customer. |
| `custom` | `string[]` | No | An Array containing the custom attributes to be added to the customer. If sending custom attributes, each custom attribute must be an object and have a type, key, and value. E.g. {"type":"String","key": "key1","value": "value1"} |
| `source` | `string` | No | Optional parameter for UI use. Can be updated, doesn't show in response. |

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

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: "chartmogul-create-customer",
  arguments: {
    dataSourceId: "Data Source UUID",
    externalId: "External 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: "chartmogul-create-customer",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    chartmogul: { authProvisionId: "apn_xxxxxxx" },
    dataSourceId: "Data Source UUID",
    externalId: "External 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": "chartmogul-create-customer",
    "configured_props": {
      "chartmogul": { "authProvisionId": "apn_xxxxxxx" },
      "dataSourceId": "Data Source UUID",
      "externalId": "External ID"
    }
  }'
```

---

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