Webhooks
웹훅을 사용하면 inlink에서 발생하는 이벤트를 실시간으로 수신할 수 있습니다.
동작 방식
- 웹훅 URL과 수신할 이벤트를 등록
- 이벤트 발생 시 등록된 URL로 POST 요청 전송
- 서명을 검증하고 이벤트를 처리
페이로드 형식
POST /your-webhook-endpoint HTTP/1.1
Content-Type: application/json
X-Webhook-Event: campaign.created
X-Webhook-Timestamp: 2026-03-26T10:00:00Z
X-Webhook-Signature: sha256=xxxxxxxxxxxxxxxx
{
"event": "campaign.created",
"timestamp": "2026-03-26T10:00:00Z",
"data": {
"id": "camp_abc123",
"title": "신제품 리뷰 캠페인",
"status": "active",
"budget_max": 200000
}
}서명 검증 (Node.js)
import crypto from 'crypto';
function verifyWebhook(body, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(body)
.digest('hex');
return signature === `sha256=${expected}`;
}
// Express 예시
app.post('/webhook', (req, res) => {
const signature = req.headers['x-webhook-signature'];
if (!verifyWebhook(JSON.stringify(req.body), signature, SECRET)) {
return res.status(401).send('Invalid signature');
}
// 이벤트 처리
console.log(req.body.event, req.body.data);
res.status(200).send('OK');
});재시도 정책
- 5xx 에러 또는 타임아웃 시 최대 3회 재시도
- 재시도 간격: 30초, 5분, 30분
- 10초 타임아웃
- 3회 연속 실패 시 웹훅 자동 비활성화