> ## 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.

# Affinity: V2 Company Merges Post

> Merge a duplicate Affinity company into a primary company. Includes SDK V2 guidance, input constraints, response fields, and Deepline credit cost.

Merge a duplicate Affinity company into a primary company.

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

## 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(
  'affinity_v2_company_merges_post',
  {
    "primaryCompanyId": 123,
    "duplicateCompanyId": 123
  },
);

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

### CLI

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline tools execute affinity_v2_company_merges_post --input '{
  "primaryCompanyId": 123,
  "duplicateCompanyId": 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": {
    "taskUrl": "https://example.com/resource"
  }
}
```

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

## Input reference

Request body for initiating a company merge

| Name | Type | Required | Default | Details |
| - | - | - | - | - |
| `payload.primaryCompanyId` | `integer` | Yes | — | The ID of the company profile that will be kept after the merge. All data from the duplicate company will be merged into this company. Format: `int64`. Minimum: 1. Maximum: 9007199254740991. |
| `payload.duplicateCompanyId` | `integer` | Yes | — | The ID of the company profile that will be merged and then deleted. All data from this company will be transferred to the primary company. Format: `int64`. Minimum: 1. Maximum: 9007199254740991. |
| `payload.wait_for_completion` | `boolean` | No | `true` | Poll the Affinity merge task before returning. Set false to return the task handle immediately. |
| `payload.poll_interval_ms` | `integer` | No | `1000` | Milliseconds between merge task status polls. Minimum: 100. Maximum: 10000. |
| `payload.max_wait_ms` | `integer` | No | `30000` | Maximum synchronous wait before returning a running task handle. Minimum: 1000. Maximum: 30000. |

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

  ### Input JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "description": "Request body for initiating a company merge",
    "properties": {
      "primaryCompanyId": {
        "type": "integer",
        "description": "The ID of the company profile that will be kept after the merge. All data from the duplicate company will be merged into this company.",
        "minimum": 1,
        "maximum": 9007199254740991,
        "format": "int64"
      },
      "duplicateCompanyId": {
        "type": "integer",
        "description": "The ID of the company profile that will be merged and then deleted. All data from this company will be transferred to the primary company.",
        "minimum": 1,
        "maximum": 9007199254740991,
        "format": "int64"
      },
      "wait_for_completion": {
        "type": "boolean",
        "description": "Poll the Affinity merge task before returning. Set false to return the task handle immediately.",
        "default": true
      },
      "poll_interval_ms": {
        "type": "integer",
        "description": "Milliseconds between merge task status polls.",
        "default": 1000,
        "minimum": 100,
        "maximum": 10000
      },
      "max_wait_ms": {
        "type": "integer",
        "description": "Maximum synchronous wait before returning a running task handle.",
        "default": 30000,
        "minimum": 1000,
        "maximum": 30000
      }
    },
    "required": [
      "primaryCompanyId",
      "duplicateCompanyId"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output reference

| Name | Type | Required | Default | Details |
| - | - | - | - | - |
| `result.data` | `object` | Yes | — | — |
| `result.data.taskUrl` | `string` | Yes | — | Format: `uri`. |
| `result.data.taskId` | `string` | No | — | Affinity merge task ID. |
| `result.data.status` | `"in-progress" \| "success" \| "failed"` | No | — | Current merge task status. Allowed: `in-progress`, `success`, `failed`. |
| `result.data.launcher` | `record` | No | — | Original Affinity merge launch response. |
| `result.data.task` | `record` | No | — | Terminal Affinity merge task response. |
| `result.data.latestTask` | `object \| null` | No | — | Latest task response observed before the sync wait ended. |
| `result.data.asyncGetAction` | `string` | No | — | Action to poll while the merge remains in progress. |
| `result.meta` | `object` | No | — | — |

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

  ### Output JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "properties": {
      "data": {
        "type": "object",
        "properties": {
          "taskUrl": {
            "type": "string",
            "format": "uri"
          },
          "taskId": {
            "type": "string",
            "description": "Affinity merge task ID."
          },
          "status": {
            "type": "string",
            "description": "Current merge task status.",
            "enum": [
              "in-progress",
              "success",
              "failed"
            ]
          },
          "launcher": {
            "type": "object",
            "description": "Original Affinity merge launch response.",
            "additionalProperties": true
          },
          "task": {
            "type": "object",
            "description": "Terminal Affinity merge task response.",
            "additionalProperties": true
          },
          "latestTask": {
            "type": [
              "object",
              "null"
            ],
            "description": "Latest task response observed before the sync wait ended.",
            "additionalProperties": true
          },
          "asyncGetAction": {
            "type": "string",
            "description": "Action to poll while the merge remains in progress."
          }
        },
        "required": [
          "taskUrl"
        ],
        "additionalProperties": true
      },
      "meta": {
        "type": "object",
        "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

* [Affinity provider guide](https://deepline.com/docs/providers/affinity/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.