# Query virtual accounts

> Retrieve a user's virtual accounts and their statuses.

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: embedded-finance/virtual-accounts/query-virtual-account
info:
  title: Query virtual accounts
  version: original
  description: Retrieve a user's virtual accounts and their statuses.
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: Query virtual accounts
      description: Retrieve a user's virtual accounts and their statuses.
      parameters:
        - name: apiKey
          in: header
          required: true
          description: API key assigned for Embedded Finance API access.
          schema:
            type: string
            description: API key assigned for Embedded Finance API access.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                userId:
                  type: integer
                  description: ID of the user whose virtual accounts are queried.
              required:
                - userId
            examples:
              default:
                summary: Query virtual accounts by user ID
                value:
                  userId: 12345678
      responses:
        "200":
          description: Virtual accounts returned (active account)
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: Response code returned by Onerway. `20000` indicates success.
                  respMsg:
                    type: string
                    description: Human-readable response message.
                  data:
                    type: array
                    description: Virtual accounts returned for the user.
                    items:
                      type: object
                      properties:
                        merchantNo:
                          type: string
                          description: Merchant number associated with the virtual account.
                        userId:
                          type: integer
                          description: ID of the user who owns the virtual account.
                        iban:
                          type: string
                          description: IBAN of the virtual account.
                        ownerName:
                          type: string
                          description: Name of the virtual account owner.
                          x-onerway-constraints:
                            - kind: range
                              max: 256
                              unit: characters
                        sortCode:
                          type: string
                          description: Bank sort code of the virtual account.
                          x-onerway-constraints:
                            - kind: range
                              max: 32
                              unit: characters
                        bankCountry:
                          type: string
                          description: Country or region where the bank is located, as an ISO 3166-1
                            alpha-2 code.
                        status:
                          type: string
                          description: Current status of the virtual account.
                          enum:
                            - OPENING
                            - ACTIVE
                            - OPEN_FAILED
                            - CLOSING
                            - CLOSED
                          x-enum-descriptions:
                            OPENING: Virtual account opening is in progress.
                            ACTIVE: The virtual account is active.
                            OPEN_FAILED: Virtual account opening failed.
                            CLOSING: Virtual account closure is in progress.
                            CLOSED: The virtual account has been closed.
              examples:
                success:
                  summary: Virtual accounts returned (active account)
                  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
```
