본문으로 건너뛰기

웹훅 API

📌 웹훅 자체의 등록/관리는 콘솔에서 수행합니다. SDK 와 X-Public-Key 로 호출 가능한 webhook 엔드포인트는 현재 제공되지 않습니다. 모든 webhook 관리 API 는 콘솔 사용자 JWT 인증이 필요합니다.

웹훅 관리 (콘솔 JWT)

POST    /v1/apps/:appID/webhooks
GET     /v1/apps/:appID/webhooks
GET     /v1/apps/:appID/webhooks/:webhookID
PUT     /v1/apps/:appID/webhooks/:webhookID
DELETE  /v1/apps/:appID/webhooks/:webhookID
POST    /v1/apps/:appID/webhooks/:webhookID/regenerate-secret
GET     /v1/apps/:appID/webhooks/:webhookID/logs
POST    /v1/apps/:appID/webhooks/:webhookID/test

외부 서비스 → Connect Base 웹훅 (수신)

Stripe, GitHub 등 외부 서비스의 웹훅을 수신하려면:

  1. 콘솔의 워크플로우 메뉴에서 HTTP 트리거 가 있는 워크플로우 생성
  2. 워크플로우가 발급한 트리거 URL 을 외부 서비스의 웹훅 URL 란에 등록
  3. 워크플로우 첫 함수 스텝에서 서명 검증 로직 추가

서명 검증 예시 (Stripe — 함수 스텝 코드):

javascript
import crypto from 'crypto'

export default async function handler(rawBody, ctx) {
  // 헤더/메서드는 두 번째 인자 ctx 에 있습니다 (ctx.headers, ctx.method)
  const signature = ctx.headers['stripe-signature']
  const expected = crypto
    .createHmac('sha256', ctx.env.STRIPE_WEBHOOK_SECRET)
    .update(ctx.rawBody)  // 서명용 원본 bytes
    .digest('hex')

  if (signature !== expected) {
    return { error: 'Invalid signature', status: 401 }
  }

  // 검증된 본문 처리 — 첫 인자 rawBody 는 본문 문자열
  const event = JSON.parse(rawBody)
  return { ok: true }
}