API
Webhooks
DisHost 이벤트를 웹훅으로 외부 서비스에 전달하는 방법
DisHost에서 발생하는 이벤트를 외부 서비스로 전달할 수 있습니다. Discord 알림, Slack 메시지, CI 트리거에 활용하세요.
지원 이벤트
| 이벤트 | 설명 | Payload |
|---|---|---|
deploy.completed | 배포 완료 | { botId, botName, commitSha, commitMsg, branch, durationMs } |
server.crashed | 서버 크래시 | { botId, botName, lastLog, timestamp } |
backup.completed | 백업 완료 | { botId, botName, backupId, sizeBytes, timestamp } |
구독
API
curl -X POST https://api.dishost.kr/api/v1/webhooks/subscriptions \
-H "x-api-key: dsh_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"url": "https://my-server.com/webhook",
"events": ["deploy.completed", "server.crashed"],
"secret": "my-signature-secret"
}'구독 목록
curl -H "x-api-key: dsh_live_xxx" \
https://api.dishost.kr/api/v1/webhooks/subscriptions구독 해제
curl -X DELETE \
-H "x-api-key: dsh_live_xxx" \
https://api.dishost.kr/api/v1/webhooks/subscriptions/{id}시그니처 검증
모든 Webhook 요청에는 X-Dishost-Signature 헤더가 포함됩니다.
const crypto = require("crypto");
function verifySignature(payload, signature, secret) {
const hmac = crypto.createHmac("sha256", secret);
const expected = "sha256=" + hmac.update(payload).digest("hex");
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}재시도
- 배달 실패 시 최대 3회 재시도 (1s → 5s → 25s)
- 10회 연속 실패 시 Webhook 자동 비활성화