Webhook 배치 내보내기
webhook 요청을 통해 이벤트를 직접 전달하는 대신, Aghanim은 일정 시간 창 동안 이벤트를 수집하고 JSONL 파일로 저장한 다음, 배치를 다운로드할 수 있는 사전 서명된 URL과 함께 batch.ready webhook 알림을 전송합니다.
작동 원리
- 웹훅을 생성하고 해당 웹훅에서 배치 모드를 활성화합니다.
- Aghanim은 일정 시간 창 동안 웹훅의 구독과 일치하는 이벤트를 수집합니다.
- 배치가 준비되면 Aghanim은 배치 파일을 다운로드할 수 있는 사전 서명된 URL과 함께 엔드포인트로 단일
batch.ready알림을 보냅니다. - URL이 만료되기 전(24시간)에 JSONL 파일을 다운로드하고 처리합니다.
배치 모드 활성화
대시보드를 통해
- Aghanim 대시보드에서 게임 → 웹훅 → 새 웹훅으로 이동합니다.
- 엔드포인트 URL을 입력하고 웹훅 시크릿을 구성합니다.
- 배치로 수신할 이벤트 유형을 선택합니다(예:
order.created,order.paid). - 배치 모드 옵션을 켭니다.
- 웹훅을 저장합니다.
API를 통해
batch_mode 매개 변수를 true로 설정하여 웹훅 생성 API 메서드를 사용합니다.
정보
다음 이벤트에서는 배치 모드를 사용할 수 없습니다:
player.verify,player.lookup,store.get— 이러한 이벤트는 서버에서 동기식 응답이 필요하며, 이는 배치 전송과 호환되지 않습니다.item.add,item.remove— 아이템 전달 지연을 방지하기 위해 이러한 이벤트는 배치로 처리하지 않아야 합니다.
배치 알림 처리
배치가 준비되면 Aghanim이 엔드포인트로 batch.ready 알림을 보냅니다. 엔드포인트는 다음을 충족해야 합니다:
- HTTPS POST 요청을 수락합니다.
- 요청 서명을 검증합니다.
- 만료되기 전(24시간)에 제공된 서명된 URL을 사용하여 배치 파일을 다운로드합니다.
- JSONL 파일을 처리합니다 — 각 줄은 별도의 JSON 이벤트 객체입니다.
- 성공적으로 처리된 경우에는 2xx 상태 코드로 응답하며, 오류의 경우에는 4xx 또는 5xx를 응답합니다.
알림 스키마
아래는 예시입니다 batch.ready 웹훅 요청:
- HTTP
- cURL
POST /your/webhook/uri HTTP/1.1
Content-Type: application/json
Host: your-webhook-endpoint.com
User-Agent: Aghanim/0.1.0
X-Aghanim-Signature: 2e45ed4dede5e09506717490655d2f78e96d4261040ef48cc623a780bda38812
X-Aghanim-Signature-Timestamp: 1725548450
{
"event_type": "batch.ready",
"event_data": {
"signed_url": "https://s2s-api.aghanim.com/v1/batch_export/download?token=eyJhb...NiIs",
"format": "jsonl",
"expires_at": 1710786400
},
"event_time": 1725548450,
"event_id": "whevt_eCacGbJVbvToOgzjXUgOCitkQE",
"idempotency_key": null,
"request_id": "d1593e9c-c291-4004-8846-6679c2e5810b",
"sandbox": false,
"transaction_id": "whtx_eCacGbJVbvT",
"context": null,
"game_id": "gm_exTAyxPsVwh"
}
curl "https://your-webhook-endpoint.com/your/webhook/uri" \
-X POST \
-H "Content-Type: application/json" \
-H "User-Agent: Aghanim/0.1.0" \
-H "X-Aghanim-Signature: 2e45ed4dede5e09506717490655d2f78e96d4261040ef48cc623a780bda38812" \
-H "X-Aghanim-Signature-Timestamp: 1725548450" \
-d '{
"event_type": "batch.ready",
"event_data": {
"signed_url": "https://s2s-api.aghanim.com/v1/batch_export/download?token=eyJhb...NiIs",
"format": "jsonl",
"expires_at": 1710786400
},
"event_time": 1725548450,
"event_id": "whevt_eCacGbJVbvToOgzjXUgOCitkQE",
"idempotency_key": null,
"request_id": "d1593e9c-c291-4004-8846-6679c2e5810b",
"sandbox": false,
"transaction_id": "whtx_eCacGbJVbvT",
"context": null,
"game_id": "gm_exTAyxPsVwh"
}'
이벤트 스키마
| Key | 유형 | 설명 |
|---|---|---|
event_id | string | Aghanim에 의해 생성된 고유 이벤트 ID. |
game_id | string | Aghanim 시스템에서의 귀하의 게임 ID. |
event_type | string | 이벤트의 유형, batch.ready 이럴 경우. |
event_time | number | 유닉스 에포크 시간으로 된 이벤트 날짜. |
event_data | EventData | 이벤트 특정 데이터가 포함되어 있으며, 상속된 객체에 대한 가능한 키가 포함됩니다. |
idempotency_key | string|null | 웹훅 작업이 재시도되어도 한 번만 실행되도록 보장합니다. 일 수 있습니다 null 이벤트 유형에 따라 달라집니다. |
request_id | string|null | 이벤트가 API 요청에 의해 트리거된 경우, 요청 ID가 포함됩니다. |
sandbox | boolean | 이 이벤트가 샌드박스 게임 환경에서 전송되었는지를 표시합니다. |
trigger | string|null | The trigger that caused the event to be sent. |
transaction_id | string | Aghanim이 생성한 거래 ID입니다. 이 ID는 동일한 거래 내에서 발생한 여러 이벤트에서 동일할 수 있습니다. |
context | EventContext|null | 이벤트에 대한 컨텍스트 정보. |
EventContext 스키마
| Key | 유형 | 설명 |
|---|---|---|
order | OrderContext|null | 해당되는 경우 이벤트와 관련된 주문 정보입니다. |
player | PlayerContext|null | 플레이어 정보를 추가하려면 웹훅 설정에서 "플레이어 컨텍스트 추가"를 활성화하세요. |
EventData 스키마
| Key | 형식 | 설명 |
|---|---|---|
signed_url | 문자열 | JSONL 파일을 다운로드하기 위한 사전 서명된 URL입니다. 24시간 후에 만료됩니다. |
format | 문자열 | 파일 형식입니다. 항상 jsonl입니다. |
expires_at | integer | 서명된 URL이 만료되는 시점의 Unix 타임스탬프. |
배치 파일 형식
각 배치 파일은 JSONL 파일입니다 — 한 줄당 하나의 JSON 이벤트입니다. 각 줄에는 구독한 이벤트 유형과 일치하는 완전한 웹훅 이벤트 객체가 포함됩니다.
예시 파일 내용:
{"event_type":"order.created","event_data":{"id":"ord_eCacpFwavzi","amount":9499,"company_id":"com_exTAxmkZQCO","country":"US","created_at":1725547595,"currency":"USD","game_id":"gm_exTAyxPsVwh","items":[{"id":"itm_exTBZQmIlDz","name":"Crystals","sku":"crystals","quantity":480000,"price":9499,"price_decimal":94.99,"currency":"USD","type":"item","nested_items":null}],"modified_at":1725547657,"player_id":"2D2R-OP3C","receipt_number":"2409051289614565","status":"created","user_id":"usr_eymySUreClx","metadata":null,"creator":null},"event_time":1725547595,"event_id":"whevt_eCacFaIUauSnNfykXTfNChtsjDE","idempotency_key":"idmpt_aXRlb...JkX2VFS","request_id":"c0482e8b-b180-3003-7735-5568b2e4710a","sandbox":false,"trigger":"checkout.purchase","transaction_id":"whtx_eCacFaIUauS","context":null,"game_id":"gm_exTAyxPsVwh"}
{"event_type":"order.paid","event_data":{"id":"ord_eCacpFwavzi","amount":9499,"company_id":"com_exTAxmkZQCO","country":"US","created_at":1725547595,"currency":"USD","game_id":"gm_exTAyxPsVwh","revenue_usd":9099.123,"fees":{"aghanim_fee_usd":10.11,"payment_system_fee_usd":15.123,"taxes_usd":481.198933},"items":[{"id":"itm_exTBZQmIlDz","name":"Crystals","sku":"crystals","quantity":480000,"price":9499,"price_decimal":94.99,"currency":"USD","type":"item","nested_items":null}],"modified_at":1725547657,"player_id":"2D2R-OP3C","receipt_number":"2409051289614565","status":"paid","user_id":"usr_eymySUreClx","metadata":null,"creator":null},"event_time":1725548450,"event_id":"whevt_eCacGbJVbvToOgzjXUgOCitkQE","idempotency_key":"idmpt_aXRlb...JkX2VFS","request_id":"d1593e9c-c291-4004-8846-6679c2e5810b","sandbox":false,"trigger":"checkout.purchase","transaction_id":"whtx_eCacGbJVbvT","context":null,"game_id":"gm_exTAyxPsVwh"}
도움이 필요하세요?
통합팀에 문의하십시오 [email protected]