# 查询收款人字段规则

> 查询指定商户、国家、币种、主体及付款方式下的收款人字段定义和校验规则。

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: transfer/v3-beneficiaries/schema
info:
  title: 查询收款人字段规则
  version: original
  description: 查询指定商户、国家、币种、主体及付款方式下的收款人字段定义和校验规则。
servers:
  - url: https://sandbox-transfer-api.onerway.com
    description: sandbox
  - url: https://transfer-api.onerway.com
    description: production
paths:
  /api/v3/beneficiary/schema:
    post:
      summary: 查询收款人字段规则
      description: 查询指定商户、国家、币种、主体及付款方式下的收款人字段定义和校验规则。
      parameters:
        - name: ApiKey
          in: header
          required: true
          description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
          schema:
            type: string
            description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                destinationCountry:
                  type: string
                  description: 收款账户所在国家或地区，参见[国家/地区枚举](/zh/transfer/api-reference/v3-enums#国家地区枚举)。
                  x-onerway-constraints:
                    - kind: rule
                      text: 最大长度：12。
                targetCurrency:
                  type: string
                  description: 目标币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                  x-onerway-constraints:
                    - kind: rule
                      text: 最大长度：128。
                paymentMethod:
                  type: string
                  description: 付款方式，参见[枚举说明](/zh/transfer/api-reference/v3-enums#paymentmethod-付款方式)。
                  enum:
                    - BANK_TRANSFER
                    - SWIFT
                    - E_WALLET
                    - CASH_PICKUP
                  x-enum-descriptions:
                    BANK_TRANSFER: 银行转账
                    SWIFT: SWIFT 汇款
                    E_WALLET: 电子钱包
                    CASH_PICKUP: 现金支取
                entityType:
                  type: string
                  description: 收款人的主体类型，取值见[枚举说明](/zh/transfer/api-reference/v3-enums#entitytype-主体类型)。
                  enum:
                    - INDIVIDUAL
                    - BUSINESS
                  x-enum-descriptions:
                    INDIVIDUAL: 个人
                    BUSINESS: 企业
                walletProvider:
                  type: string
                  description: 钱包服务商，参见[钱包服务商](/zh/transfer/api-reference/v3-enums#walletprovider-walletformat-钱包服务商与账号格式)。
                  x-onerway-required: conditional
                  x-onerway-condition:
                    - paymentMethod=E_WALLET 时必填。
                  x-onerway-constraints:
                    - kind: rule
                      text: paymentMethod=E_WALLET 时必填。
                    - kind: consistency
                      text: walletProvider 与 walletFormat 必须组成该商户、账户国家、币种和主体类型下有效的钱包组合。
                    - kind: rule
                      text: 最大长度：64。
                walletFormat:
                  type: string
                  description: 所选 walletProvider
                    对应的钱包账号格式，参见[钱包账号格式](/zh/transfer/api-reference/v3-enums#walletprovider-walletformat-钱包服务商与账号格式)。
                  x-onerway-required: conditional
                  x-onerway-condition:
                    - paymentMethod=E_WALLET 时必填。
                  x-onerway-constraints:
                    - kind: rule
                      text: paymentMethod=E_WALLET 时必填。
                    - kind: rule
                      text: 最大长度：64。
                onBehalfOf:
                  type: string
                  description: 请求实际对应的商户号，仅在代其他商户发起请求时填写。
              required:
                - destinationCountry
                - targetCurrency
                - paymentMethod
                - entityType
            examples:
              default:
                summary: 请求结构示例（替换为当前商户数据）
                value:
                  destinationCountry: US
                  targetCurrency: USD
                  paymentMethod: BANK_TRANSFER
                  entityType: BUSINESS
              wallet:
                summary: 电子钱包
                value:
                  destinationCountry: US
                  targetCurrency: USD
                  paymentMethod: E_WALLET
                  entityType: BUSINESS
                  walletProvider: PAYPAL
                  walletFormat: EMAIL
      responses:
        "200":
          description: 成功示例（字段节选，非配置快照）
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      respCode:
                        type: string
                        description: 响应码；`20000` 表示请求处理成功，其余为错误码。
                      respMsg:
                        type: string
                        description: 响应码对应的可读说明。
                      data:
                        type: object
                        properties:
                          condition:
                            type: object
                            properties:
                              merchantNo:
                                type: string
                                description: 请求发起方的商户号。
                              destinationCountry:
                                type: string
                                description: 收款账户所在国家或地区，参见[国家/地区枚举](/zh/transfer/api-reference/v3-enums#国家地区枚举)。
                              targetCurrency:
                                type: string
                                description: 目标币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                              paymentMethod:
                                type: string
                                description: 付款方式，参见[枚举说明](/zh/transfer/api-reference/v3-enums#paymentmethod-付款方式)。
                                enum:
                                  - BANK_TRANSFER
                                  - SWIFT
                                  - E_WALLET
                                  - CASH_PICKUP
                                x-enum-descriptions:
                                  BANK_TRANSFER: 银行转账
                                  SWIFT: SWIFT 汇款
                                  E_WALLET: 电子钱包
                                  CASH_PICKUP: 现金支取
                              entityType:
                                type: string
                                description: 收款人的主体类型，取值见[枚举说明](/zh/transfer/api-reference/v3-enums#entitytype-主体类型)。
                                enum:
                                  - INDIVIDUAL
                                  - BUSINESS
                                x-enum-descriptions:
                                  INDIVIDUAL: 个人
                                  BUSINESS: 企业
                              walletProvider:
                                type: string
                                description: 钱包服务商，参见[钱包服务商](/zh/transfer/api-reference/v3-enums#walletprovider-walletformat-钱包服务商与账号格式)。
                              walletFormat:
                                type: string
                                description: 所选 walletProvider
                                  对应的钱包账号格式，参见[钱包账号格式](/zh/transfer/api-reference/v3-enums#walletprovider-walletformat-钱包服务商与账号格式)。
                            description: 本次规则查询条件
                          fields:
                            type: array
                            description: 当前条件下的字段定义
                            items:
                              type: object
                              properties:
                                path:
                                  type: string
                                  description: "[新增收款人](/zh/transfer/api-reference/endpoints/v3-beneficiaries-add\
                                    )请求中的字段路径。"
                                required:
                                  type: string
                                  description: 字段是否全局必填，取值见[枚举说明](/zh/transfer/api-reference/v3-enums#字段规则)。
                                  enum:
                                    - MANDATORY
                                    - OPTIONAL
                                  x-enum-descriptions:
                                    MANDATORY: 必填
                                    OPTIONAL: 非全局必填，仍须满足条件规则
                                type:
                                  type: string
                                  description: 字段值类型，取值见[枚举说明](/zh/transfer/api-reference/v3-enums#字段规则)。
                                  enum:
                                    - STRING
                                    - DATE
                                  x-enum-descriptions:
                                    STRING: 字符串
                                    DATE: 日期
                                description:
                                  type: string
                                  description: 字段或选项说明
                                example:
                                  type: string
                                  description: 可为空的示例值；不是默认值
                                options:
                                  type: array
                                  description: 该字段的候选值。未提供候选值列表时省略此字段。
                                  items:
                                    type: object
                                    properties:
                                      value:
                                        type: string
                                        description: 填写到 path 所指字段中的值。
                                      description:
                                        type: string
                                        description: 该候选值的展示说明。
                                rules:
                                  type: array
                                  description: 字段规则列表
                                  items:
                                    type: object
                                    properties:
                                      ruleType:
                                        type: string
                                        description: 校验规则类型 取值见[枚举说明](/zh/transfer/api-reference/v3-enums#字段规则)。
                                        enum:
                                          - REQUIRED
                                          - LENGTH_RANGE
                                          - NUMBER_RANGE
                                          - REGEX
                                          - AMOUNT_RANGE
                                          - TIME_RANGE
                                          - CONDITION
                                          - UNKNOWN
                                        x-enum-descriptions:
                                          REQUIRED: 必填规则
                                          LENGTH_RANGE: 长度范围
                                          NUMBER_RANGE: 数值范围
                                          REGEX: 正则表达式
                                          AMOUNT_RANGE: 金额范围
                                          TIME_RANGE: 时间范围
                                          CONDITION: 条件或组合规则
                                          UNKNOWN: 未知规则类型；规则配置为 UNKNOWN 时返回
                                      params:
                                        type: object
                                        properties:
                                          min:
                                            type: number
                                            description: 范围下限（含边界）。ruleType 为 LENGTH_RANGE、NUMBER_RANGE 或 AMOUNT_RANGE
                                              且配置了范围参数时返回。
                                          max:
                                            type: number
                                            description: 范围上限（含边界）。ruleType 为 LENGTH_RANGE、NUMBER_RANGE 或 AMOUNT_RANGE
                                              且配置了范围参数时返回。
                                          startTime:
                                            type: string
                                            description: 绝对时间范围的起点，包含该边界。ruleType 为 TIME_RANGE
                                              且配置了时间范围参数时返回；未配置绝对起点时可为空。时区：北京时间（UTC+8）。
                                          endTime:
                                            type: string
                                            description: 绝对时间范围的终点，包含该边界。ruleType 为 TIME_RANGE
                                              且配置了时间范围参数时返回；未配置绝对终点时可为空。时区：北京时间（UTC+8）。
                                          pattern:
                                            type: string
                                            description: 需要匹配的正则表达式。ruleType 为 REGEX 且配置了表达式时返回。
                                          rules:
                                            type: array
                                            description: 同一字段的嵌套规则。ruleType 为 CONDITION 且配置了嵌套规则时返回。组合规则适用时，须通过其中每条规则；每项分别包含
                                              ruleType 和 params。
                                            items:
                                              type: object
                                              properties:
                                                ruleType:
                                                  type: string
                                                  description: 嵌套规则类型 取值见[枚举说明](/zh/transfer/api-reference/v3-enums#字段规则)。
                                                  enum:
                                                    - REQUIRED
                                                    - LENGTH_RANGE
                                                    - NUMBER_RANGE
                                                    - REGEX
                                                    - AMOUNT_RANGE
                                                    - TIME_RANGE
                                                    - CONDITION
                                                    - UNKNOWN
                                                  x-enum-descriptions:
                                                    REQUIRED: 必填规则
                                                    LENGTH_RANGE: 长度范围
                                                    NUMBER_RANGE: 数值范围
                                                    REGEX: 正则表达式
                                                    AMOUNT_RANGE: 金额范围
                                                    TIME_RANGE: 时间范围
                                                    CONDITION: 条件或组合规则
                                                    UNKNOWN: 未知规则类型；规则配置为 UNKNOWN 时返回
                                                params:
                                                  type: object
                                                  properties:
                                                    {}
                                                  description: 递归使用同样参数结构；没有固定嵌套深度
                                        description: 当前规则的参数，各字段的适用规则见下方说明。时间参数仅提供绝对时间边界，年龄等相对日期限制以收款人校验接口的结果为准。
                                      message:
                                        type: string
                                        description: 可读的错误或规则说明
                        description: 成功业务数据；失败不作为有效业务数据读取
                        x-onerway-constraints:
                          - kind: rule
                            text: 没有配置适用的路由或校验规则时会失败，不应将失败当作“没有必填字段”。
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                            description: 错误类型。
                          code:
                            type: string
                            description: 本接口错误标识。
                          declineCode:
                            type: string
                            description: 拒绝原因码，可能为空。
                          message:
                            type: string
                            description: 错误详细说明
                          param:
                            type: string
                            description: 失败字段或条件；无法定位时可能为空
                          docUrl:
                            type: string
                            description: 错误文档链接，可能为空。
                          requestId:
                            type: string
                            description: 服务端错误跟踪标识，req_ + 32 位十六进制字符；不是商户请求编号
                          errorDetails:
                            type: array
                            description: 具体错误明细；见下列分支
                            items:
                              type: object
                              properties:
                                errorCode:
                                  type: string
                                  description: 业务或校验明细码。
                                message:
                                  type: string
                                  description: 明细说明
                        description: 结构化失败信息；并非每个失败分支都有该字段
                  - type: object
                    properties:
                      respCode:
                        type: string
                      respMsg:
                        type: string
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                          code:
                            type: string
                          message:
                            type: string
                          param:
                            type: string
                          requestId:
                            type: string
                          errorDetails:
                            type: array
                        required:
                          - type
                          - code
                          - message
                          - param
                          - requestId
                          - errorDetails
                    required:
                      - respCode
                      - respMsg
                      - error
                  - type: object
                    properties:
                      respCode:
                        type: string
                      respMsg:
                        type: string
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                          code:
                            type: string
                          message:
                            type: string
                          requestId:
                            type: string
                          errorDetails:
                            type: array
                          param:
                            type: string
                        required:
                          - type
                          - code
                          - message
                          - requestId
                          - errorDetails
                          - param
                    required:
                      - respCode
                      - respMsg
                      - error
              examples:
                "40004":
                  summary: 钱包配置查询成功，但没有配置与传入的 walletProvider、walletFormat 组合匹配。
                  description: 钱包服务商与账号格式未匹配到可用的钱包配置。
                  value:
                    respCode: "40004"
                    respMsg: Illegal parameter [walletProvider/walletFormat]
                    error:
                      type: validation_error
                      code: invalid_wallet_selection
                      message: walletProvider and walletFormat must match an available wallet
                        configuration
                      param: walletProvider
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        []
                "50097":
                  summary: 查询的国家、币种和付款方式未组成支持的场景。
                  description: 查询的国家、币种和付款方式未组成支持的场景。
                  value:
                    respCode: "50097"
                    respMsg: payment country is not surpport this payment method
                    error:
                      type: business_error
                      code: invalid_schema_scene
                      message: destinationCountry, targetCurrency and paymentMethod do not form a
                        supported schema scene
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        []
                      param: destinationCountry
                success:
                  summary: 成功示例（字段节选，非配置快照）
                  value:
                    respCode: "20000"
                    respMsg: Success
                    data:
                      condition:
                        merchantNo: "10000"
                        destinationCountry: US
                        targetCurrency: USD
                        paymentMethod: BANK_TRANSFER
                        entityType: BUSINESS
                      fields:
                        - path: account.countryCode
                          required: MANDATORY
                          type: STRING
                          description: account country
                          example: US
                          rules:
                            []
                        - path: account.currency
                          required: MANDATORY
                          type: STRING
                          description: account currency
                          example: USD
                          rules:
                            []
                        - path: business.companyName
                          required: OPTIONAL
                          type: STRING
                          description: business company name
                          rules:
                            - ruleType: LENGTH_RANGE
                              params:
                                max: 64
                              message: business.companyName length cannot exceed 64
                failure:
                  summary: 查询的国家、币种和付款方式未组成支持的场景。
                  value:
                    respCode: "50097"
                    respMsg: payment country is not surpport this payment method
                    error:
                      type: business_error
                      code: invalid_schema_scene
                      message: destinationCountry, targetCurrency and paymentMethod do not form a
                        supported schema scene
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        []
                      param: destinationCountry
```
