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
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
Optional UUID for retry deduplication. A 60-minute cache applies to the result.
Body Parameters
One of contact, company, or deal.
Minimum similarity score (0.0 - 1.0) for a pair to be flagged. Lower values surface more candidates; higher values reduce noise.
Maximum number of duplicate pairs to return in a single response. Maximum 1000.
Optional additional filters: created_after (ISO 8601), tag, list_id.
Response
ID of the suggested primary record
ID of the suggested duplicate
Confidence score (0.0 - 1.0)
Fields that contributed to the match (e.g. email, full_name, phone)
Short natural-language explanation
Number of records scanned
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
Status Code Description 400 validation_errorUnsupported entity_type or invalid threshold 401 invalid_keyInvalid or expired API key 402 insufficient_creditsWorkspace credit balance is exhausted 403 insufficient_permissionsMissing write:ai permission 429 rate_limitedRate limit exceeded