Relay 查看用量示例

查看 Webhook 傳送紀錄

curl --json @evt_1042.json https://relay.example.com/in/billing

示例方案:每月首 100,000 個事件免費。

  • {"…原始 Webhook
  • invoice.paid已識別類型的事件
  • 503 ┄┄等待重試

集中查看不同來源的事件

四項事件處理功能

示範從外部服務接收事件,再傳送至你的接收端。

讀取事件資料,識別各欄位的資料類型。

evt_1042來自 billing.example.com由 Relay 推斷

evt_1042.json

{
  "type": "invoice.paid",
  "id": "evt_1042",
  "amount": 4800,
  "currency": "GBP",
  "paid_at": "2026-10-08T09:42:16Z"
}

invoice-paid.ts

// inferred from evt_1042
export type InvoicePaid = {
  type: "invoice.paid";
  id: string;
  amount: number;
  currency: "GBP";
  paid_at: string;
};

接收端無法回應時,示例會保留 evt_1042 並重試:先收到 503,再逾時,最後收到 200 OK。

  1. 5032.1 秒後回報服務無法使用第 1 次嘗試, 09:42:18
  2. 10.0 s未有回應,已逾時第 2 次嘗試, 09:42:48
  3. 200182 毫秒內成功第 3 次嘗試, 09:43:48

從紀錄選取過往事件,示範重新傳送至接收端。

重送

invoice.paidevt_1042
事件
evt_1042, invoice.paid
接收地址
https://example.com/hooks/billing
以原有資料內容重送
  1. 09:58:14已重送 evt_1042200 OK164 ms
  2. 09:31:02已重送 evt_0987200 OK201 ms
  3. 08:12:40已重送 evt_0961200 OK176 ms
curl --json @evt_1042.json https://example.com/hooks/billing

每個來源使用獨立接收地址,再集中顯示所有 Webhook。

來源傳送至已接收的事件類型最近事件
shop.example.comrelay.example.com/in/shoporder.created order.shipped09:42:31
billing.example.comrelay.example.com/in/billinginvoice.paid refund.issued09:42:18
crm.example.comrelay.example.com/in/crmcustomer.updated contact.merged09:41:55
forms.example.comrelay.example.com/in/formsform.submitted09:39:40

四個來源均傳送至 https://example.com/hooks

每月 100,000 個免費事件示例

36,000 個事件,以每月 30 日計

未超出 100,000 個免費事件的示例額度。

在處理程式使用資料類型

接收端回傳 200 即表示傳送成功;其他回應則會觸發重試。

app/hooks/billing/route.ts你的接收端

import type { InvoicePaid } from "./invoice-paid";

export async function POST(req: Request) {
  const event = (await req.json()) as InvoicePaid;
  console.log(event.id, event.amount, event.currency);
  return new Response(null, { status: 200 });
}
這個類型檔案由示例事件 evt_1042 的資料推斷。
私隱與分析設定