# Create or Update Customer — Ascora

> Creates or updates a customer in the Ascora system. See the documentation

- Key: `ascora-create-or-update-customer`
- Type: Action (Write)
- Version: 0.0.1
- App: Ascora (`ascora`) — https://pipedream.com/apps/ascora.md
- This page (HTML): https://pipedream.com/apps/ascora/actions/create-or-update-customer
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/ascora/actions/create-or-update-customer/create-or-update-customer.mjs

## Description

Creates or updates a customer in the Ascora system. [See the documentation](https://www.ascora.com.au/Assets/Guides/AscoraApiGuide.pdf)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `customerId` | `string` | No | If provided, the customer will be updated. If not provided, a new customer will be created. Options are loaded from the connected account. |
| `customerNumber` | `string` | No | The customer number of the customer |
| `companyName` | `string` | No | The company name of the customer |
| `contactFirstName` | `string` | No | The first name of the contact of the customer |
| `contactLastName` | `string` | No | The last name of the contact of the customer |
| `emailAddress` | `string` | No | The email address of the customer |
| `phoneNumber` | `string` | No | The phone number of the customer |
| `streetLine1` | `string` | No | The first line of the street of the customer |
| `streetLine2` | `string` | No | The second line of the street of the customer |
| `streetSuburb` | `string` | No | The suburb of the customer |
| `streetPostcode` | `string` | No | The postcode of the customer |
| `streetState` | `string` | No | The state of the customer |
| `streetCountry` | `string` | No | The country of the customer |
| `customerType` | `string` | No | The type of the customer |
| `leadSource` | `string` | No | The source of the lead |
| `customFields` | `string[]` | No | Custom fields of the customer Example: [ { "fieldName": "Customer text", "fieldValue": "free text value test update" } ] |

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

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: "ascora-create-or-update-customer",
  arguments: {
    customerId: "Customer ID",
    customerNumber: "Customer Number",
  },
})
```

**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: "ascora-create-or-update-customer",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    ascora: { authProvisionId: "apn_xxxxxxx" },
    customerId: "Customer ID",
    customerNumber: "Customer Number",
  },
})

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": "ascora-create-or-update-customer",
    "configured_props": {
      "ascora": { "authProvisionId": "apn_xxxxxxx" },
      "customerId": "Customer ID",
      "customerNumber": "Customer Number"
    }
  }'
```

---

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