> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onboard.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# List Sub-accounts

> This endpoint returns all sub-accounts


Fetches all sub-accounts under the main account.


## OpenAPI

````yaml GET /ledger/subaccounts
openapi: 3.0.3
info:
  version: 3.0.2
  title: Onboard External API Gateway
  description: >-
    **Introduction**

    API Gateway for Onboard


    This specification describes API endpoints that are available to the public
    internet via the API gateway. The different endpoints require different
    authentication schemes, see documentation for what applies to the operation
    you want to access.


    **Errors**

    Uses conventional HTTP response codes to indicate success or failure. In

    general:
     
    - `2xx` status codes indicate success. Codes in the

    - `4xx` range

    indicate a client error (e.g. required parameters, failed request etc.).

    - `5xx` status codes indicate a server error occurred.
  contact:
    name: Nestcoin TechOps
    email: techops@nestcoin.com
  license:
    name: UNLICENSED
servers:
  - url: https://external.dev.onboardpay.co
    description: Gateway for external API on staging environment.
security: []
tags:
  - name: users-onboardapi
    description: Endpoints available to for merchants liquidity automation
  - name: users-users
    description: User related endpoints
  - name: users-partners
    description: Partner related endpoints
  - name: users-admin
    description: Back office related endpoints
  - name: users-user2fa
    description: User 2fa related endpoints
  - name: users-usernotifications
    description: User notifications related endpoints
  - name: users-merchantnetwork
    description: Merchant network endpoints
  - name: users-userauth
    description: Authentication endpoints
  - name: users-userservice
    description: Service endpoints
  - name: users-webhook
    description: webhook endpoints
  - name: users-config
    description: Configuration Endpoints
paths:
  /ledger/subaccounts:
    get:
      tags:
        - ledger-sub-accounts
      summary: Fetch all sub-accounts belonging to the customer.
      description: |
        This endpoint returns all sub-accounts
      operationId: fetchSubAccounts
      parameters:
        - $ref: '#/components/parameters/LedgerSvcaccountIdQuery'
        - $ref: '#/components/parameters/LedgerSvcsize'
        - $ref: '#/components/parameters/LedgerSvcpage'
      responses:
        '200':
          description: Sub-accounts fetched Successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubAccountList'
        '400':
          $ref: '#/components/responses/LedgerSvcInvalidRequest'
        '401':
          $ref: '#/components/responses/LedgerSvcUnauthorized'
        '403':
          $ref: '#/components/responses/LedgerSvcAccessDenied'
        default:
          $ref: '#/components/responses/LedgerSvcServerError'
      security:
        - HMACAuth: []
components:
  parameters:
    LedgerSvcaccountIdQuery:
      name: accountId
      description: The ID for the main account for the request.
      required: false
      in: query
      schema:
        type: string
        format: uuid
    LedgerSvcsize:
      in: query
      name: size
      required: false
      schema:
        type: integer
        maximum: 100
        minimum: 1
        default: 20
    LedgerSvcpage:
      in: query
      name: page
      required: false
      description: Page parameter, starting from 1
      schema:
        type: integer
        minimum: 1
        default: 1
  schemas:
    SubAccountList:
      allOf:
        - $ref: '#/components/schemas/Paging'
        - type: object
          description: Paginated list of sub-accounts belonging to a client.
          additionalProperties: false
          required:
            - content
          properties:
            content:
              type: array
              description: List of sub-accounts
              items:
                $ref: '#/components/schemas/SubAccount'
      x-source-svc: ledger
    Paging:
      description: Base object for paginated list
      type: object
      properties:
        name:
          type: string
          description: Descriptive name for the list
        size:
          minimum: 0
          type: integer
          format: int32
          description: Positive integer
        totalItems:
          minimum: 0
          type: integer
          format: int32
          description: Positive integer
        nextPage:
          minimum: 0
          type: integer
          format: int32
          description: Positive integer
        previousPage:
          minimum: 0
          type: integer
          format: int32
          description: Positive integer
      discriminator:
        propertyName: name
      x-common-model: Paging
    SubAccount:
      type: object
      additionalProperties: false
      required:
        - id
        - accountId
        - reference
        - accountBalance
        - currency
        - frozen
        - createdDate
      properties:
        id:
          type: string
          format: uuid
          description: Unique sub-account ID
        accountId:
          type: string
          format: uuid
          description: The main account ID to which this sub-account belongs.
        displayName:
          type: string
          description: An optional name for the sub-account.
        reference:
          type: string
          description: A unique reference for the sub-account.
        currency:
          type: string
          description: Currency of the sub-account
          example: USD
        accountBalance:
          $ref: '#/components/schemas/AccountBalanceDetails'
        frozen:
          type: boolean
          description: Indicates if the sub-account is frozen (locked) or not.
          default: false
        createdDate:
          type: string
          format: date-time
          description: The date the sub-account was created.
      x-source-svc: ledger
    ErrorMessageDto:
      description: >-
        Default error object for services. This gives consistent error object
        that all services may use.
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Error code
          example: UNKNOWN_ERROR
        message:
          type: string
          description: Descriptive error message
          example: Request could not be completed due to an error
        data:
          type: object
          description: Additional data for this error message.
          additionalProperties: true
          properties: {}
      x-common-model: ErrorMessageDto
    AccountBalanceDetails:
      type: object
      additionalProperties: false
      description: Account balance details
      properties:
        balance:
          description: The actual ledger balance of the account
          type: number
          example: 1000
        availableBalance:
          description: The available balance for spending
          type: number
          example: 1000
      x-source-svc: ledger
  responses:
    LedgerSvcInvalidRequest:
      description: Request could not be validated
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessageDto'
          example:
            code: BAD_REQUEST
            message: Request could not be validated.
    LedgerSvcUnauthorized:
      description: Client is not authorized to make request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessageDto'
          example:
            code: UNAUTHORIZED
            message: Either client security header is missing or it is not valid.
    LedgerSvcAccessDenied:
      description: Expected permission is not available.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessageDto'
          example:
            code: ACCESS_DENIED
            message: Expected permission or scope is not present.
    LedgerSvcServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorMessageDto'
          example:
            code: INTERNAL_ERROR
            message: An internal server error occurred.
  securitySchemes:
    HMACAuth:
      type: apiKey
      name: x-api-key
      in: header
      description: |-
        Requires authentication via API key and HMAC signature.
          * `x-api-key`: Your API key generated from your Onboard Business dashboard.
          * `x-timestamp`:  Unix epoch timestamp (seconds) used in signature, allowed skew is 30 seconds
          * `x-signature`: SHA256 HMAC HEX signature calculated over  `t={x-timestamp}&{requestBody}` using your API Secret.

````