メインコンテンツまでスキップ

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 は無効化されます。