본문으로 건너뛰기

Webhooks API

이벤트에 대한 알림을 받기 위해 webhooks를 구성합니다.

Webhook 목록

GET /v1/webhooks

응답:

{
"success": true,
"webhooks": [
{
"id": "wh_abc123",
"url": "https://your-server.com/webhook",
"events": ["index.complete", "security.alert"],
"active": true,
"createdAt": "2024-01-10T08:00:00Z"
}
]
}

Webhook 생성

POST /v1/webhooks

요청 본문:

{
"url": "https://your-server.com/webhook",
"events": ["index.complete", "security.alert"],
"secret": "귀하의-webhook-시크릿"
}

응답:

{
"success": true,
"webhook": {
"id": "wh_xyz789",
"url": "https://your-server.com/webhook",
"events": ["index.complete", "security.alert"],
"active": true
}
}

Webhook 삭제

DELETE /v1/webhooks/:id

사용 가능한 이벤트

이벤트설명
index.started인덱싱이 시작되었습니다
index.complete인덱싱이 성공적으로 완료되었습니다
index.failed인덱싱이 실패했습니다
security.alert새로운 보안 취약점이 발견되었습니다
analysis.complete분석이 완료되었습니다

Webhook 페이로드

모든 webhooks는 JSON 페이로드를 받습니다:

{
"event": "index.complete",
"timestamp": "2024-01-15T10:30:00Z",
"project": {
"id": "proj_abc123",
"name": "my-app"
},
"data": {
"filesCount": 234,
"symbolsCount": 1847,
"duration": 45
}
}

서명 검증

Webhooks에는 검증을 위한 서명 헤더가 포함됩니다:

X-ArchiCore-Signature: sha256=abc123...

검증 (Node.js):

const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');

return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(`sha256=${expected}`)
);
}

재시도 정책

실패한 webhook 전송은 재시도됩니다:

  • 시도 1: 즉시
  • 시도 2: 1분 후
  • 시도 3: 5분 후
  • 시도 4: 30분 후
  • 시도 5: 2시간 후

5회 실패 후 webhook은 비활성화됩니다.