S2S Event API
팔로우
S2S Event API
Server To Server 방식으로 이벤트 업로드하기
SDK를 통해 수집할 수 없는 이벤트를 업로드하기 위한 API 입니다.
기본 정보
메서드 | URL | 인증 방식 |
POST | https://openapi.dfinery.io/api/v1/events | 액세스 토큰 |
Headers
Key | Value |
Authorization | Bearer ${API Token} |
Content-Type | application/json |
Body
- Parameter
Name | Type | Description | Required |
event_attributes | EventAttributes | 이벤트 속성 | O |
user_attributes | UserAttributes | 유저 속성 | O |
- EventAttributes
Name | Type | Description | Required |
event_id | String | 이벤트 식별 ID* | O |
event_name | String | 이벤트명 | O |
event_datetime | Long | 이벤트 발생 시각 | O |
order_id | String | 주문 ID | X |
order_sales | Double | 주문가(총액) | X |
payment_method | String | 결제 방법 | X |
discount | Double | 할인가 | X |
items | List<ItemAttributes> | 아이템 리스트 | X |
* event_id : uuid 형식으로 작성 (https://docs.python.org/ko/3/library/uuid.html)
- ItemAttributes
Name | Type | Description | Required |
product_id | String | 상품 식별 ID | X |
product_name | String | 상품명 | X |
category1 | String | 상품 카테고리 1 | X |
category2 | String | 상품 카테고리 2 | X |
category3 | String | 상품 카테고리 3 | X |
category4 | String | 상품 카테고리 4 | X |
category5 | String | 상품 카테고리 5 | X |
quantity | Long | 상품 수량 | X |
price | Double | 상품 금액 | X |
discount | Double | 상품 할인가 | X |
coupon_id | String | 쿠폰 ID | X |
- UserAttributes
Name | Type | Description | Required |
user_id | String | 유저 식별값 | O |
user_name | String |
유저 이름 |
X |
Example
{
"event_attributes": {
"event_id": "0166a71c-caf4-462d-8201-9c30c40f2354",
"event_name": "purchase",
"event_datetime": 1685672905000,
"order_id": "123456789",
"order_sales": 4000000.0,
"payment_method": "MobilePayment",
"discount": 11.0,
"items": [
{
"product_id": "123456789",
"product_name": "Macbook Air 13",
"category1": "Macbook Air",
"quantity": 1,
"price": 1900000.0,
"discount": 200000.0,
"coupon_id": "asdf1234asdf342",
"product_processor": "m1",
"product_memory": "16g",
"product_ssd": "256g",
"product_adaptor": "35W",
"trade_in_device": "iphone14",
"trade_in_serial_num": "12312313",
"coupon_name": "새학기 할인",
"coupon_discount_type": "per",
"coupon_discount_amount": "11",
"coupon_expired_date": "2024-01-01"
},
{
"product_id": "23432424",
"product_name": "Macbook Pro 13'",
"category1": "Macbook Pro",
"quantity": 1,
"price": 4000000.0,
"discount": 300000.0,
"coupon_id": "asdf1234asdf342",
"product_processor": "m2 pro",
"product_memory": "64g",
"product_ssd": "1tb",
"product_adaptor": "96W",
"trade_in_device": "Macbook Air 13'",
"trade_in_serial_num": 12313131,
"coupon_name": "새학기 할인",
"coupon_discount_type": "per",
"coupon_discount_amount": "11",
"coupon_expired_date": "2024-01-01"
}
],
"source_type": "POS",
"region_type": "tokyo",
"use_applepay": true,
"register_applepay": true
},
"user_attributes": {
"user_id": "user1",
"user_name": "홍길동"
}
}
유의사항
1. 이벤트명
- 미리 정의되지 않은 이벤트는 커스텀 이벤트로 처리되며, 현재 디파이너리 S2S Event API 에서 미리 정의 및 지원하는 이벤트는 다음과 같습니다. (링크)
2. 이벤트 속성
- 미리 정의되지 않은 이벤트 속성들은 커스텀 필드로 처리되며, 현재 디파이너리 S2S Event API 에서 미리 정의한 이벤트 속성은 다음과 같습니다. (링크)
- 미리 정의된 필드와 커스텀 필드 처리 예시는 다음과 같습니다.
discount -> abx:discount
source_type -> c:source_type
3. 유저 속성
- 미리 정의되지 않은 유저 속성들은 커스텀 필드로 처리되며, 현재 디파이너리 S2S Event API 에서 미리 정의한 이벤트 속성은 다음과 같습니다. (링크)
- 미리 정의된 필드와 커스텀 필드 처리 예시는 다음과 같습니다.
user_id -> abx:user_id
user_name -> c:user_name
4. Value Type
- 일부 필드는 정의된 타입대로 강제 타입 캐스팅 됩니다. 일부 필드 목록은 다음과 같습니다.
user_id (string)
event_datetime (datetime)
event_id (string)
event_name (string)
- 이외 항목들은 아래와 같은 자료형으로 자동 변환됩니다. 만약 동일 필드명에 다른 타입으로 값을 올려주면 디파이너리 콘솔 리포트에서 다른 필드로 취급되니 유의 바랍니다.
1. Double => 0.0
2. Long => 0
3. Boolean => False
4. String => ""
* Integer는 Long으로 취급합니다.
5. 기타 분석 관점
- 아이템 하위 파라미터 개수에 제한은 없지만 분석 관점에서 잘 설계하여야 합니다.
- 모든 이벤트의 시간대는 UTC 기준으로 처리됩니다.
- 최대 48시간 이내 데이터만 처리됩니다.
Response Example
- 업데이트 성공
HTTP/1.1 200 OK { "result_code": 2000, "result_msg": null, "result_data": { "event_id": "0166a71c-caf4-462d-8201-9c30sd3fg54" } }
- 업데이트 실패
1. API 토큰이 없거나 인증에 실패한 경우
HTTP/1.1 401 Unauthorized
2. 잘못된 토큰인 경우
HTTP/1.1 400 BadRequest { "result_code": 4001, "result_msg": "Invalid API Token Error.", "result_data": null }
3. 요청 형식이 잘못된 경우
HTTP/1.1 400 BadRequest { "result_code": 4002, "result_msg": "Invalid request format.", "result_data": null }
4. 필수값들이 채워지지 않은 경우
HTTP/1.1 400 BadRequest { "result_code": 4002, "result_msg": "Required parameters cannot be empty.", "result_data": null }
5. 호출 인자값의 데이터 타입이 적절하지 않은 경우 : 요청 파라미터 확인
HTTP/1.1 400 BadRequest { "result_code": 4002, "result_msg": "{eventAttribute / eventItemAttribute / userAttribute} contains unsupported value type.", "result_data": null }
6. Rate Limit이 초과된 경우
HTTP/1.1 429 TooManyRequests { "result_code": 4006, "result_msg": "API RateLimit exceeded.", "result_data": null }
7. 지원하지 않는 프로퍼티명이나 값타입을 사용한 경우
HTTP/1.1 400 BadRequest { "result_code": 4007, "result_msg": "Contains unsupported property {name or value}.", "result_data": null }
8. Event Datetime의 타입이 잘못된 경우
HTTP/1.1 400 BadRequest { "result_code": 4002, "result_msg": "Invalid event datetime format.", "result_data": null }
9. 서버 내부 에러인 경우
HTTP/1.1 500 InternalServerError { "result_code": 5001, "result_msg": "Invalid API Token Error.", "result_data": null }