> ## 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 的 PCI DSS Level 1 环境，使用真实卡数据调用任意第三方 HTTPS API，并通过 vaulted_token 引用已存储的卡。

将您的请求转发到 `yuno-proxy-destination-url` 标头中的目标地址，并在 Yuno 的安全环境中将 `{{vaulted_token.<TOKEN>.<field>}}` 表达式替换为该存储令牌下存储的数据：卡片（PAN、有效期、持卡人姓名）、其网络令牌（DPAN 及其有效期），以及其网络交易 ID（NTID）。对于需要 HMAC 签名请求的目标地址，请发送 `yuno-proxy-auth` + `yuno-proxy-auth-secret-key`，代理会为您对解析后的请求体进行签名。详情请参阅[签名目标地址](https://docs.y.uno/zh-hans/docs/security-and-compliance/pci-proxy/forward-proxy.md#signed-destinations-hmac-request-signing)。分步集成说明请参阅 [Forward Proxy 指南](https://docs.y.uno/zh-hans/docs/security-and-compliance/pci-proxy/forward-proxy.md)。

> [!NOTE]
>
> **Beta**
>
> PCI Proxy 处于 Beta 阶段，按组织启用。在生产环境中，您的组织激活之前，请求会返回 `403 PRODUCT_NOT_ENABLED`；请联系您的大客户经理（KAM）。sandbox 开放用于测试。

> [!WARNING]
>
> **仅限服务器端**
>
> 代理请求会对卡数据进行去令牌化，因此只能从您的 backend 发起。切勿在客户端代码中暴露您的 `private-secret-key`。

支持 `GET`、`POST`、`PUT`、`PATCH` 和 `DELETE`：目标地址会收到与您所用相同的方法。请将完整的目标 URL（包括路径和任何查询字符串）放在 `yuno-proxy-destination-url` 标头中；`/pci-proxy/forward` 请求本身带有的查询字符串会被拒绝。目标主机必须在您的[目标地址允许列表](https://docs.y.uno/zh-hans/docs/security-and-compliance/pci-proxy/allowlist.md)中。

如果您是通过 PCI 认证的商户，并且需要原始卡数据本身，而不是透传调用，请改用[按 ID 检索已注册支付方式的 PCI 数据](https://docs.y.uno/zh-hans/reference/payment-methods-direct-workflow/retrieve-enrolled-payment-method-by-id-pci-api.md)。


## OpenAPI

````yaml openapi/zh-hans/pci-proxy/invoke-forward-proxy.json POST /pci-proxy/forward
openapi: 3.1.0
info:
  title: pci-proxy-invoke-forward-proxy
  version: 1.0.0
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /pci-proxy/forward:
    post:
      summary: 调用转发代理
      description: >-
        将您的请求转发到 `yuno-proxy-destination-url` 标头指定的目标，并在 Yuno 的 PCI DSS Level 1
        环境内，将正文和标头值中的 `{{vaulted_token.<TOKEN>.<field>}}`
        表达式替换为真实的卡数据。目标的状态码、标头和正文会原样返回。同样支持 `GET`、`PUT`、`PATCH` 和
        `DELETE`，并原样转发。完整的目标（包括其路径和查询字符串）在 `yuno-proxy-destination-url`
        中指定；`/pci-proxy/forward` 请求本身带有查询字符串时会被拒绝。每个代理响应都带有
        `yuno-proxy-request-id` 标头；请求到达代理之前返回的 `401` 是唯一的例外。
      operationId: invokeForwardProxy
      parameters:
        - name: yuno-proxy-destination-url
          in: header
          required: true
          description: >-
            完整的目标 URL，包括其路径和任何查询字符串（例如
            `https://api.example-processor.com/charges/ch_123/capture?expand=true`）。必须是
            443 端口上的公共 HTTPS 主机名，且该主机必须已在您的目标允许列表中注册；IP 地址和内部网络会被拒绝。不得包含
            `{{vaulted_token...}}` 表达式（卡数据绝不能出现在 URL 中）。
          schema:
            type: string
            example: https://api.example-processor.com/charges
        - name: yuno-proxy-timeout
          in: header
          required: false
          description: 目标超时时间，单位为秒。默认 30，最大 120。
          schema:
            type: integer
            minimum: 1
            maximum: 120
            example: 30
        - name: yuno-account-id
          in: header
          required: false
          description: >-
            可选的账户范围。用于缩小此请求允许使用的、在允许列表中的目标范围；它不影响令牌解析（vault 令牌始终限定在您的组织范围内）。与所有
            `yuno-*` 标头一样，它会在转发前被移除，不会到达目标。
          schema:
            type: string
            example: acc_123
        - name: yuno-proxy-auth
          in: header
          required: false
          description: >-
            针对需要对正文进行 HMAC
            请求签名的目标的签名方案。代理会对解析后的正文（表达式替换之后）计算签名，并注入目标的认证标头；您的签名密钥仅在内存中使用，随后即被丢弃，不会存储任何内容。支持：`DLOCAL_HMAC`（代理生成
            `X-Date`，并对 `X-Login + X-Date + resolved body`（即解析后的正文）计算
            `Authorization: V2-HMAC-SHA256, Signature: <hex>`；您需要像普通目标标头一样发送
            `X-Login`、`X-Trans-Key` 和 `X-Version`）。未知的值，或缺少 `X-Login` 或
            `X-Trans-Key` 标头的 `DLOCAL_HMAC` 请求，会在联系目标之前被拒绝并返回 `400
            INVALID_REQUEST`。
          schema:
            type: string
            enum:
              - DLOCAL_HMAC
            example: DLOCAL_HMAC
        - name: yuno-proxy-auth-secret-key
          in: header
          required: false
          description: >-
            此请求的签名密钥（存在 `yuno-proxy-auth` 时必填）。与所有 `yuno-*`
            标头一样，它会在转发前被剥离，并从日志中排除。
          schema:
            type: string
      requestBody:
        description: >-
          目标 API 期望的正文，在应放置卡数据的位置使用 vault 令牌表达式。代理对内容是透明的：它会原样转发您的正文和
          `Content-Type`，并解析原始正文中任何位置的 `{{vaulted_token.<TOKEN>.<field>}}`
          表达式，因此支持任何内容类型（JSON、表单编码、XML）。下面的 JSON
          对象仅作示例。支持的字段：`number`、`expiration_month`、`expiration_year`、`holder_name`、`security_code`；当卡有网络令牌时，还有
          `network_token_number`（DPAN）、`network_token_expiration_month`、`network_token_expiration_year`；以及
          `network_transaction_id`（NTID：卡组织为该卡原始交易提供的参考，用于商户发起的交易）。`security_code`
          仅在卡注册时带有安全码时才会解析，并且仅在注册后的有限时间窗口内有效（参见[转发代理指南](/zh-hans/docs/security-and-compliance/pci-proxy/forward-proxy)）；不可用时，请求会失败并返回
          `EXPRESSION_RESOLUTION_FAILED`。加密凭证按交易生成，不会被解析：如果您的目标需要加密凭证，请直接在正文中包含该值。每个请求最多
          20 个不同的令牌；正文最大 1 MB。表达式在标头值中同样会被解析。所有非表达式内容都会原样转发。
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              example:
                amount: 2500
                currency: USD
                card:
                  number: >-
                    {{vaulted_token.1a2b3c4d-5678-90ab-cdef-111213141516.number}}
                  expiration_month: >-
                    {{vaulted_token.1a2b3c4d-5678-90ab-cdef-111213141516.expiration_month}}
                  expiration_year: >-
                    {{vaulted_token.1a2b3c4d-5678-90ab-cdef-111213141516.expiration_year}}
                  holder_name: >-
                    {{vaulted_token.1a2b3c4d-5678-90ab-cdef-111213141516.holder_name}}
          '*/*':
            schema:
              description: 任何其他内容类型（表单编码、XML、纯文本）都会原样转发，并解析原始正文中的表达式。
      responses:
        '200':
          description: 目标的响应，原样透传：状态、内容类型和正文。正文可以是 JSON、XML、文本或为空，因此不强制使用 schema。
          headers:
            yuno-proxy-request-id:
              description: 此次代理调用的唯一标识符。
              schema:
                type: string
            yuno-proxy-destination-status:
              description: 目标返回的 HTTP 状态码。仅当已联系到目标时才会出现。
              schema:
                type: integer
            yuno-proxy-replacements:
              description: 转发前替换的表达式数量。
              schema:
                type: integer
            yuno-proxy-response-redactions:
              description: 从目标响应中脱敏的卡号数量（非零值表示目标返回了卡数据）。
              schema:
                type: integer
          content:
            '*/*':
              schema:
                description: 目标返回的任何内容。
        '400':
          description: >-
            源自代理的请求错误（目标 URL 无效、表达式问题、超时时间无效、令牌过多，或签名设置无效：未知的
            `yuno-proxy-auth`、缺少 `yuno-proxy-auth-secret-key`，或 `DLOCAL_HMAC` 缺少
            `X-Login` 或 `X-Trans-Key` 标头）。由于未调用目标，因此不存在
            `yuno-proxy-destination-status` 标头。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Invalid request:
                  value:
                    code: INVALID_REQUEST
                    messages:
                      - yuno-proxy-destination-url header is required
                Expression resolution failed:
                  value:
                    code: EXPRESSION_RESOLUTION_FAILED
                    messages:
                      - >-
                        a vaulted_token expression could not be resolved:
                        network_transaction_id
                Invalid account id:
                  value:
                    code: INVALID_ACCOUNT_ID
                    messages:
                      - account_id is not a valid account
        '401':
          description: 认证失败。在请求到达代理之前返回，因此不带 `yuno-proxy-*` 标头。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Not authenticated:
                  value:
                    code: NOT_AUTHENTICATED
                    messages:
                      - not authenticated
                Authorization unavailable:
                  value:
                    code: AuthenticationFail
                    messages:
                      - authorization unavailable
        '403':
          description: 不允许该目标，或者您的组织未激活 PCI Proxy（仅限生产环境）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Destination not allowed:
                  value:
                    code: DESTINATION_NOT_ALLOWED
                    messages:
                      - destination host is not registered on your allowlist
                Product not enabled:
                  value:
                    code: PRODUCT_NOT_ENABLED
                    messages:
                      - >-
                        The PCI Proxy is enabled per organization. Contact your
                        Key Account Manager (KAM) to activate it.
        '413':
          description: 请求正文超过 1 MB。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Request too large:
                  value:
                    code: REQUEST_TOO_LARGE
                    messages:
                      - request body exceeds 1 MB
        '429':
          description: 该账户超出了速率限制（在 Yuno 边缘强制执行）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Too many requests:
                  value:
                    code: TOO_MANY_REQUESTS
                    messages:
                      - rate limit exceeded
        '500':
          description: 代理侧出现意外错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Proxy error:
                  value:
                    code: PROXY_ERROR
                    messages:
                      - internal error
        '502':
          description: 无法联系到目标，或者（当 Yuno 在全服务范围内配置为阻止而不是脱敏时）其响应包含卡数据。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Destination unreachable:
                  value:
                    code: DESTINATION_UNREACHABLE
                    messages:
                      - connection to destination failed
                Response blocked:
                  value:
                    code: RESPONSE_BLOCKED
                    messages:
                      - destination returned card data
        '504':
          description: 目标未在超时时间内响应。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyError'
              examples:
                Destination timeout:
                  value:
                    code: DESTINATION_TIMEOUT
                    messages:
                      - >-
                        destination did not respond within the configured
                        timeout
components:
  schemas:
    ProxyError:
      type: object
      properties:
        code:
          type: string
          description: 机器可读的错误代码。
          enum:
            - NOT_AUTHENTICATED
            - AuthenticationFail
            - INVALID_REQUEST
            - EXPRESSION_RESOLUTION_FAILED
            - INVALID_ACCOUNT_ID
            - DESTINATION_NOT_ALLOWED
            - PRODUCT_NOT_ENABLED
            - REQUEST_TOO_LARGE
            - TOO_MANY_REQUESTS
            - DESTINATION_UNREACHABLE
            - DESTINATION_TIMEOUT
            - RESPONSE_BLOCKED
            - PROXY_ERROR
        messages:
          type: array
          items:
            type: string
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: public-api-key
      x-default: <Your public-api-key>
    sec1:
      type: apiKey
      in: header
      name: private-secret-key
      x-default: <Your private-secret-key>

````

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