관계 유형 생성
POST/crm-core/v1/relationships/types
두 개체 사이에 생성할 수 있는 관계의 스키마를 정의한다. 관계 유형에는 소스/대상 개체와 양방향 레이블(예: 직원 ↔ 회사)을 지정한다. 생성된 유형은 이후 실제 관계(Relationship) 인스턴스를 만들 때 사용된다. 권한 요구: MEMBER 이상.
Body Params
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | 관계 유형 이름. 예: 소속사 | |
| sourceEntityId | string | 소스 개체 ID | |
| targetEntityId | string | 대상 개체 ID | |
| sourceLabel | string | 소스 레코드 쪽에서 본 상대 호칭. 예: 직원이 회사를 가리킬 때 소속 회사 | |
| targetLabel | string | 대상 레코드 쪽에서 본 상대 호칭. 예: 회사가 직원을 가리킬 때 직원 | |
| description | string | 관계 유형 설명 |
Response
| Name | Type | Required | Description |
|---|---|---|---|
| relationshipTypeId | string | 생성된 관계 유형 ID | |
| accountId | string | 계정 ID | |
| workspaceId | string | 워크스페이스 ID | |
| name | string | 관계 유형 이름 | |
| description | string | 설명 | |
| sourceEntityId | string | 소스 개체 ID | |
| targetEntityId | string | 대상 개체 ID | |
| sourceLabel | string | 소스 방향 레이블 | |
| targetLabel | string | 대상 방향 레이블 | |
| dateCreated | date | 생성 시각 | |
| dateUpdated | date | 마지막 수정 시각 |
Structure
코드 예제
const response = await fetch('https://api.solapi.com/crm-core/v1/relationships/types', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + TOKEN,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: '소속사',
sourceEntityId: 'CRMET1260423081530123XYZ11122233',
targetEntityId: 'CRMET1260423081530124XYZ11122234',
sourceLabel: '소속 회사',
targetLabel: '직원'
})
});
const data = await response.json();
import requests
response = requests.post(
'https://api.solapi.com/crm-core/v1/relationships/types',
headers={'Authorization': f'Bearer {TOKEN}'},
json={
'name': '소속사',
'sourceEntityId': 'CRMET1260423081530123XYZ11122233',
'targetEntityId': 'CRMET1260423081530124XYZ11122234',
'sourceLabel': '소속 회사',
'targetLabel': '직원'
}
)
data = response.json()
curl -X POST 'https://api.solapi.com/crm-core/v1/relationships/types' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"name":"소속사","sourceEntityId":"CRMET1260423081530123XYZ11122233","targetEntityId":"CRMET1260423081530124XYZ11122234","sourceLabel":"소속 회사","targetLabel":"직원"}'
관계는 `sourceEntityId → targetEntityId` 방향으로 정의된다. 자기 참조(같은 개체끼리) 관계도 허용되며, 이 경우 sourceLabel/targetLabel로 양쪽 역할을 구분하는 것을 권장한다 (예: 상위 조직/하위 조직).
동일 계정 내 중복된 관계 유형이 감지되면 `409 Conflict`가 반환된다. 카디널리티(1:1, 1:N, N:M)는 관계 유형 자체에 저장되지 않고, 실제 관계 인스턴스의 운용 방식으로 제어된다.