{"…原始 Webhookinvoice.paid已識別類型的事件503 ┄┄等待重試
集中查看不同來源的事件
四項事件處理功能
示範從外部服務接收事件,再傳送至你的接收端。
讀取事件資料,識別各欄位的資料類型。
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。
- 5032.1 秒後回報服務無法使用
第 1 次嘗試, 09:42:18 - 10.0 s未有回應,已逾時
第 2 次嘗試, 09:42:48 - 200182 毫秒內成功
第 3 次嘗試, 09:43:48
從紀錄選取過往事件,示範重新傳送至接收端。
重送
invoice.paidevt_1042- 事件
evt_1042, invoice.paid- 接收地址
https://example.com/hooks/billing
以原有資料內容重送
09:58:14已重送evt_1042200 OK164 ms09:31:02已重送evt_0987200 OK201 ms08:12:40已重送evt_0961200 OK176 ms
curl --json @evt_1042.json https://example.com/hooks/billing
每個來源使用獨立接收地址,再集中顯示所有 Webhook。
| 來源 | 傳送至 | 已接收的事件類型 | 最近事件 |
|---|---|---|---|
| shop.example.com | relay.example.com/in/shop | order.created order.shipped | 09:42:31 |
| billing.example.com | relay.example.com/in/billing | invoice.paid refund.issued | 09:42:18 |
| crm.example.com | relay.example.com/in/crm | customer.updated contact.merged | 09:41:55 |
| forms.example.com | relay.example.com/in/forms | form.submitted | 09:39:40 |
四個來源均傳送至 https://example.com/hooks
每月 100,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 的資料推斷。