> ## 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.

# 身份验证

> 介绍用于验证和保护 Yuno API 请求的 API 密钥标头和幂等键

Yuno API 使用 ApiKey 安全方案对 HTTP 请求进行身份验证。API 密钥是由字母和数字组成的凭证，用于授予对特定 API 功能的访问权限。

所有请求都需要 `public-api-key` 和 `private-secret-key` 标头。您可以在 [Yuno Dashboard](https://dashboard.y.uno/developers) 中找到它们。

> [!CAUTION]
>
> 请勿在 GitHub 或 Bitbucket 等公开位置分享您的私有 API 密钥，以免遭到恶意 API 调用。

有时可能需要 `X-Idempotency-Key`。此 UUID 对每个请求都必须唯一。详情请参阅[幂等性](https://docs.y.uno/zh-hans/reference/getting-started/authentication.md#idempotency)。

**请求示例**：

```sh theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request <Method> \
     --url <URL> \
     --header 'X-Idempotency-Key: 7bf41af5-70ae-4e79-9b28-a8fa75c3ac53' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'private-secret-key: <Your private-secret-key>' \
     --header 'public-api-key: <Your public-api-key>'
```

## 幂等性

当请求结果不明确时（例如超时、连接错误或 `500` 响应），幂等性让您可以安全地重试请求。它消除了同一操作被执行两次的风险。

部分请求会包含一个作为 `X-Idempotency-Key` 标头发送的唯一标识符（例如 `7bf41af5-70ae-4e79-9b28-a8fa75c3ac53`）。此键还用于标识特定交易。

> [!NOTE]
>
> 将 `X-Idempotency-Key` 的值设置为 `{$randomUUID}`，即可自动生成键。

重复使用 `X-Idempotency-Key` 会产生以下结果之一：

* **原始响应。** 如果使用此键的第一个请求创建了支付（无论其状态是已批准、已授权还是已拒绝），之后使用相同键的任何请求都会返回该原始支付，而不会创建新支付。重试请求的正文会被忽略。
* **`400 REQUEST_IN_PROCESS`。** 使用此键的第一个请求仍在处理中。请在几秒后使用相同的键重试。
* **`400 IDEMPOTENCY_DUPLICATED`。** 使用此键的第一个请求在创建支付之前就失败了。此键下不存在任何支付，且该键不能再次使用：请修正请求，并使用新键发送。
* **正常处理。** 如果第一个请求在开始处理之前就被拒绝（例如正文格式错误），则该键未被消耗，重试请求将作为新请求处理。

### 推荐的重试逻辑

1. 如果请求失败且结果不明确（超时、连接错误、`500`，或无法解析的响应），请**使用相同的键**重试。重试要么返回原始结果，要么正常处理，要么返回 `IDEMPOTENCY_DUPLICATED`，表示未创建任何支付。
2. 仅在开始真正的新尝试时使用**新键**：新订单，或在被拒绝之后、收到 `IDEMPOTENCY_DUPLICATED` 之后的新尝试。
3. 切勿使用新键重试结果不明确的失败请求。如果原始请求实际上已经成功，使用新键重试会造成重复操作。


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