For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
预约演示登录免费开始
  • 使用 SDK
    • SDK 概述
    • SDK 如何工作
    • Quickstart
    • Customer showcase
  • 使用 SDK
    • 项目结构
    • 添加自定义代码
    • Migrating to Replay
    • 功能特性
  • 参考
      • SDK 用户特性
      • 自定义 README
      • 自定义方法名称
      • 按受众过滤端点
      • 服务器 URL 模板化
      • Webhook 签名验证
  • 资源
    • generators.yml
Checking status...
SOC2Soc 2 Type II
© 2026 Fern • Birch Solutions, Inc., a Postman company

Documentation

SDKsDocsAsk FernCLI Reference

API Definitions

OpenAPIAsyncAPIOpenRPCgRPC

Resources

BlogSupportPricing

Company

Brand KitPrivacy PolicyTerms of Service
LogoLogo
预约演示登录免费开始
在本页
  • 生成的 SDK 行为
  • 设置 webhook 签名验证
SDK 设计

Webhook 签名验证

||以 Markdown 格式查看|
此页面是否有帮助?
在仪表板中编辑
上一个

服务器 URL 模板化

下一个

配置全局头部

当你在 API 规范中定义 webhook 时,Fern 会自动生成实用工具,允许你的 SDK 用户验证 webhook 签名并确保事件来源于你的 API。

Fern 支持两种签名验证方法:

  • 基于哈希的消息认证码 (HMAC) — 使用共享密钥的对称密钥验证
  • 非对称 — 使用 RSA、椭圆曲线数字签名算法 (ECDSA) 或 Ed25519 密钥的公钥验证
Webhook 签名验证目前仅支持 TypeScript SDK 生成。

生成的 SDK 行为

生成的 SDK 公开了一个 verifyWebhookSignature 实用工具:

1import { verifyWebhookSignature } from "my-api";
2
3// In your webhook handler
4app.post("/webhooks", (req, res) => {
5 // Verify the signature using your webhook secret
6 const payload = verifyWebhookSignature(req, {
7 secret: process.env.WEBHOOK_SECRET,
8 });
9
10 // Process the verified payload
11 console.log("Received event:", payload);
12
13 res.status(200).send("OK");
14});

设置 webhook 签名验证

在你的 API 定义中配置签名验证。设置可以在文档级别应用(由所有 webhook 继承)或每个 webhook应用(覆盖文档级别的设置)。

openapi.yml
1x-fern-webhook-signature:
2 type: hmac
3 header: x-webhook-signature
4 algorithm: sha256
5 encoding: hex
6 payload-format:
7 components: [timestamp, body]
8 delimiter: "."
9 timestamp:
10 header: x-webhook-timestamp
11 format: unix-seconds
12 tolerance: 300

有关完整的配置详细信息,请参阅 OpenAPI 中的 Webhook 签名验证。