Webhook
분석된 결과를 원하는 callback URL로 전달해주는 기능으로, Session API에 Create Session API에서 파라미터에 적어주면, 아래와 같은 포맷으로 분석 결과를 전달합니다.
Request
Method
POST
Header
Field | Type | Description |
---|---|---|
x-api-key | String | 데이터 업로드 또는 세션 종료 시 사용한 API Key |
x-user-id | String | 수면 세션을 생성한 user id |
Body
Field | Type | Description |
---|---|---|
event | String (INFERENCE_COMPLETE ,SESSION_COMPLETE ) | Webhook 이벤트 타입INFERENCE_COMPLETE : 5분 또는 40분 단위로 분석이 완료된 경우SESSION_COMPLETE : 전체 세션 분석이 완료된 경우 |
version | String ( V1 ,V2 ,V3 ) | Webhook 버전V1 : v1.0 문서의 webhook 포맷을 따름V2 : v2.0 문서의 webhook 포맷을 따름V3 : 현재 버전의 webhook 포맷을 따름 |
data | Webhook Data Object | 웹훅 데이터 |
INFERENCE_COMPLETE일 경우 Webhook Data Object
Field | Type | Description |
---|---|---|
user_id | String | user id |
session_id | String | session id |
seq_num | Int | 오디오 데이터 업로드 순서 번호 |
inference_seq_num | Int | seq_num을 5분 단위로 변환한 번호 예) 사운드 데이터 업로드 시 seq_num 39이면 inference_seq_num은 3 |
sleep_stages | [Int] | 직전 5분 단위의 수면 단계 결과. 가장 최근 분석된 10개의 값을 전달받음 |
snoring_stages | [Int] | 직전 5분 단위의 코골이 결과. 가장 최근 분석된 10개의 값을 전달받음 |
{
"event": "INFERENCE_COMPLETE",
"version": "V3",
"data": {
"user_id": "G-20250115025029-vLErWBfQNtnfvgDccFOQ",
"session_id": "20250115025029_fvivn",
"seq_num": 39,
"inference_seq_num": 3,
"sleep_stages": [0], // omitted
"breath_stages": null,
"snoring_stages": [0] // omitted
}
}
SESSION_COMPLETE일 경우 Webhook Data Object
Field | Type | Description |
---|---|---|
data | Sleep Data Object | Data API의 Get Session의 응답과 같은 형태 (user_id 만 추가되어 있음) |
{
"event": "SESSION_COMPLETE",
"version": "V3",
"data": {
"timezone": "UTC",
"peculiarities": ["NO_BREATHING_STABILITY"],
"missing_data_ratio": 0.0,
"user_id": "G-20250115025029-vLErWBfQNtnfvgDccFOQ",
"session": {
"id": "20250115025029_fvivn",
"state": "COMPLETE",
"start_time": "2025-01-15T02:50:29+00:00",
"end_time": "2025-01-15T03:50:29+00:00",
"unexpected_end_time": null,
"created_timezone": "UTC",
"sleep_stages": [0], // omitted
"breath_stages": null,
"snoring_stages": [0] // omitted
},
"stat": {
"sleep_time": "2025-01-15T03:05:29+00:00",
"wake_time": "2025-01-15T03:26:29+00:00",
"sleep_index": 50,
"sleep_latency": 900,
"wakeup_latency": 1440,
"light_latency": 0,
"deep_latency": null,
"rem_latency": null,
"time_in_bed": 3600,
"time_in_sleep_period": 1260,
"time_in_sleep": 1080,
"time_in_wake": 180,
"time_in_light": 1080,
"time_in_deep": 0,
"time_in_rem": 0,
"time_in_stable_breath": null,
"time_in_unstable_breath": null,
"time_in_snoring": 0,
"time_in_no_snoring": 1260,
"sleep_efficiency": 0.3,
"sleep_ratio": 0.86,
"wake_ratio": 0.14,
"light_ratio": 0.86,
"deep_ratio": 0.0,
"rem_ratio": 0.0,
"stable_breath_ratio": null,
"unstable_breath_ratio": null,
"snoring_ratio": 0.0,
"no_snoring_ratio": 1.0,
"breathing_index": null,
"breathing_pattern": null,
"waso_count": 1,
"longest_waso": 180,
"sleep_cycle_count": 0,
"sleep_cycle": null,
"sleep_cycle_time": [],
"unstable_breath_count": null,
"snoring_count": 0
}
}
}
Updated 11 days ago