---
title: "Merge Filtered Companies"
method: POST
path: "/companies/merge-filtered"
tags: ["Companies"]
---

# Merge Filtered Companies

`POST /companies/merge-filtered`

## Request

- Base URL: `https://be.graph8.com/api/v1`
- URL: `https://be.graph8.com/api/v1/companies/merge-filtered`
- Auth: HTTP bearer

Add every company matching a filter into `target_list_id`.

Despite the name this does NOT merge duplicate companies together - it
merges a SELECTION INTO A LIST. `/duplicates` merges records.

A 409 means some companies need a decision; re-send with
`conflict_resolution`.

## Query parameters

- `filterModel` string, nullable: Optional per-column filter JSON.
- `sortModel` string, nullable: Optional sort JSON.

## Headers

- `Authorization` string, nullable
- `X-Target-Org-Id` string, nullable

## Request body

- MergeFilteredRequest: Add every record matching a filter into a target list. Mirrors `MergeFilteredContactsRequest` / `MergeFilteredCompaniesRequest`, which are field-identical. Despite the name this MERGES A SELECTION INTO A LIST - it does not merge duplicate records together. `/duplicates` is the surface that does that. On a 409 the call is telling you some records need a decision; re-send with `conflict_resolution` set.
  - `target_list_id` integer, required: List the matching records are added to.
  - `filter` FilterCondition[]: Conditions selecting the source records.
    - `field` string, required: Field name to apply the condition to.
    - `operator` string: Operator, e.g. `=`, `in`, `like`.
    - `value` unknown
    - `value_to` unknown
  - `dynamic_column_mapping` object: Source-column to target-column mapping for custom columns.
  - `segmentFilter` SegmentFilterGroup: An AND/OR group of leaves and nested groups, at most three groups deep. Mirrors `SegmentFilterGroup` in `contacts.domain.value_objects.ag_grid_models`. `op` is closed because the app REFUSES an unrecognised connector rather than defaulting to AND - defaulting would silently return a different result set, and on a destructive route that is a different set of records acted on. FIXED DEPTH, NOT RECURSIVE. The app's model is self-referencing; the published one deliberately is not, because a schema that reaches itself through `$ref` sends the docs renderer into unbounded recursion. Three group levels (this one, `SegmentFilterSubgroup`, `SegmentFilterInnerGroup`) cover every filter the app's own builder produces; the app's larger depth and leaf budget still applies and surfaces as a 422.
    - `op` 'AND' | 'OR' | 'and' | 'or', required: Connector for this group. Case-insensitive.
    - `children` union[]: Nested groups and/or leaf conditions.
      - union
        - SegmentFilterSubgroup: The second group level: leaves and/or innermost groups.
          - `op` 'AND' | 'OR' | 'and' | 'or', required: Connector for this group. Case-insensitive.
          - `children` union[]: Innermost groups and/or leaf conditions.
            - union
              - …
        - SegmentFilterLeaf: One field-level condition inside an advanced-filter tree. Mirrors `contacts.domain.value_objects.ag_grid_models.SegmentFilterLeaf`. `op` is CLOSED here: the app compiles its UI vocabulary down to this canonical set before sending, and an unrecognised operator reaching the SQL builder is a 500 rather than a refusal naming the valid operators.
          - `field` string, required: Column to test, e.g. `CONTACT_JOB_TITLE`.
          - `op` 'eq' | 'neq' | 'lt' | 'lte' | 'gt' | 'gte' | 'contains' | 'icontains' | 'starts_with' | 'ends_with' | 'in' | 'not_in' | 'between' | 'is_null' | 'is_not_null', required: Comparison to apply.
          - `value` unknown
          - `valueTo` unknown
  - `conflict_resolution` 'add_all' | 'skip_all' | 'custom', nullable: Required when retrying after a 409. `add_all` takes every warned record, `skip_all` takes none of them, `custom` takes the ids in `include_warned_ids`. Blocked records are excluded either way.
  - `include_warned_ids` string[], nullable: With `conflict_resolution=custom`, the warned ids to include.

## Response `200`

Successful Response

- ApiResponseCrmRecordPayload
  - `data` CrmRecordPayload, required: An open envelope for one record, one dashboard or one job receipt. Open because most of these reads are COMPUTED shapes - an engagement summary, a next-best-step, an intelligence status - that grow with the product, and dropping a field from an advisory read makes it say "nothing to report" rather than "we did not tell you".
  - `pagination` PaginationMeta
    - `page` integer, required: Current page number (1-indexed)
    - `limit` integer, required: Items per page
    - `total` integer, required: Total number of items
    - `has_next` boolean, required: Whether there are more pages
    - `next_cursor` string, nullable: Opaque cursor for the next page; null when there are no more items. Pass it back as the `cursor` query param to fetch the following page without computing page numbers.
    - `total_available` integer, nullable: Search endpoints only: how many records really match, when known. Can be larger than `total`, which is capped at the 10,000 results that can be paged. For company search this is a distinct-company estimate. Null when unknown; absent outside search.
    - `total_is_lower_bound` boolean, nullable: Search endpoints only: true when more records match than `total` shows (the result set is larger than the 10,000 results that can be paged). Absent outside search.
    - `notes` string[], nullable: Search endpoints only: plain-language notes about the result, e.g. that more records match than can be paged, or that a reversed `between` range was put in order.

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/graph8/apis/graph8-developer-api.md) · [All operations](https://skmtc.dev/graph8/apis/graph8-developer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/graph8/apis/graph8-developer-api/revisions/2e7cfa0ca921?raw)
