> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 配置 Webhooks

> 通过 Dashboard 或 API 设置 webhook 的 endpoint、触发器和投递身份验证

无论您通过何种方式设置，webhook 的配置方式都相同：一个目标 `url`、至少一个触发器，以及可选的 Yuno 向您的 endpoint 进行身份验证的方式。有关您可以选择的完整事件目录，请参阅[事件和触发器](https://docs.y.uno/zh-hans/docs/webhooks/events.md)。

webhook 的 `url` 以及（如果您使用 OAuth2）身份验证 URL 必须是可公开访问的 endpoint（OAuth2 身份验证 URL 必须使用 HTTPS）。Yuno 不会调用解析为私有或内部网络地址的 URL，包括这些范围内的 IP 地址。

> [tab] Dashboard
>
> 1. 前往 **Developers** 选项卡
> 2. 点击 **Webhook endpoints**
> 3. 点击 **Add webhook**
>
> 此时会打开一个面板，您将在其中配置：
>
> * **Name**：用于识别您的 webhook
> * **Endpoint URL**：用于接收通知的服务器 URL
> * **x-api-key**：您的 API 密钥，在通知标头中发送（通过 API 设置时为 `api_key`）
> * **x-secret**：您的密钥，在通知标头中发送（通过 API 设置时为 `secret`）
> * **Use OAuth 2.0 authentication**：用于 OAuth2 的可选复选框
> * **Use HMAC signing**：用于 HMAC 签名验证的可选复选框
> * **Trigger on**：选择哪些事件会触发此 webhook，按类别分组（Enrollment、Payment、Report、Subscription、Onboarding），每个类别都有自己的 **Select all** 链接
> * **Apply to accounts**：对于拥有多个账户的组织，选择此 webhook 适用于哪些账户。默认为当前账户。
>
> 配置完成后，每当所选事件发生时，webhook 都会发送通知。下图显示了添加 webhook 的面板。
>
> ![](https://mintcdn.com/yuno-3979e326/zLWBCWoVuqzWOeQV/images/reference/configure-webhooks/image1.png?fit=max\&auto=format\&n=zLWBCWoVuqzWOeQV\&q=85\&s=f9c86d8820d070bc0a8347143482905b)
>
> 在 [Yuno Dashboard](https://dashboard.y.uno/) 的 Developers 选项卡中，您可以使用 **Status** 切换按钮激活和停用 webhooks。

> [tab] API
>
> 将目标 `url`、唯一的 `name` 和至少一个触发器发送到[创建 Webhook](https://docs.y.uno/reference/webhooks/create-webhook.md)：
>
> ```bash cURL theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> curl -X POST 'https://api-sandbox.y.uno/v1/webhooks' \
>   -H 'public-api-key: <YOUR_PUBLIC_API_KEY>' \
>   -H 'private-secret-key: <YOUR_PRIVATE_SECRET_KEY>' \
>   -H 'Content-Type: application/json' \
>   -d '{
>     "account_id": "<ACCOUNT_ID>",
>     "name": "Order updates",
>     "url": "https://your-endpoint.example.com/yuno-webhooks",
>     "payment_triggers": ["AUTHORIZE", "PURCHASE"]
>   }'
> ```
>
> 响应中包含 `id`，您可以用它来[检索](https://docs.y.uno/reference/webhooks/retrieve-webhook.md)、[更新](https://docs.y.uno/reference/webhooks/update-webhook.md)或[删除](https://docs.y.uno/reference/webhooks/delete-webhook.md)该 webhook。有关每个字段（包括投递身份验证和错误响应），请参阅完整的 [Webhooks API 参考](https://docs.y.uno/reference/webhooks.md)。

访问 [Payloads 和示例](https://docs.y.uno/zh-hans/docs/webhooks/object-and-examples.md)页面，查看支付、注册和许多其他通知事件的示例。

### HMAC 身份验证

在 Dashboard 中勾选 **Use HMAC signing** 并填写 **Client Secret Key** 字段，或通过 API 设置 `hmac_client_secret`。无论哪种方式，Yuno 都会使用该密钥生成 HMAC-SHA256 签名，并在每次投递时通过 `x-hmac-signature` 标头发送，以便您验证 webhook 确实来自 Yuno 且未被篡改。

有关实现细节，请参阅[验证 Webhook 签名（HMAC）](https://docs.y.uno/zh-hans/docs/webhooks/verify-webhook-signatures-hmac.md)指南。

### OAuth2

在 Dashboard 中勾选 **Use OAuth 2.0 authentication**，或通过 API 设置对应的字段，以便 Yuno 获取每次投递时发送的令牌：

| Dashboard 字段 | API 字段 | 描述 |
| :- | :- | :- |
| Authentication URL | `oauth2_authentication_url` | 您的令牌 endpoint，通过 HTTPS 访问。 |
| Client ID | `oauth2_client_id` | Yuno 用于身份验证的客户端标识符。 |
| Client Secret Key | `oauth2_client_secret` | Yuno 用于身份验证的客户端密钥。 |
| Grant Type | `oauth2_grant_type` | Yuno 请求令牌时使用的授权类型，通常为 `client_credentials`。 |
| Scope (optional) | `oauth2_scope` | 要请求的 OAuth2 范围（如果您的身份验证服务需要）。 |

> [!NOTE]
>
> API 还提供 `oauth2_authorization_name`（Yuno 用于发送令牌的标头，默认为 `Authorization`）和 `oauth2_include_client_id`。这些字段目前在 Dashboard 中还没有对应项。有关完整的字段参考，请参阅 [OAuth2](https://docs.y.uno/reference/webhooks.md#oauth2)。

![](https://mintcdn.com/yuno-3979e326/zLWBCWoVuqzWOeQV/images/reference/configure-webhooks/image2.png?fit=max\&auto=format\&n=zLWBCWoVuqzWOeQV\&q=85\&s=2df23bed550fdbef86d0724083043c5e)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.