Webhook은 특정 event 발생 시 Zonos가 external system에 proactive하게 알리는 방법입니다. subscribe한 event가 발생하면 Zonos가 지정한 webhook URL로 HTTP POST request를 보냅니다. request body에 event 상세가 포함되어 system이 programmatically 처리할 수 있습니다.
Webhook은 Zonos를 다른 platform과 통합하고, automated workflow를 trigger하며, system 간 data를 real-time으로 sync하는 데 유용합니다. 예:
Zonos에서 order가 생성되면 order management system을 업데이트
shipment이 canceled되면 fulfillment provider에 알림
auditing을 위해 international order status change를 log
Webhooks
Webhook으로 event 수신
Zonos 통합에 대한 real-time event notification을 받습니다.
Webhook은 특정 event 발생 시 Zonos가 external system에 proactive하게 알리는 방법입니다. subscribe한 event가 발생하면 Zonos가 지정한 webhook URL로 HTTP POST request를 보냅니다. request body에 event 상세가 포함되어 system이 programmatically 처리할 수 있습니다.
Webhook은 Zonos를 다른 platform과 통합하고, automated workflow를 trigger하며, system 간 data를 real-time으로 sync하는 데 유용합니다. 예:
Webhook type
사용 가능한 모든 webhook type은
WebhookTypeenum에 포함됩니다. 각 example payload는 Event Types guide에서 확인할 수 있습니다.Webhook 생성
API로 webhook을 생성하려면:
mutation WebhookCreate($input: WebhookCreateInput!) {webhookCreate(input: $input) {idurltypestatussecretheaders {key}}}Webhook 상세 편집
API로 기존 webhook을 편집하려면:
mutation WebhookUpdate($input: WebhookUpdateInput!) {webhookUpdate(input: $input) {idurltypestatus}}Webhook signature 검증
Zonos가 보내는 모든 webhook request에는
zonos-signatureheader가 포함되어 있어, 해당 request가 실제로 Zonos에서 온 것인지, 그리고 전송 중에 payload가 변조되지 않았는지 확인할 수 있습니다.header 값의 형식은 다음과 같습니다:
timestamp— request가 서명된 시각으로, Unix epoch milliseconds 단위입니다.hmac— raw JSON request body에 대한 HMAC-SHA256 서명으로, webhook의 secret을 key로 사용해 계산한 후 Base64로 encoding한 값입니다.request를 검증하려면:
zonos-signatureheader에서timestamp와hmac값을 parse합니다.hmac값과 constant-time comparison으로 비교하고, 일치하지 않으면 request를 거부합니다.timestamp가 몇 분 이상 지난 request는 거부하여, 캡처된 request의 재전송(replay)을 방지할 수 있습니다. Zonos는 자체적으로 delivery window를 강제하지 않으므로, 이 확인은 사용자가 직접 구현해야 합니다.const crypto = require('crypto');function verifyZonosWebhook(rawBody, signatureHeader, secret) {const [timestampPart, hmacPart] = signatureHeader.split(',');const receivedHmac = hmacPart.split('=')[1];const expectedHmac = crypto.createHmac('sha256', secret).update(rawBody).digest('base64');const receivedBuffer = Buffer.from(receivedHmac);const expectedBuffer = Buffer.from(expectedHmac);if (receivedBuffer.length !== expectedBuffer.length) {return false;}return crypto.timingSafeEqual(receivedBuffer, expectedBuffer);}Webhook log 조회
API로 webhook log를 조회하려면:
query WebhookLogs($first: Int$after: String$filter: WebhookLogsFilterInput) {webhookLogs(first: $first, after: $after, filter: $filter) {edges {node {idtypeurlcreatedAtresponseStatus}}}}WebhookCreateInput WebhookLogsFilterInput WebhookUpdateInput
webhookCreate webhookUpdate
이 페이지가 도움이 되었나요?