조건 매칭 기반 관계 일괄 연결
POST/crm-core/v1/relationships/bulk-match
소스 레코드의 이름 또는 특정 속성값을 기준으로 대상 개체의 레코드를 자동 매칭하여 관계를 생성한다. 예를 들어 "이메일 값이 같은 고객 ↔ 회사 담당자"를 일괄 연결하는 용도. 권한 요구: MEMBER 이상.
Body Params
| Name | Type | Required | Description |
|---|---|---|---|
| sourceEntityId | string | 소스 개체 ID | |
| relationshipTypeId | string | 관계 유형 ID | |
| sourceRecordIds | Array | 소스 레코드 ID 목록. 최대 500개. sourceFilter와 택일 | |
| sourceFilter | Object | 필터 조건으로 소스 레코드 선택 (최대 5,000건) | |
| sourceFilter.keyword | string | 레코드 이름 부분 일치 키워드 | |
| sourceFilter.filters | string | 속성값 필터 JSON 문자열 | |
| sourceFilter.segmentId | string | 세그먼트 기반 필터 | |
| criteria | Array | 매칭 기준 목록. 최소 1개 이상 | |
| criteria[].myField | Object | 소스 레코드에서 비교할 필드 | |
| criteria[].myField.type | string | name 또는 property | |
| criteria[].myField.propertyId | string | type=property일 때 사용할 속성 ID | |
| criteria[].counterField | Object | 대상 레코드에서 비교할 필드 | |
| criteria[].counterField.type | string | name 또는 property | |
| criteria[].counterField.propertyId | string | type=property일 때 사용할 속성 ID | |
| matchMode | string | FIRST(첫 번째 매칭만) 또는 ALL(모든 매칭) |
Response
| Name | Type | Required | Description |
|---|---|---|---|
| matched | number | 매칭에 성공한 소스 레코드 수 | |
| created | number | 생성된 관계 수 | |
| skipped | number | * | 매칭 실패 또는 중복으로 건너뛴 수 |
Structure
코드 예제
const response = await fetch('https://api.solapi.com/crm-core/v1/relationships/bulk-match', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + TOKEN,
'Content-Type': 'application/json'
},
body: JSON.stringify({
sourceEntityId: 'CRMET1260423081530123XYZ11122233',
relationshipTypeId: 'CRMRT1260423091530123RTP11122233',
sourceRecordIds: ['CRMRC1260423081530123REC11122233'],
criteria: [
{
myField: { type: 'property', propertyId: 'CRMPP1260423091530123PPP11122233' },
counterField: { type: 'property', propertyId: 'CRMPP1260423091530124PPP11122234' }
}
],
matchMode: 'FIRST'
})
});
const data = await response.json();
import requests
response = requests.post(
'https://api.solapi.com/crm-core/v1/relationships/bulk-match',
headers={'Authorization': f'Bearer {TOKEN}'},
json={
'sourceEntityId': 'CRMET1260423081530123XYZ11122233',
'relationshipTypeId': 'CRMRT1260423091530123RTP11122233',
'sourceRecordIds': ['CRMRC1260423081530123REC11122233'],
'criteria': [
{
'myField': {'type': 'property', 'propertyId': 'CRMPP1260423091530123PPP11122233'},
'counterField': {'type': 'property', 'propertyId': 'CRMPP1260423091530124PPP11122234'}
}
],
'matchMode': 'FIRST'
}
)
data = response.json()
curl -X POST 'https://api.solapi.com/crm-core/v1/relationships/bulk-match' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"sourceEntityId":"CRMET1260423081530123XYZ11122233","relationshipTypeId":"CRMRT1260423091530123RTP11122233","sourceRecordIds":["CRMRC1260423081530123REC11122233"],"criteria":[{"myField":{"type":"name"},"counterField":{"type":"name"}}],"matchMode":"FIRST"}'
`matchMode`가 `FIRST`이면 소스 1건당 첫 매칭 대상 1건에만 관계를 생성한다. `ALL`이면 매칭되는 모든 대상 레코드와 관계를 만들어 대상 개체에서 fan-out이 커질 수 있으니 주의.
`criteria`는 AND로 결합된다. 여러 기준을 모두 만족하는 대상 레코드만 매칭되며, 동일 조합의 관계가 이미 있으면 중복 생성되지 않고 `skipped`로 집계된다.