> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open.cx/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Lead Action

> Find a Pipedrive lead by ID, phone, email, person, or org, and update or create it from an OpenCX workflow.

The **Update PipeDrive Lead** action lives inside the workflow builder. Point it at a lead (by ID or by search), declare the fields to change, and run. If the lead doesn't exist, the action can create one.

<Tip>
  New to the workflow builder? Open your [OpenCX dashboard](https://platform.open.cx) and pick any existing workflow, then drop an `Update PipeDrive Lead` node from the **CRM** category in the node picker.
</Tip>

## Configure the action

<Steps>
  <Step title="Drop the node into your workflow">
    In the flow builder, add an `Update PipeDrive Lead` node wherever you want the update to fire — usually after the AI has collected enough context.
  </Step>

  <Step title="Paste your credentials">
    Fill **PipeDrive API Token** and **Company Domain** with the values you gathered in [Connect](/integrations/pipedrive/connect).
  </Step>

  <Step title="Decide how to find the lead">
    If the workflow already has a Lead ID (from a Pipedrive webhook, for example), pass it in the **Lead ID** field. Otherwise fill **Search Criteria** with one or more `{ field, value }` pairs.
  </Step>

  <Step title="Declare your field updates">
    List the fields you want to write in **Field Updates**. Each entry is a `{ fieldKey, value }` pair — use Pipedrive's own field keys (`title`, `value`, `expected_close_date`) or the key of any custom field.
  </Step>

  <Step title="Pick your fallback behavior">
    Enable **Create If Not Found** if the workflow should create a new lead when the search misses. Leave **Skip Empty Values** on to avoid accidentally clearing fields.
  </Step>
</Steps>

## Inputs reference

<AccordionGroup>
  <Accordion title="Lead ID" icon="fingerprint">
    Optional. If set, the action skips the search entirely and PATCHes that lead. Use this when the Lead ID is already on your session or was passed in from a Pipedrive automation payload.
  </Accordion>

  <Accordion title="Search Criteria" icon="magnifying-glass">
    Optional, used only when Lead ID is empty. The first criterion's value becomes the search term; <Tooltip tip="Pipedrive's endpoint for searching across items. OpenCX calls it with exact_match=true and item_types=lead — only exact matches count.">Pipedrive's item search</Tooltip> is called with `exact_match=true` on `lead` items. Stick to standard fields: `phone`, `email`, `person_name`, or `org_name`.

    <Warning>
      Searching by **custom fields** is unreliable. If your lead needs to be matched by a value you stored in a custom field, find it a different way — for example, include the Lead ID in your Pipedrive automation payload and pass it through the workflow instead.
    </Warning>
  </Accordion>

  <Accordion title="Field Updates" icon="pen-to-square">
    Required. An array of `{ fieldKey, value }` objects. Each `fieldKey` is Pipedrive's exact field key — standard fields (`title`, `value`, `expected_close_date`) or the custom-field key you can see in Pipedrive's field settings.
  </Accordion>

  <Accordion title="Create If Not Found" icon="plus">
    Defaults to `false`. When `true` and the search misses, the action creates a new lead using your Field Updates as its starting values. If you didn't pass a `title`, OpenCX sets one from the first search criterion's value (e.g. `Lead - +15551234567`).
  </Accordion>

  <Accordion title="Skip Empty Values" icon="filter">
    Defaults to `true`. When `true`, fields whose value is `null`, `undefined`, or `""` are dropped before the update — they never overwrite existing data in Pipedrive. Set to `false` only when you explicitly want to clear a field.
  </Accordion>
</AccordionGroup>

## Updating the deal value

Pipedrive stores the `value` field as an object with an amount and a currency. The action hides that detail when you pass a plain number — it auto-wraps `42` as `{ amount: 42, currency: "USD" }`.

If your pipeline uses a different currency, pass the full object yourself:

```json theme={"dark"}
{
  "fieldKey": "value",
  "value": { "amount": 42, "currency": "EUR" }
}
```

For other numeric fields (stages, enums, sets), Pipedrive expects strings. The action stringifies them automatically — pass `3` and the API receives `"3"`.

## Output

| Key             | Meaning                                                                                      |
| --------------- | -------------------------------------------------------------------------------------------- |
| `success`       | `true` when the update or create landed; `false` if the action returned an error.            |
| `leadId`        | The ID of the lead that was updated or created.                                              |
| `wasCreated`    | `true` if the action created a new lead; `false` if it updated an existing one.              |
| `updatedFields` | Array of the `fieldKey`s that actually went into the request body.                           |
| `leadData`      | The full lead object returned by Pipedrive after the write. Use it to chain follow-up nodes. |
| `error`         | Error message if `success` is `false`.                                                       |

## Good To Know

<AccordionGroup>
  <Accordion title="Per-call timeout" icon="clock">
    Each search, create, and update request has a hard **30-second timeout**. Pipedrive is usually well under that, but flag slow runs if you see timeouts in your workflow run viewer.
  </Accordion>

  <Accordion title="Workflow-scoped credentials" icon="key">
    The API token is read from the node's own configuration every time the workflow runs — it is not stored at the organization level. Rotate a token and you will need to update every node that references it.
  </Accordion>

  <Accordion title="Errors surface as run failures" icon="triangle-exclamation">
    A bad token, a missing lead with `Create If Not Found` disabled, or an all-empty update raises a runtime error. The workflow run fails on that node — handle it with a conditional branch if your flow needs to keep going.
  </Accordion>
</AccordionGroup>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Connect" icon="plug" href="/integrations/pipedrive/connect">
    Generate an API token and find your company domain.
  </Card>

  <Card title="Trigger workflows from Pipedrive" icon="bolt" href="/integrations/pipedrive/webhook-trigger">
    Pair this action with a Pipedrive automation that fires the workflow.
  </Card>

  <Card title="Overview" icon="users-viewfinder" href="/integrations/pipedrive/overview">
    Capabilities and patterns at a glance.
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/integrations/pipedrive/troubleshooting">
    Lead not found, empty updates, currency errors.
  </Card>
</CardGroup>
