## Find duplicates of a lead (tenant:crm:read)

`GET /api/crm/v1/leads/duplicates`

Module: CRM · operationId: `findLeadDuplicates` · Tag: Leads · Auth: access token (`Authorization: Bearer <accessToken>`)

Leads and masterdata addresses with the same normalised company name or the same e-mail
address. `masterdataUnavailable` is `true` when masterdata could not be asked and only leads were
searched.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `company` | query | string |  | (max length 255) |
| `email` | query | string |  | (max length 255) |
| `excludeId` | query | string (uuid) |  | A lead to leave out (the one being edited). |

### Responses

- **200** Candidates (`application/json`)
- **400** Invalid input (`invalid`): `field` names the first invalid field, `details.fields` every one (JSON paths for
bodies, parameter names for the query). Some refusals have their own code (`invalid_sort`,
`invalid_stages`, `invalid_custom_fields`, `convert_target_required`, `invalid_csv`, …).
 (`application/json`)
- **401** Missing, invalid or expired token (no body).
- **403** The token lacks the permission (`insufficient permissions`) or has no active tenant.
 (`application/json`)
- **500** Unexpected error; details are only logged. (`application/json`)

Fields of the 200 answer:

- `candidates` (array of DuplicateCandidate, required): Leads and addresses that look the same.
  - `company` (string, required): Company name.
  - `match` (string, required): What matched. (one of `email`, `company`)
  - `source` (string, required): `import`: an earlier row of the same import file (`id` empty, see `line`). (one of `lead`, `address`, `import`)
  - `adrNr` (string): Address number (masterdata addresses).
  - `city` (string): City (masterdata addresses).
  - `contactName` (string): Contact person (leads).
  - `email` (string): E-mail address (leads).
  - `id` (string (uuid)): Set for leads and addresses.
  - `line` (integer): Line of the earlier row (source `import`).
  - `status` (string): Lead status (leads).
- `masterdataUnavailable` (boolean, required): Only leads were searched.

Example 200 answer:

```json
{
  "candidates": [
    {
      "company": "Brauerei Gaßner GmbH \u0026 Co. KG",
      "contactName": "Eva Gaßner",
      "email": "eva.gassner@brauerei-gassner.example",
      "id": "5b7d9f1a-3c5e-4a7b-9d1f-3a5c7e9b1d3f",
      "match": "email",
      "source": "lead",
      "status": "QUALIFIED"
    },
    {
      "adrNr": "10031",
      "city": "Mallersdorf-Pfaffenberg",
      "company": "Brauerei Gaßner GmbH \u0026 Co. KG",
      "id": "0e2a4c6e-8a1b-4d3f-9b5d-7f9b1d3f5a7b",
      "match": "company",
      "source": "address"
    }
  ],
  "masterdataUnavailable": false
}
```

### Example request

```bash
curl -X GET 'https://api.mbcom.cloud/api/crm/v1/leads/duplicates' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
