Skip to main content
POST
/
v1
/
ai
/
detect-duplicates
Detect Duplicates
curl --request POST \
  --url https://api.example.com/v1/ai/detect-duplicates \
  --header 'Content-Type: application/json' \
  --data '
{
  "entity_type": "<string>",
  "threshold": 123,
  "limit": 123,
  "scope": {}
}
'
{
  "data": {
    "pairs": [
      {
        "primary_id": "<string>",
        "duplicate_id": "<string>",
        "similarity": 123,
        "matched_fields": [
          {}
        ],
        "reason": "<string>"
      }
    ],
    "total_candidates": 123,
    "credits_remaining": 123
  }
}
This endpoint consumes AI credits. Each scan costs 3 credits for workspaces up to 10,000 records, 5 credits up to 100,000, and 10 credits beyond that. If the workspace balance is insufficient, the API returns 402 insufficient_credits.

Request

Headers

Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
Idempotency-Key
string
Optional UUID for retry deduplication. A 60-minute cache applies to the result.

Body Parameters

entity_type
string
required
One of contact, company, or deal.
threshold
number
default:"0.85"
Minimum similarity score (0.0 - 1.0) for a pair to be flagged. Lower values surface more candidates; higher values reduce noise.
limit
integer
default:"100"
Maximum number of duplicate pairs to return in a single response. Maximum 1000.
scope
object
Optional additional filters: created_after (ISO 8601), tag, list_id.

Response

data
object
Responses include X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-Request-ID.
curl -X POST \
  https://data.leadlex.com/functions/v1/api-gateway/v1/ai/detect-duplicates \
  -H "Authorization: Bearer wbk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"entity_type": "contact", "threshold": 0.9}'

Example Response

{
  "data": {
    "pairs": [
      {
        "primary_id": "123e4567-e89b-12d3-a456-426614174000",
        "duplicate_id": "aaaa1111-bbbb-2222-cccc-333344445555",
        "similarity": 0.96,
        "matched_fields": ["email", "full_name", "company_name"],
        "reason": "Both records share the same email domain and nearly identical name."
      }
    ],
    "total_candidates": 4821,
    "credits_remaining": 4863
  }
}

Errors

StatusCodeDescription
400validation_errorUnsupported entity_type or invalid threshold
401invalid_keyInvalid or expired API key
402insufficient_creditsWorkspace credit balance is exhausted
403insufficient_permissionsMissing write:ai permission
429rate_limitedRate limit exceeded