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

# Lemlist: Post Companies Merge

> Merge up to 10 duplicate Lemlist companies into one. Includes SDK V2 guidance, input constraints, response fields, and Deepline credit cost.

Merge up to 10 duplicate Lemlist companies into one.

> [!NOTE]
>
> Tool ID: `lemlist_post_companies_merge`

## Run this action

Use the TypeScript SDK for one call. Use `ctx.tools.execute(...)` inside a Play for durable calls, scheduled calls, or CSV processing.

```ts theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
import { Deepline } from 'deepline';

const deepline = await Deepline.connect();
const result = await deepline.tools.execute(
  'lemlist_post_companies_merge',
  {
    "primaryId": "primary_123",
    "secondaryIds": [
      "secondary_123"
    ]
  },
);

console.log(result.toolResponse.raw);
```

### CLI

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline tools execute lemlist_post_companies_merge --input '{
  "primaryId": "primary_123",
  "secondaryIds": [
    "secondary_123"
  ]
}' --json
```

## Example response

The SDK returns this shape at `result.toolResponse.raw`. The example values illustrate the response.

```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
{
  "data": {
    "success": true,
    "primaryId": "primary_123",
    "merged": true,
    "mergedIds": [
      "merged_123"
    ],
    "remainingIds": [
      "remaining_123"
    ]
  }
}
```

Use `deepline describe lemlist_post_companies_merge --json` for the latest machine-readable contract.

## Input reference

Merges up to 10 lemlist companies into one. The survivor (`primaryId`) keeps its id and every value it holds. its empty fields are filled from the other companies, which are then deleted. Everything attached to a deleted company (contacts, activities, tasks, list memberships) is moved to the survivor. When a CRM is connected, the survivor keeps its CRM link (or adopts the first linked record's when it has none) and receives the merged values there. lemlist never merges or deletes anything in the CRM itself, so the other records' CRM entries stay in the CRM, unlinked from lemlist — merge them CRM-side too, or a CRM import may recreate the duplicate. The companies are folded into the survivor one at a time and the run **stops at the first failure**: `mergedIds` lists what went through, `remainingIds` what still exists. A first-fold failure returns an error instead — nothing was written. See the live schema below for the complete notes.

| Name | Type | Required | Default | Details |
| - | - | - | - | - |
| `payload.primaryId` | `string` | Yes | — | The surviving company. A lemlist company id (`cpn_xxx`). |
| `payload.secondaryIds` | `array` | Yes | — | The companies folded into the survivor then deleted, 9 at most. A lemlist company id (`cpn_xxx`). Must not contain `primaryId`, and each company is listed once. Minimum items: 1. Maximum items: 9. |

<details>
  <summary>Show raw input schema</summary>

  ### Input JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "description": "Merges up to 10 lemlist companies into one. The survivor (`primaryId`) keeps its id and every value it holds; its empty fields are filled from the other companies, which are then deleted. Everything attached to a deleted company (contacts, activities, tasks, list memberships) is moved to the survivor. When a CRM is connected, the survivor keeps its CRM link (or adopts the first linked record's when it has none) and receives the merged values there; lemlist never merges or deletes anything in the CRM itself, so the other records' CRM entries stay in the CRM, unlinked from lemlist — merge them CRM-side too, or a CRM import may recreate the duplicate. The companies are folded into the survivor one at a time and the run **stops at the first failure**: `mergedIds` lists what went through, `remainingIds` what still exists. A first-fold failure returns an error instead — nothing was written. **No undo:** deleted companies are gone.",
    "properties": {
      "primaryId": {
        "type": "string",
        "description": "The surviving company. A lemlist company id (`cpn_xxx`)."
      },
      "secondaryIds": {
        "type": "array",
        "description": "The companies folded into the survivor then deleted, 9 at most. A lemlist company id (`cpn_xxx`). Must not contain `primaryId`, and each company is listed once.",
        "minItems": 1,
        "maxItems": 9,
        "items": {
          "type": "string"
        }
      }
    },
    "required": [
      "primaryId",
      "secondaryIds"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output reference

Standard tool result payload.

| Name | Type | Required | Default | Details |
| - | - | - | - | - |
| `result.data` | `object` | Yes | — | Provider response payload. |
| `result.data.success` | `boolean` | Yes | — | — |
| `result.data.primaryId` | `string` | Yes | — | ID of the surviving lemlist company. |
| `result.data.merged` | `boolean` | Yes | — | `true` once at least one company was folded into the survivor. |
| `result.data.mergedIds` | `array` | Yes | — | IDs of the companies folded into the survivor and deleted, in fold order. |
| `result.data.remainingIds` | `array` | Yes | — | IDs of the companies NOT merged because an earlier fold failed. Empty when everything went through. |
| `result.data.rejectedFields` | `array` | No | — | Fields whose adopted value was refused by a uniqueness rule (kept survivor-side). Only present when it happened. |
| `result.meta` | `object` | No | — | Additional response metadata (status, paging). |

<details>
  <summary>Show raw output schema</summary>

  ### Output JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "description": "Standard tool result payload.",
    "properties": {
      "data": {
        "type": "object",
        "description": "Provider response payload.",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "primaryId": {
            "type": "string",
            "description": "ID of the surviving lemlist company."
          },
          "merged": {
            "type": "boolean",
            "description": "`true` once at least one company was folded into the survivor."
          },
          "mergedIds": {
            "type": "array",
            "description": "IDs of the companies folded into the survivor and deleted, in fold order.",
            "items": {
              "type": "string"
            }
          },
          "remainingIds": {
            "type": "array",
            "description": "IDs of the companies NOT merged because an earlier fold failed. Empty when everything went through.",
            "items": {
              "type": "string"
            }
          },
          "rejectedFields": {
            "type": "array",
            "description": "Fields whose adopted value was refused by a uniqueness rule (kept survivor-side). Only present when it happened.",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "success",
          "primaryId",
          "merged",
          "mergedIds",
          "remainingIds"
        ],
        "additionalProperties": false
      },
      "meta": {
        "type": "object",
        "description": "Additional response metadata (status, paging).",
        "additionalProperties": true
      }
    },
    "required": [
      "data"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Deepline cost

* Pricing model: `fixed` (per call).
* Estimated Deepline credits: `0` per pricing unit.
* Provider-native pricing may still exist outside Deepline credit billing.

## Related documentation

* [Lemlist provider guide](https://deepline.com/docs/providers/lemlist/guide.md)
* [SDK V2 quickstart](https://deepline.com/docs/sdk-v2/quickstart.md)
* [SDK reference](https://deepline.com/docs/sdk-v2/sdk-reference.md)
* [Run tools across a CSV](https://deepline.com/docs/sdk-v2/batch-csv.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.