# Create or Update Custom Object — Gainsight

> Create or update a custom object record. See the documentation

- Key: `gainsight_nxt-create-or-update-custom-object`
- Type: Action (Write)
- Version: 0.0.3
- App: Gainsight (`gainsight_nxt`) — https://pipedream.com/apps/gainsight-nxt.md
- This page (HTML): https://pipedream.com/apps/gainsight-nxt/actions/create-or-update-custom-object
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/gainsight_nxt/actions/create-or-update-custom-object/create-or-update-custom-object.mjs

## Description

Create or update a custom object record. [See the documentation](https://support.gainsight.com/gainsight_nxt/API_and_Developer_Docs/Custom_Object_API/Gainsight_Custom_Object_API_Documentation#Insert_API)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `objectName` | `string` | Yes | The name of the custom object. Options are loaded from the connected account. |
| `fields` | `string[]` | Yes | The field(s) which identify this object (max 3), e.g. fieldName1. If a record with the same key field(s) exists, it will be updated, otherwise a new one will be created. |
| `fieldValues` | `object` | Yes | The record data to create or update, as key-value pairs. |

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

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: "gainsight_nxt-create-or-update-custom-object",
  arguments: {
    objectName: "Custom Object",
    fields: ["Key Field(s)"],
  },
})
```

**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: "gainsight_nxt-create-or-update-custom-object",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    gainsight_nxt: { authProvisionId: "apn_xxxxxxx" },
    objectName: "Custom Object",
    fields: ["Key Field(s)"],
  },
})

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": "gainsight_nxt-create-or-update-custom-object",
    "configured_props": {
      "gainsight_nxt": { "authProvisionId": "apn_xxxxxxx" },
      "objectName": "Custom Object",
      "fields": ["Key Field(s)"]
    }
  }'
```

---

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