# Add Deal — Pipedrive

> Adds a new deal. See the Pipedrive API docs for Deals here

- Key: `pipedrive-add-deal`
- Type: Action (Write)
- Version: 0.1.26
- App: Pipedrive (`pipedrive`) — https://pipedream.com/apps/pipedrive.md
- This page (HTML): https://pipedream.com/apps/pipedrive/actions/add-deal
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/pipedrive/actions/add-deal/add-deal.mjs

## Description

Adds a new deal. See the Pipedrive API docs for Deals [here](https://developers.pipedrive.com/docs/api/v1/Deals#addDeal)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `title` | `string` | Yes | Deal title |
| `ownerId` | `integer` | No | ID of the user who will be marked as the owner of this deal. If omitted, the authorized user ID will be used. Options are loaded from the connected account. |
| `personId` | `integer` | No | ID of the person this deal will be associated with Options are loaded from the connected account. |
| `orgId` | `integer` | No | ID of the organization this deal will be associated with Options are loaded from the connected account. |
| `pipelineId` | `integer` | No | ID of the pipeline this activity will be associated with Options are loaded from the connected account. |
| `stageId` | `integer` | No | ID of the stage this deal will be placed in a pipeline (note that you can't supply the ID of the pipeline as this will be assigned automatically based on stage_id). If omitted, the deal will be placed in the first stage of the default pipeline. Get the stage_id from here. Options are loaded from the connected account. |
| `value` | `string` | No | Value of the deal. If omitted, value will be set to 0. |
| `currency` | `string` | No | Currency of the deal. Accepts a 3-character currency code. If omitted, currency will be set to the default currency of the authorized user. |
| `status` | `string` | No | open = Open, won = Won, lost = Lost, deleted = Deleted. If omitted, status will be set to open. |
| `probability` | `integer` | No | Deal success probability percentage. Used/shown only when deal_probability for the pipeline of the deal is enabled. |
| `lostReason` | `string` | No | Optional message about why the deal was lost (to be used when status=lost) |
| `visibleTo` | `integer` | No | Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user. |
| `isDeleted` | `boolean` | No | Whether the deal is deleted or not |
| `isArchived` | `boolean` | No | Whether the deal is archived or not |
| `archiveTime` | `string` | No | The optional date and time of archiving the deal in UTC. Format: YYYY-MM-DD HH:MM:SS. If omitted and Is Archived is true, it will be set to the current date and time. |
| `closeTime` | `string` | No | The date and time of closing the deal. Can only be set if deal status is won or lost. Format: YYYY-MM-DD HH:MM:SS |
| `wonTime` | `string` | No | The date and time of changing the deal status as won. Can only be set if deal status is won. Format: YYYY-MM-DD HH:MM:SS |
| `lostTime` | `string` | No | The date and time of changing the deal status as lost. Can only be set if deal status is lost. Format: YYYY-MM-DD HH:MM:SS |
| `expectedCloseDate` | `string` | No | The expected close date of the deal. Format: YYYY-MM-DD |
| `labelIds` | `integer[]` | No | The IDs of labels assigned to the deal Options are loaded from the connected account. |
| `customFields` | `object` | No | An object where each key represents a custom field. All custom fields are referenced as randomly generated 40-character hashes |
| `note` | `string` | No | The content of a note to be attached to the deal. The note will be created after the deal is successfully added. |

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

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: "pipedrive-add-deal",
  arguments: {
    title: "Title",
    ownerId: 10,
  },
})
```

**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: "pipedrive-add-deal",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    pipedrive: { authProvisionId: "apn_xxxxxxx" },
    title: "Title",
    ownerId: 10,
  },
})

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": "pipedrive-add-deal",
    "configured_props": {
      "pipedrive": { "authProvisionId": "apn_xxxxxxx" },
      "title": "Title",
      "ownerId": 10
    }
  }'
```

---

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