S2S Event API
Follow
S2S Event API
Upload events using Server To Server method
This is an API for uploading events that cannot be collected through the SDK.
Basic Information
| Method | URL | Authentication Method |
| POST | https://openapi.dfinery.io/api/v1/events | Access Token |
Headers
| Key | Value |
| Authorization | Bearer ${API Token} |
| Content-Type | application/json |
Body
- Parameter
| Name | Type | Description | Required |
| event_attributes | EventAttributes | Event Attributes | O |
| user_attributes | UserAttributes | User Attributes | O |
- EventAttributes
| Name | Type | Description | Required |
| event_id | String | Event Identification ID* | O |
| event_name | String | Event Name | O |
| event_datetime | Long | Event occurrence time | O |
| order_id | String | Order ID | X |
| order_sales | Double | Orderer (Total Amount) | X |
| payment_method | String | Payment Method | X |
| discount | Double | Discount price | X |
| items | List | Item List | X |
* event_id : Write in uuid format ( https://docs.python.org/ko/3/library/uuid.html )
- ItemAttributes
| Name | Type | Description | Required |
| product_id | String | Product Identification ID | X |
| product_name | String | Product Name | X |
| category1 | String | Product Category 1 | X |
| category2 | String | Product Category 2 | X |
| category3 | String | Product Category 3 | X |
| category4 | String | Product Category 4 | X |
| category5 | String | Product Category 5 | X |
| quantity | Long | Product Quantity | X |
| price | Double | Product Amount | X |
| discount | Double | Product discount price | X |
| coupon_id | String | Coupon ID | X |
- UserAttributes
| Name | Type | Description | Required |
| user_id | String | User identifier | O |
| user_name | String |
User Name |
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": "Back to School Discount",
"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": "Back to School Discount",
"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": "Hong Gil-dong"
}
}
Precautions
- Events that are not predefined are handled as custom events, and the events currently predefined and supported by the DFINERY S2S Event API are as follows.( Link )
2. Event Attributes
- Event properties that are not predefined are processed as custom fields, and the event properties currently predefined in the DFINERY S2S Event API are as follows.( Link )
- Examples of handling predefined fields and custom fields are as follows.
discount -> abx:discount
source_type -> c:source_type
3. User Attributes
- User properties that are not predefined are treated as custom fields, and the event properties currently predefined in the DFINERY S2S Event API are as follows.( Link )
- Examples of handling predefined fields and custom fields are as follows.
user_id -> abx:user_id
user_name -> c:user_name
- Some fields are forcibly typecast to the defined type.The list of some fields is as follows.
user_id (string)
event_datetime (datetime)
event_id (string)
event_name (string)
- Other items are automatically converted to the following data types.Please note that if you add a value of a different type to the same field name, it will be treated as a different field in the DFINERY console report.
1. Double => 0.0
2. Long => 0
3. Boolean => False
4. String => ""
* Integer is treated as Long.
- There is no limit to the number of sub-parameters for items, but they should be well-designed from an analysis perspective.
- All event times are processed in UTC.
- Only data within a maximum of 48 hours is processed.
Response Example
- Update successful
HTTP/1.1 200 OK
{
"result_code": 2000,
"result_msg": null,
"result_data": {
"event_id": "0166a71c-caf4-462d-8201-9c30sd3fg54"
}
}
- Update failed
1.If there is no API token or authentication fails
HTTP/1.1 401 Unauthorized
2. In case of an invalid token
HTTP/1.1 400 BadRequest
{
"result_code": 4001,
"result_msg": "Invalid API Token Error.",
"result_data": null
}
3. In case of an incorrect request format
HTTP/1.1 400 BadRequest
{
"result_code": 4002,
"result_msg": "Invalid request format.",
"result_data": null
}
4. If required values are not filled
HTTP/1.1 400 BadRequest
{
"result_code": 4002,
"result_msg": "Required parameters cannot be empty.",
"result_data": null
}
5. If the data type of the call argument is not appropriate: Check the request parameters.
HTTP/1.1 400 BadRequest
{
"result_code": 4002,
"result_msg": "{eventAttribute / eventItemAttribute / userAttribute} contains unsupported value type.",
"result_data": null
}
6. When the rate limit is exceeded
HTTP/1.1 429 TooManyRequests
{
"result_code": 4006,
"result_msg": "API RateLimit exceeded.",
"result_data": null
}
7. When an unsupported property name or value type is used
HTTP/1.1 400 BadRequest
{
"result_code": 4007,
"result_msg": "Contains unsupported property {name or value}.",
"result_data": null
}
8. If the type of Event Datetime is incorrect
HTTP/1.1 400 BadRequest
{
"result_code": 4002,
"result_msg": "Invalid event datetime format.",
"result_data": null
}
9.In case of an internal server error
HTTP/1.1 500 InternalServerError
{
"result_code": 5001,
"result_msg": "Invalid API Token Error.",
"result_data": null
}