# 查询虚拟账户

> 查询指定用户的虚拟账户及其状态。

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: embedded-finance/virtual-accounts/query-virtual-account
info:
  title: 查询虚拟账户
  version: original
  description: 查询指定用户的虚拟账户及其状态。
servers:
  - url: https://sandbox-baas.onerway.com/embedded-finance
    description: sandbox
  - url: https://baas.onerway.com
    description: production
paths:
  /api/v2/virtual-account/query:
    post:
      summary: 查询虚拟账户
      description: 查询指定用户的虚拟账户及其状态。
      parameters:
        - name: apiKey
          in: header
          required: true
          description: 用于访问嵌入式金融 API 的 API key。
          schema:
            type: string
            description: 用于访问嵌入式金融 API 的 API key。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                userId:
                  type: integer
                  description: 要查询虚拟账户的用户 ID。
              required:
                - userId
            examples:
              default:
                summary: 按用户 ID 查询虚拟账户
                value:
                  userId: 12345678
      responses:
        "200":
          description: 查询虚拟账户成功（活跃账户）
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: Onerway 返回的响应码；`20000` 表示成功。
                  respMsg:
                    type: string
                    description: 响应码对应的可读消息。
                  data:
                    type: array
                    description: 该用户的虚拟账户列表。
                    items:
                      type: object
                      properties:
                        merchantNo:
                          type: string
                          description: 虚拟账户所属的商户号。
                        userId:
                          type: integer
                          description: 虚拟账户所属用户的 ID。
                        iban:
                          type: string
                          description: 虚拟账户的 IBAN。
                        ownerName:
                          type: string
                          description: 虚拟账户户名。
                          x-onerway-constraints:
                            - kind: range
                              max: 256
                              unit: 字符
                        sortCode:
                          type: string
                          description: 虚拟账户的银行 sort code。
                          x-onerway-constraints:
                            - kind: range
                              max: 32
                              unit: 字符
                        bankCountry:
                          type: string
                          description: 银行所在国家或地区，使用 ISO 3166-1 alpha-2 两位代码。
                        status:
                          type: string
                          description: 虚拟账户当前状态。
                          enum:
                            - OPENING
                            - ACTIVE
                            - OPEN_FAILED
                            - CLOSING
                            - CLOSED
                          x-enum-descriptions:
                            OPENING: 开户处理中。
                            ACTIVE: 虚拟账户正常（活跃）。
                            OPEN_FAILED: 开户失败。
                            CLOSING: 销户处理中。
                            CLOSED: 已注销。
              examples:
                success:
                  summary: 查询虚拟账户成功（活跃账户）
                  value:
                    respCode: "20000"
                    respMsg: Success
                    data:
                      - merchantNo: 800***
                        userId: 12345678
                        iban: GB00EXAMPLE00000000000000
                        ownerName: EXAMPLE USER
                        sortCode: "040893"
                        bankCountry: GB
                        status: ACTIVE
      security:
        - apiKeyAuth:
            []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: apiKey
```
