---
title: "创建 webhook"
description: "让另一个系统代表员工提交表单：为表单添加 webhook，选择用哪个 HRIS id 识别员工，一次性生成密钥，并查看到达内容的日志。"
sidebar:
  order: 2
area: flows
feature: forms
appPath: /flows/home
lastVerified: 2026-11-15
version: "2026-10-30"
audience: admin
screenshots:
  - id: flows-forms-webhook-drawer
    caption: 表单上的 Settings 侧面板，带 webhook 的 URL、请求头、主体和示例请求体。
related:
  - flows/forms/reference-webhook-api
  - flows/forms/build-a-form
  - notices
intercom:
  - id: "16858360"
    title: Create a Webhook (Pyn 2)
    url: https://intercom.help/pyn/en/articles/16858360-create-a-webhook-pyn-2
    note: replaces
translation:
  source: flows/forms/create-a-webhook.mdx
  sourceSha: 88dd3263f023bcd0343ab040ded33eaba8203476
---

有些答案已经存在于另一个系统中：LMS 中完成的培训、工单工具中的设备申请、一份签署的文件。表单上的 webhook 让那个系统把答案作为一次提交发送到 Pyn，记录在它指定的员工名下。

## 开始之前

- 你是 Admin。
- 表单已构建并发布，字段标签是你的另一个系统能够映射的。见[构建表单](https://support.pyn.ai/zh-cn/flows/forms/build-a-form/)。
- 另一个系统能够发送每位员工在你 HRIS 中的 id，也就是 Pyn 从该集成获得的同一个 id。

![表单上的 Settings 侧面板，带 webhook 的 URL、请求头、主体和示例请求体。](https://support.pyn.ai/media/flows/forms/flows-forms-webhook-drawer.png)

## 步骤

1. 在 Pyn 中，打开左侧导航中的 **Flows**，选择 **Forms**，然后选择表单。

2. 选择编辑器右侧栏上的 **Settings**。侧面板显示 **Add a webhook to let another system submit this form on an employee's behalf.**。选择 **Add Webhook**。如果无法添加 webhook，会有一条提示显示 **Could not add this webhook**，侧面板保持原样。

3. 在侧面板顶部，提示框显示 **This webhook accepts nothing until it has a secret.**。选择 **Create Secret**；提示框随后显示 **Copy this secret now. It is shown once and cannot be retrieved later.**。把它复制到另一个系统中，然后选择 **Done**。如果无法生成密钥，会有一条提示显示 **Could not create the secret**，提示框保持原样。已经有密钥的 webhook 显示 **This webhook already has a secret. Replace it if the old one has been lost.**，并改为提供 **Replace Secret**；见下文。

4. 在提示框下方，复制 **URL** 并记下请求头：`Authorization: Bearer <secret>`。

5. 在 **Subject** 下，选择另一个系统将发送其 id 的来源系统，例如 **BambooHR Employee ID** 或 **Workday Worker ID**。说明文字是 **The submission is recorded against the employee holding this id.**。

6. 阅读 **Post a body of this shape.** 下的示例。它用别名（驼峰形式的标签）命名每个字段并给出示例值，外加 `subject_id`。

7. 从另一个系统发送一个测试负载，并阅读侧面板底部的日志（**Payloads this webhook has taken, and what became of them.**）。绿色条目显示 **Recorded a submission for the ... identifier ...**；红色条目说明问题所在。

> **Caution:** 丢失的密钥无法找回。选择 **Replace Secret** 生成一个新的；**Replace Webhook Secret** 对话框警告 **The current secret stops working immediately. Anything calling this webhook will need the new one.**，**Replace** 确认操作。如果无法替换密钥，会有一条提示显示 **Could not replace the secret**，旧密钥继续有效。

## 轮换密钥和阅读日志

- **Replace Secret** 一步完成密钥轮换，旧密钥立即失效；确认之前先更新调用方系统。
- 日志显示最近的 20 条记录。一旦有了记录，它旁边的导出图标会把整个日志下载为 `pyn-webhook-log.csv`（`receivedAt`、`outcome`、`action`、`code`、`message`、`eventId`、`subjectId`、`submissionId`）。
- 被丢弃的负载还会在[通知](https://support.pyn.ai/zh-cn/notices/)中生成一条通知，而且同一个错误反复出现只会保持一条通知而不是许多条；它的那一行提供 **Acknowledge**，然后是 **Archive**。工作区的通知设置决定是给每位 admin 发邮件还是只给 owner。

## 你应该看到什么

被接受的负载作为提交出现在表单的 **Activity** 侧面板中，员工的记录带有任何 Buddy 或 Mentor 值。每位员工对每个 webhook 只能被提交一次；重复会被记录为 `already-submitted`。[Webhook API](https://support.pyn.ai/zh-cn/flows/forms/reference-webhook-api/) 列出端点、请求头、请求体、响应和每一个日志代码。

## 相关

- [Webhook API](https://support.pyn.ai/zh-cn/flows/forms/reference-webhook-api/)，了解确切的请求和响应。
- [构建表单](https://support.pyn.ai/zh-cn/flows/forms/build-a-form/)，了解负载填写的字段。
- [通知](https://support.pyn.ai/zh-cn/notices/)，了解失败在哪里显示。
