# `compare_contact_pair` — Compare Two Contacts for Duplicate Match

> Part of [CRM Cleanse & Dedupe Edge API](https://crm-cleanse.apikeg.com/llms.txt) (`com.apikeg/crm-cleanse`)

Computes field-by-field normalized similarity (email fingerprint, E.164 phone, Jaro-Winkler + Soundex name, company key, corporate domain) and returns an isMatch merge recommendation.

**Why call instead of DIY:** Instant deterministic entity-resolution check for webhook/CRM pre-insert hooks at $0.0005 per pair.

- **REST Endpoint:** `POST https://crm-cleanse.apikeg.com/v1/compare-contact-pair`
- **MCP Server:** `https://crm-cleanse.apikeg.com/mcp` (tool: `compare_contact_pair`)
- **Pricing:** $0.0005 USD per contact pair comparison (x402 instant micropayment)
- **Free Dry-Run:** `POST https://crm-cleanse.apikeg.com/v1/compare-contact-pair?dry_run=true`

## Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "recordA": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "maxLength": 128,
          "description": "Optional caller-supplied CRM record identifier."
        },
        "fullName": {
          "type": "string",
          "maxLength": 200,
          "description": "Full person name (may include honorifics/suffixes such as 'Dr. Ronald MCDONALD, MBA')."
        },
        "firstName": {
          "type": "string",
          "maxLength": 120,
          "description": "Given/first name if already split."
        },
        "lastName": {
          "type": "string",
          "maxLength": 120,
          "description": "Family/last name if already split."
        },
        "email": {
          "type": "string",
          "maxLength": 320,
          "description": "Email address (supports +tag subaddressing and free-webmail detection)."
        },
        "phone": {
          "type": "string",
          "maxLength": 64,
          "description": "Domestic or international phone string, optionally including an extension."
        },
        "country": {
          "type": "string",
          "minLength": 2,
          "maxLength": 2,
          "pattern": "^[A-Za-z]{2}$",
          "description": "Per-record ISO 3166-1 alpha-2 country override for domestic phone parsing."
        },
        "company": {
          "type": "string",
          "maxLength": 240,
          "description": "Raw company or organization name (e.g. 'Acme, Inc.' or 'Siemens AG')."
        },
        "title": {
          "type": "string",
          "maxLength": 160,
          "description": "Job title or organizational role."
        },
        "website": {
          "type": "string",
          "maxLength": 512,
          "description": "Company website URL or domain."
        }
      },
      "additionalProperties": false,
      "description": "CRM contact or lead record."
    },
    "recordB": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "maxLength": 128,
          "description": "Optional caller-supplied CRM record identifier."
        },
        "fullName": {
          "type": "string",
          "maxLength": 200,
          "description": "Full person name (may include honorifics/suffixes such as 'Dr. Ronald MCDONALD, MBA')."
        },
        "firstName": {
          "type": "string",
          "maxLength": 120,
          "description": "Given/first name if already split."
        },
        "lastName": {
          "type": "string",
          "maxLength": 120,
          "description": "Family/last name if already split."
        },
        "email": {
          "type": "string",
          "maxLength": 320,
          "description": "Email address (supports +tag subaddressing and free-webmail detection)."
        },
        "phone": {
          "type": "string",
          "maxLength": 64,
          "description": "Domestic or international phone string, optionally including an extension."
        },
        "country": {
          "type": "string",
          "minLength": 2,
          "maxLength": 2,
          "pattern": "^[A-Za-z]{2}$",
          "description": "Per-record ISO 3166-1 alpha-2 country override for domestic phone parsing."
        },
        "company": {
          "type": "string",
          "maxLength": 240,
          "description": "Raw company or organization name (e.g. 'Acme, Inc.' or 'Siemens AG')."
        },
        "title": {
          "type": "string",
          "maxLength": 160,
          "description": "Job title or organizational role."
        },
        "website": {
          "type": "string",
          "maxLength": 512,
          "description": "Company website URL or domain."
        }
      },
      "additionalProperties": false,
      "description": "CRM contact or lead record."
    },
    "defaultCountry": {
      "type": "string",
      "default": "US",
      "minLength": 2,
      "maxLength": 2,
      "pattern": "^[A-Za-z]{2}$",
      "description": "Default ISO 3166-1 alpha-2 country code for domestic phone numbers."
    },
    "matchThreshold": {
      "type": "number",
      "default": 0.82,
      "minimum": 0.5,
      "maximum": 1,
      "description": "Minimum confidence threshold [0.5-1.0] required to recommend merging."
    }
  },
  "required": [
    "recordA",
    "recordB"
  ],
  "additionalProperties": false
}
```

## Examples
### Compare phonetic surname & legal suffix variants
```bash
curl -X POST "https://crm-cleanse.apikeg.com/v1/compare-contact-pair" \
  -H "Content-Type: application/json" \
  -d '{"defaultCountry":"GB","matchThreshold":0.82,"recordA":{"fullName":"Jon Smyth","phone":"07911 123456","company":"Albion Analytics Ltd"},"recordB":{"fullName":"John Smith","phone":"+44 7911 123456","company":"Albion Analytics Limited"}}'
```
Expected output: isMatch=true, recommendation='merge' with exact_phone_e164, fuzzy_name_and_company, and phonetic_name_match.
