Skip to main content
POST
Merge Companies
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. A value the survivor already has is never overwritten. Companies are addressed by their lemlist id (cpn_xxx).

What moves to the survivor

  • Contacts, activities, tasks and list memberships of every deleted company.
  • When a CRM is connected, the survivor keeps its CRM link, or adopts the first linked company’s when it has none, and receives the merged values there. lemlist never merges or deletes anything in the CRM itself: the other companys’ CRM records stay in the CRM, unlinked from lemlist. Merge them CRM-side too, or a later CRM import may recreate the duplicate.

Partial runs — success: true does not mean complete

The companies are folded into the survivor one at a time and the run stops at the first failure. The response is still 200: mergedIds lists what went through, remainingIds what still exists — fix the cause and call again with the remaining ids. A failure on the very first fold returns an error instead, and nothing was written.
There is no undo. Once merged, the secondary companies are deleted and only the survivor remains.

Authorizations

Authorization
string
header
required

Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.

Body

application/json
primaryId
string
required

The surviving company. A lemlist company id (cpn_xxx).

Example:

"cpn_A1B2C3D4E5F6G7H8I"

secondaryIds
string[]
required

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.

Required array length: 1 - 9 elements
Example:

Response

Merge run — success: true does not mean complete. The companies fold one at a time and the run stops at the first failure, so ALWAYS check remainingIds: the companies listed there were NOT merged and still exist. Fix the cause and call again with the survivor and the remaining ids.

success
boolean
required
primaryId
string
required

ID of the surviving lemlist company.

merged
boolean
required

true once at least one company was folded into the survivor.

mergedIds
string[]
required

IDs of the companies folded into the survivor and deleted, in fold order.

remainingIds
string[]
required

IDs of the companies NOT merged because an earlier fold failed. Empty when everything went through.

rejectedFields
string[]

Fields whose adopted value was refused by a uniqueness rule (kept survivor-side). Only present when it happened.