관계 일괄 생성
/crm-core/v1/relationships/bulk조건 또는 ID 목록으로 선택한 다수의 소스 레코드를 지정한 대상 레코드들과 일괄 연결합니다. 카르테시안 곱(소스 × 대상)이 10,000건을 초과하면 거절됩니다. 중복 관계는 자동으로 건너뛰며, 응답에 skipped로 집계됩니다. MEMBER 이상 권한 + relationships.max 한도 적용.
Body Params
Response
Structure
코드 예제
const crypto = require('crypto');
const apiKey = 'NCSXXXXXXXXXXXXX';
const apiSecret = 'YOUR_API_SECRET';
const dateTime = new Date().toISOString();
const salt = crypto.randomBytes(16).toString('hex');
const signature = crypto.createHmac('sha256', apiSecret).update(dateTime + salt).digest('hex');
const authHeader = HMAC-SHA256 apiKey=${apiKey}, date=${dateTime}, salt=${salt}, signature=${signature};
const response = await fetch('https://api.solapi.com/crm-core/v1/relationships/bulk', {
method: 'POST',
headers: { 'Authorization': authHeader, 'Content-Type': 'application/json' },
body: JSON.stringify({
"sourceEntityId": "CRMET1260423081530123CUS11122233",
"relationshipTypeId": "CRMRT1260423091530123RTP11122233",
"targetEntityId": "CRMET1260423081530124COM11122234",
"targetRecordIds": [
"CRMRC1260423081530124REC11122234"
],
"sourceFilter": {
"segmentId": "CRMSG1260423081530123SGM11122233"
}
})
});
const data = await response.json();
import hmac, hashlib, secrets, requests
from datetime import datetime, timezone
api_key = 'NCSXXXXXXXXXXXXX'
api_secret = 'YOUR_API_SECRET'
date_time = datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
salt = secrets.token_hex(16)
signature = hmac.new(api_secret.encode(), (date_time + salt).encode(), hashlib.sha256).hexdigest()
auth_header = f'HMAC-SHA256 apiKey={api_key}, date={date_time}, salt={salt}, signature={signature}'
response = requests.post('https://api.solapi.com/crm-core/v1/relationships/bulk', headers={
'Authorization': auth_header,
'Content-Type': 'application/json'
}, json={
"sourceEntityId": "CRMET1260423081530123CUS11122233",
"relationshipTypeId": "CRMRT1260423091530123RTP11122233",
"targetEntityId": "CRMET1260423081530124COM11122234",
"targetRecordIds": [
"CRMRC1260423081530124REC11122234"
],
"sourceFilter": {
"segmentId": "CRMSG1260423081530123SGM11122233"
}
})
data = response.json()
API_KEY="NCSXXXXXXXXXXXXX"
API_SECRET="YOUR_API_SECRET"
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
SALT=$(openssl rand -hex 16)
SIGNATURE=$(echo -n "${DATE}${SALT}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $NF}')
AUTH="HMAC-SHA256 apiKey=${API_KEY}, date=${DATE}, salt=${SALT}, signature=${SIGNATURE}"
curl -X POST 'https://api.solapi.com/crm-core/v1/relationships/bulk' \
-H "Authorization: ${AUTH}" \
-H "Content-Type: application/json" \
-d '{"sourceEntityId": "CRMET1260423081530123CUS11122233", "relationshipTypeId": "CRMRT1260423091530123RTP11122233", "targetEntityId": "CRMET1260423081530124COM11122234", "targetRecordIds": ["CRMRC1260423081530124REC11122234"], "sourceFilter": {"segmentId": "CRMSG1260423081530123SGM11122233"}}'
`sourceRecordIds`와 `sourceFilter`는 둘 중 하나만 사용하면 됩니다. `sourceFilter.filters`는 `{"propertyId":{"op":"eq"|"contains","value":"..."}}` JSON 문자열입니다.
`sourceRecordIds.length × targetRecordIds.length`가 10,000건 초과 시 `400 Bad Request`가 반환됩니다. 큰 배치는 분할 호출하세요.
**401 응답**: `{ "errorCode": "Unauthorized", "errorMessage": "권한이 없습니다." }`