# Create or Update Contact — Xero Accounting

> Creates a new contact or updates if the contact exists.

- Key: `xero_accounting_api-xero-accounting-create-or-update-contact`
- Type: Action (Write)
- Version: 0.1.5
- App: Xero Accounting (`xero_accounting_api`) — https://pipedream.com/apps/xero-accounting-api.md
- This page (HTML): https://pipedream.com/apps/xero-accounting-api/actions/xero-accounting-create-or-update-contact
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/xero_accounting_api/actions/xero-accounting-create-or-update-contact/xero-accounting-create-or-update-contact.mjs

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `tenantId` | `string` | Yes | Select an organization tenant to use, or provide a tenant ID Options are loaded from the connected account. |
| `name` | `string` | No | Full name of contact/organisation (max length = 255). The following is required to create a contact. |
| `contactId` | `string` | No | Unique identification of the contact Options are loaded from the connected account. |
| `contactNumber` | `string` | No | This can be updated via the API only i.e. This field is read only on the Xero contact screen, used to identify contacts in external systems (max length = 50). If the Contact Number is used, this is displayed as Contact Code in the Contacts UI in Xero. |
| `accountNumber` | `string` | No | A user defined account number. This can be updated via the API and the Xero UI (max length = 50). |
| `contactStatus` | `string` | No | Current status of a contact - see contact status types |
| `firstName` | `string` | No | First name of contact person (max length = 255) |
| `lastName` | `string` | No | Last name of contact person (max length = 255) |
| `emailAddress` | `string` | No | Email address of contact person (umlauts not supported) (max length = 255) |
| `skypeUserName` | `string` | No | Skype user name of contact |
| `contactPersons` | `any` | No | See contact persons |
| `bankAccountDetails` | `string` | No | Bank account number of contact |
| `taxNumber` | `string` | No | Tax number of contact - this is also known as the ABN (Australia), GST Number (New Zealand), VAT Number (UK) or Tax ID Number (US and global) in the Xero UI depending on which regionalized version of Xero you are using (max length = 50) |
| `accountReceivableTaxType` | `string` | No | Default tax type used for contact on AP invoices |
| `accountPayableType` | `string` | No | Store certain address types for a contact - see address types |
| `addresses` | `any` | No | Store certain address types for a contact - see address types |
| `phones` | `any` | No | Store certain phone types for a contact - see phone types |
| `isSupplier` | `boolean` | No | true or false  Boolean that describes if a contact that has any AP invoices entered against them. Cannot be set via PUT or POST - it is automatically set when an accounts payable invoice is generated against this contact. |
| `isCustomer` | `boolean` | No | true or false  Boolean that describes if a contact has any AR invoices entered against them. Cannot be set via PUT or POST - it is automatically set when an accounts receivable invoice is generated against this contact. |
| `defaultCurrency` | `string` | No | Default currency for raising invoices against contact |
| `xeroNetworkKey` | `string` | No | Store XeroNetworkKey for contacts |
| `salesDefaultAccountCode` | `string` | No | The default sales account code for contacts |
| `purchasesDefaultAccountCode` | `string` | No | The default purchases account code for contacts |
| `salesTrackingCategories` | `string` | No | The default sales tracking categories for contacts |
| `purchasesTrackingCategories` | `string` | No | The default purchases tracking categories for contacts |
| `trackingCategoryName` | `string` | No | The name of the Tracking Category assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories |
| `trackingOptionName` | `string` | No | The name of the Tracking Option assigned to the contact under SalesTrackingCategories and PurchasesTrackingCategories |
| `paymentTermsBillDay` | `integer` | No | The default payment terms bill day |
| `paymentTermsBillType` | `string` | No | The default payment terms bill type |

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

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: "xero_accounting_api-xero-accounting-create-or-update-contact",
  arguments: {
    tenantId: "Tenant ID",
    name: "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: "xero_accounting_api-xero-accounting-create-or-update-contact",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    xero_accounting_api: { authProvisionId: "apn_xxxxxxx" },
    tenantId: "Tenant ID",
    name: "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": "xero_accounting_api-xero-accounting-create-or-update-contact",
    "configured_props": {
      "xero_accounting_api": { "authProvisionId": "apn_xxxxxxx" },
      "tenantId": "Tenant ID",
      "name": "Name"
    }
  }'
```

---

- App: https://pipedream.com/apps/xero-accounting-api.md · All apps: https://pipedream.com/apps
