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

# List accounts of customer

> Returns a list of accounts of a customer with pagination and sort.

export const ListAPIInfo = ({info: {query_fields, allowed_combinations, search_fields, sort_fields, default_sort}, show_filter_combinations}) => {
  return <AccordionGroup>
    {query_fields != null && query_fields.length > 0 ? <Accordion title="Query Parameters">
      {query_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
    </Accordion> : ''}

    {allowed_combinations != null && allowed_combinations.length > 0 ? <Accordion title="Filterable Fields">
      {[...new Set(allowed_combinations.flat())].map(field => <ParamField key={field} query={field} type="string" />)}
      {show_filter_combinations ? <>
        <h3 style={{
    marginTop: "0em"
  }}>Allowed filter combinations</h3>
        <ul>
          {allowed_combinations.map(comb => <li key="a">
              {comb.map((e, i) => <><code>{e}</code>{i != comb.length - 1 ? ", " : ""}</>)}
            </li>)}
        </ul>
        </> : ''}
    </Accordion> : ''}

    {search_fields != null && search_fields.length > 0 ? <Accordion title="Searchable Fields">
      Fields that can be searched on using <code>_search</code> query param
      {search_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
    </Accordion> : ''}

    {sort_fields != null && sort_fields.length > 0 ? <Accordion title="Sortable Fields">
      Fields with which the list response can be sorted using <code>_sort</code> query param
      {sort_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
      {default_sort ? <Note>
            Default sort order:<code>{Object.entries(default_sort).map(e => e[0] + " " + e[1]).join(', ')}</code>
          </Note> : ''}
    </Accordion> : ''}

      
  </AccordionGroup>;
};

export const listAccountsQueryFields = {
  query_fields: [{
    name: "account_id",
    type: "string",
    description: "Unique identifier of the account"
  }, {
    name: "customer_id",
    type: "string",
    description: "Unique identifier of the customer corresponding to the account"
  }, {
    name: "status",
    type: "enum",
    description: "Status of the account (`ACTIVE`, `ARCHIVED`)"
  }, {
    name: "invoice_currency",
    type: "string",
    description: "Currency in which the account is invoiced (`USD`, `EUR`, `INR`…)"
  }],
  allowed_combinations: [["account_id"], ["customer_id"], ["status"], ["invoice_currency"], ["customer_id", "status"]],
  search_fields: [{
    name: "account_id",
    type: "string"
  }, {
    name: "name",
    type: "string"
  }, {
    name: "primary_email",
    type: "string"
  }],
  sort_fields: [{
    name: "account_id",
    type: "string",
    description: ""
  }, {
    name: "updated_at",
    type: "string",
    description: ""
  }],
  default_sort: {
    "updated_at": "DESC",
    "account_id": "ASC"
  }
};

<ListAPIInfo info={listAccountsQueryFields} show_filter_combinations />


## OpenAPI

````yaml get /accounts
openapi: 3.0.3
info:
  version: '1.0'
  title: Togai Apis
  contact:
    email: engg@togai.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: APIs for Togai App
servers:
  - description: Api endpoint
    url: https://api.togai.com/
  - description: Sandbox api endpoint
    url: https://sandbox-api.togai.com/
security:
  - bearerAuth: []
tags:
  - name: Customers
    description: Customer level calls
  - name: Accounts
    description: Account level calls
  - name: Event Schemas
    description: Event Schema level calls
  - name: Usage Meters
    description: Usage Meter level calls
  - name: Price Plans
    description: (DEPRECATED) Price Plan level calls
  - name: PricePlanV2
    description: Price Plan V2 level calls
  - name: Schedules
    description: Account Schedule level calls
  - name: Pricing Rules
    description: Pricing Rules level calls
  - name: Settings
    description: Settings
  - name: Price Experimentation
    description: Price Experimentation apis
  - name: InvoiceGroups
    description: Invoice Group level calls
  - name: Organization
    description: Organization level calls
  - name: FileStorage
    description: File Storage level calls
  - name: Aliases
    description: Alias level calls
  - name: Reports
    description: Report level calls
  - name: ReportTemplates
    description: Report Template level calls
  - name: Customer Portal
    description: Portal level calls
  - name: Alerts
    description: Alert level calls
  - name: Event Management
    description: APIs for getting events ingested in Togai
    externalDocs:
      description: docs
      url: https://togai.com/docs/billing/events
  - name: Metrics
    description: APIs for getting Togai metrics
    externalDocs:
      description: docs
      url: https://togai.com/docs/metrics
  - name: Licenses
    description: APIs for getting or updating license records in Togai
  - name: Entitlements
    description: APIs related to entitlements
  - name: Invoices
    description: Invoices API
  - name: Credits
    description: Credits API
  - name: Wallet
    description: Wallet API
  - name: InvoiceTemplates
    description: InvoiceTemplates API
  - name: InvoiceSequence
    description: InvoiceSequence API
  - name: Payments
    description: Payments API
  - name: Authentication
    description: Authentication API
externalDocs:
  description: Find out more about Togai
  url: https://docs.togai.com/docs
paths:
  /accounts:
    get:
      tags:
        - Accounts
      summary: List accounts of customer
      description: Returns a list of accounts of a customer with pagination and sort.
      operationId: getAccounts
      parameters:
        - $ref: '#/components/parameters/next_token'
        - $ref: '#/components/parameters/page_size'
      responses:
        '200':
          $ref: '#/components/responses/AccountPaginatedResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '403':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '429':
          $ref: '#/components/responses/ErrorResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  parameters:
    next_token:
      in: query
      name: nextToken
      required: false
      schema:
        type: string
        example: >-
          eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==
    page_size:
      in: query
      name: pageSize
      required: false
      schema:
        type: number
        example: 10
  responses:
    AccountPaginatedResponse:
      description: Response for list customers request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AccountPaginatedResponse'
          examples:
            AccountPaginatedResponse:
              $ref: '#/components/examples/AccountPaginatedResponse'
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            ErrorResponse:
              summary: Error message
              value:
                message: <Reason message>
  schemas:
    AccountPaginatedResponse:
      type: object
      additionalProperties: false
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Account'
        nextToken:
          type: string
        context:
          $ref: '#/components/schemas/PaginationOptions'
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: error description
          maxLength: 500
    Account:
      description: Structure of an account
      type: object
      additionalProperties: false
      required:
        - name
        - id
        - togaiAccountId
        - togaiCustomerId
        - status
        - customerId
      properties:
        id:
          description: Identifier of the account
          type: string
          maxLength: 50
        togaiAccountId:
          description: Unique identifier of the account
          type: string
        togaiCustomerId:
          description: Unique identifier of the customer
          type: string
        name:
          description: Name of the Account
          type: string
          maxLength: 255
          minLength: 3
        customerId:
          description: Identifier of the customer
          type: string
        invoiceCurrency:
          description: >
            [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217) code of the
            currency in which the account must be invoiced

            Defaults to Base currency.
          type: string
          minLength: 3
          maxLength: 3
          example: USD
        aliases:
          description: list of aliases of the account
          type: array
          maxItems: 10
          minItems: 0
          items:
            title: AccountAliases
            type: object
            properties:
              alias:
                type: string
                maxLength: 50
        netTermDays:
          type: integer
          format: int32
        address:
          $ref: '#/components/schemas/Address'
        primaryEmail:
          description: Primary email of the customer
          type: string
          maxLength: 320
          example: admin@example.com
        billingInformation:
          $ref: '#/components/schemas/AccountsBillingInformation'
        status:
          description: Status of the account
          type: string
          enum:
            - ACTIVE
            - DRAFT
            - ARCHIVED
          example: ACTIVE
        settings:
          type: array
          maxItems: 10
          minItems: 0
          items:
            $ref: '#/components/schemas/CreateEntitySetting'
        invoiceGroupDetails:
          $ref: '#/components/schemas/InvoiceGroupDetails'
        metadata:
          description: |
            Additional information associated with the account.
            Example: GSTN, VATN
          type: object
          additionalProperties:
            type: string
        tags:
          description: Tag for accounts are stored in lowercase
          type: array
          uniqueItems: true
          items:
            type: string
    PaginationOptions:
      type: object
      additionalProperties: false
      properties:
        pageSize:
          type: integer
        sortOrder:
          type: string
          enum:
            - ASC
            - DESC
    Address:
      description: billing address of the customer
      type: object
      additionalProperties: false
      properties:
        phoneNumber:
          description: Contact number
          type: string
        line1:
          description: Address line 1 (eg. Street, PO Box, Company Name)
          type: string
        line2:
          description: Address line 2 (eg. apartment, suite, unit or building)
          type: string
        postalCode:
          description: ZIP or postal code
          type: string
        city:
          description: City, district, suburb, town or village
          type: string
        state:
          description: State, county, province or region
          type: string
        country:
          description: >-
            Two letter country code [ISO-3166-1
            Alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
          type: string
    AccountsBillingInformation:
      description: Billing information of an account
      type: object
      additionalProperties: false
      properties:
        emailRecipients:
          type: array
          items:
            description: >
              Emails in this array will be added in to: in mail. Primary email
              will be added if left blank.
            type: string
            maxLength: 320
        additionalEmailRecipients:
          type: array
          items:
            description: |
              Emails in this array will be added in cc: in mail.
            type: string
            maxLength: 320
    CreateEntitySetting:
      type: object
      description: Represents a setting
      additionalProperties: false
      required:
        - id
        - value
        - namespace
        - name
        - dataType
      properties:
        id:
          type: string
        value:
          type: string
        namespace:
          type: string
        name:
          type: string
        dataType:
          $ref: '#/components/schemas/SettingDataType'
    InvoiceGroupDetails:
      description: Invoice group details
      type: object
      additionalProperties: false
      required:
        - id
        - name
        - email
        - dailyInvoiceConsolidation
        - invoiceCurrency
        - billingAddress
      properties:
        id:
          type: string
        name:
          type: string
        email:
          type: string
          maxLength: 320
        dailyInvoiceConsolidation:
          type: boolean
        netTermDays:
          type: integer
          format: int32
        invoiceCurrency:
          type: string
        billingAddress:
          $ref: '#/components/schemas/Address'
    SettingDataType:
      type: string
      enum:
        - STRING
        - NUMERIC
        - JSON
        - JSON_LOGIC
  examples:
    AccountPaginatedResponse:
      value:
        data:
          - id: G234DZZKBKACATFFGVGEMERFI
            togaiAccountId: account.dsvvre314.dcs314
            customerId: ACME_CUSTOMER_1
            togaiCustomerId: customer.dsvvre314.dcs314
            name: ACME Enterprise - Account2
            status: ACTIVE
            aliases:
              - alias: account2@acme.com
              - alias: '+1234567890'
        nextToken: >-
          eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==
        context:
          pageSize: 10
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bearer <credential>

````