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

# Fetch invoice status summary

> Counts the invoices that the filters of `GET /v1/invoices` select and sums their total amounts, for each status and in total, so that one call totals the invoices of a customer, a period or a status.

Requires the role `invoices:read`.



## OpenAPI

````yaml /api-reference/openapi.yaml get /v1/invoices/status-summary
openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
paths:
  /v1/invoices/status-summary:
    get:
      tags:
        - Invoices
      summary: Fetch invoice status summary
      description: >-
        Counts the invoices that the filters of `GET /v1/invoices` select and
        sums their total amounts, for each status and in total, so that one call
        totals the invoices of a customer, a period or a status.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
          example: Mercado Bom Preço
          in: query
          name: search
          required: false
          description: >-
            Free-text search over the invoice number, the customer name and the
            names of the customers whose usage the invoice bills, such as the
            subsidiaries of an organization.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: customerIds[]
          required: false
          description: Only return invoices billing these customers.
        - schema:
            type: array
            items:
              type: string
              enum:
                - open
                - in_review
                - issued
                - synced
                - pending
                - paid
                - overdue
                - canceled
                - failed
          in: query
          name: status[]
          required: false
          description: >-
            Only return invoices in these statuses. Canceled invoices are
            controlled by includeCanceled, not by this filter.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeCanceled
          required: false
          description: >-
            When false, canceled invoices are excluded. When true, canceled
            invoices are added to the statuses selected in status[]; if no
            status[] is provided, only canceled invoices are returned.
        - schema:
            type: boolean
            default: false
          in: query
          name: hideZeroAmount
          required: false
          description: When true, invoices with a zero total amount are excluded.
        - schema:
            type: string
            format: date
          in: query
          name: invoiceDate.gte
          required: false
          description: Only return invoices whose invoice date is on or after this date.
        - schema:
            type: string
            format: date
          in: query
          name: invoiceDate.lte
          required: false
          description: Only return invoices whose invoice date is on or before this date.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: contractIds[]
          required: false
          description: Only return the invoices of these contracts.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: productIds[]
          required: false
          description: >-
            Only return the invoices with at least one line item of these
            products.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: paymentAccountIds[]
          required: false
          description: Only return the invoices that bill these payment accounts.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: legalEntityIds[]
          required: false
          description: >-
            Only return the invoices of these legal entities: an invoice of a
            contract when its contract names one of them, and an invoice without
            a contract, such as a one-off invoice, when one of them is the
            default legal entity of the tenant.
        - schema:
            type: object
            properties:
              contract:
                type: object
                description: >-
                  The custom field values of the contract of the invoice. An
                  invoice without a contract never matches.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              customer:
                type: object
                description: The custom field values of the customer of the invoice.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              product:
                type: object
                description: >-
                  The custom field values of a product. An invoice matches when
                  at least one of its line items bills a product that holds
                  them.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              item:
                type: object
                description: >-
                  The custom field values of an item. An invoice matches when at
                  least one of its line items bills an item that holds them.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
            additionalProperties: false
          in: query
          name: customField
          required: false
          description: >-
            Only return the invoices whose records hold these custom field
            values, keyed by the record and then by the key of the custom field,
            as in `customField[contract][region][]=south`. An invoice matches a
            key when the record holds one of its values, and it matches the
            filter when it matches every key.
      responses:
        '200':
          description: >-
            The number of the invoices that match the filters and the sum of
            their total amounts, for each invoice status and in total.
          content:
            application/json:
              schema:
                type: object
                properties:
                  byStatus:
                    type: array
                    description: >-
                      One item for each invoice status that the settings of the
                      tenant list, in their order, with zeros for a status that
                      no selected invoice holds.
                    items:
                      type: object
                      properties:
                        status:
                          type: string
                          enum:
                            - open
                            - in_review
                            - issued
                            - synced
                            - pending
                            - paid
                            - overdue
                            - canceled
                            - failed
                          description: The invoice status.
                        count:
                          type: number
                          description: The number of selected invoices in this status.
                        totalAmount:
                          type: number
                          description: >-
                            The sum of the total amounts of the selected
                            invoices in this status, in cents.
                      required:
                        - status
                        - count
                        - totalAmount
                      additionalProperties: false
                  totalCount:
                    type: number
                    description: >-
                      The number of selected invoices across the statuses of
                      `byStatus`.
                  totalAmount:
                    type: number
                    description: >-
                      The sum of the total amounts of the selected invoices
                      across the statuses of `byStatus`, in cents.
                required:
                  - byStatus
                  - totalCount
                  - totalAmount
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.

            - `invalid_custom_fields`: a key of the `customField` filter names
            no custom field of the tenant for its record.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the tenant does not allow the IP of the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            The tenant reached one of its limits of reads.


            - `too_many_reads_per_second`: the tenant already made 50 reads in
            this second.

            - `too_many_reads_in_flight`: the tenant already has 20 reads in
            flight.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: a tenant can make at most 50 reads per
                      second. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: a tenant can have at most 20
                      reads in flight. Retry after 1 second.
                    code: too_many_reads_in_flight
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.