Memory

Merge Duplicates

Merge one duplicate lead or company (a `GET /kg/duplicates` suggestion) into another (admin+; never automatic). In one transaction every child row of the duplicate (timeline, consents, calls, meetings, enrollments, drafts, replies, research, enrichment, signals, deliveries, knowledge-graph nodes, edges and facts; for companies also their leads) moves to the kept record, empty fields of the kept record are filled from it and the duplicate is deleted. Compliance keeps the stricter state: a consent revoked on either lead revokes the other's for the same channel and purpose, and suppressed addresses (or domains) suppress the kept record's. A timeline note and the audit log record it. Idempotent: repeating it answers the recorded outcome (`already_merged: true`). 404 a record is not a live one of this workspace; 409 `call_in_progress`, `privacy_request_open`, or `already_merged` into another record.

API key access

Needs the admin scope with an API key (ro_pat_...). A signed-in session uses the caller's role.
POST/api/v1/kg/merge
AuthorizationBearer <token>

Access token from /api/v1/auth/login, or an API key (ro_pat_..., RO-176) from /api/v1/workspaces/current/api-keys: the key implies its workspace and needs the route's scope. MCP connectors (/api/v1/mcp only) may use an OAuth access token (ro_oat_..., RO-284).

In: header

Header Parameters

X-Workspace-Id?string | null

Id of the workspace to act on (must be a member).

kindMergeKind

What a merge acts on (RO-247).

Value in"lead" | "company"
survivor_idstring

The record that is kept.

Formatuuid
merged_idstring

The duplicate: its data moves to the kept record and it is deleted.

Formatuuid

Response Body

curl -X POST "http://localhost:8000/api/v1/kg/merge" \  -H "X-Workspace-Id: string" \  -H "Content-Type: application/json" \  -d '{    "kind": "lead",    "survivor_id": "43b7619a-86a5-46b3-8c4e-e5d4e644b9cb",    "merged_id": "2be53fee-32eb-4df8-945d-1095aae1afde"  }'
{
  "kind": "lead",
  "survivor_id": "43b7619a-86a5-46b3-8c4e-e5d4e644b9cb",
  "merged_id": "2be53fee-32eb-4df8-945d-1095aae1afde",
  "already_merged": true,
  "moved": {
    "property1": 0,
    "property2": 0
  },
  "filled": [
    "string"
  ],
  "consents_revoked": 0,
  "suppressions_added": 0,
  "merged_at": "2019-08-24T14:15:22Z"
}
Empty
Empty
Empty
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}