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

# Get accounts receivable aging

> 
        Retrieve AR aging analysis grouped by customer.

        **Aging buckets:**
        - Current: Not yet due (0 days overdue)
        - 1-30 days: 1-30 days overdue
        - 31-60 days: 31-60 days overdue
        - 61-90 days: 61-90 days overdue
        - 90+ days: 90 or more days overdue

        **Returns:**
        - Total outstanding across all customers
        - Total aging buckets (sum across all customers)
        - Per-customer breakdown (sorted by total outstanding descending)

        All values are in cents. Currency is the business's base currency.
        



## OpenAPI

````yaml GET /v1/platform/businesses/{business_id}/insights/ar-aging/
openapi: 3.0.3
info:
  title: Thredfi Accounting Platform API
  version: 1.0.0
  description: >-
    Comprehensive API for accounting, invoice management, open banking, and
    intelligence services.
servers: []
security: []
paths:
  /v1/platform/businesses/{business_id}/insights/ar-aging/:
    get:
      tags:
        - Insights
        - Accounts Receivable
      summary: Get accounts receivable aging
      description: |2-

                Retrieve AR aging analysis grouped by customer.

                **Aging buckets:**
                - Current: Not yet due (0 days overdue)
                - 1-30 days: 1-30 days overdue
                - 31-60 days: 31-60 days overdue
                - 61-90 days: 61-90 days overdue
                - 90+ days: 90 or more days overdue

                **Returns:**
                - Total outstanding across all customers
                - Total aging buckets (sum across all customers)
                - Per-customer breakdown (sorted by total outstanding descending)

                All values are in cents. Currency is the business's base currency.
                
      operationId: get_ar_aging
      parameters:
        - in: query
          name: as_of_date
          schema:
            type: string
            format: date
          description: Date to calculate aging as of (YYYY-MM-DD). Defaults to today.
        - in: path
          name: business_id
          schema:
            type: string
            format: uuid
          description: Business UUID
          required: true
        - in: query
          name: group_by
          schema:
            type: string
            enum:
              - customer
              - total
            default: customer
          description: 'Grouping: ''customer'' (default) or ''total'''
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ARAging'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
          description: Validation errors in request data
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication required - missing or invalid API key
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Permission denied - insufficient privileges
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Resource not found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Conflict - resource already exists or invalid state transition
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable entity - business logic validation failed
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal server error
      security:
        - PartnerJWT: []
        - BusinessScopedJWT: []
        - BasicAuth: []
        - BearerUnscoped: []
        - BearerBusinessScoped: []
components:
  schemas:
    ARAging:
      type: object
      description: |-
        Complete AR aging response.

        Includes:
        - Business and date metadata
        - Total outstanding across all customers
        - Total aging buckets (sum across all customers)
        - Per-customer breakdown (sorted by total outstanding descending)
      properties:
        business_id:
          type: string
          format: uuid
          description: Business UUID
        as_of_date:
          type: string
          format: date
          description: Date to calculate aging as of
        group_by:
          enum:
            - customer
            - total
          type: string
          x-spec-enum-id: 1f4b3152a5bd61d9
          description: |-
            Grouping: 'customer' or 'total'

            * `customer` - customer
            * `total` - total
        currency:
          type: string
          description: Business base currency (e.g., EUR, GBP, USD)
        total_outstanding_cents:
          type: integer
          description: Total outstanding across all customers in cents
        total_aging_buckets:
          allOf:
            - $ref: '#/components/schemas/ARAgingBuckets'
          description: Total aging buckets (sum across all customers)
        customers:
          type: array
          items:
            $ref: '#/components/schemas/CustomerAging'
          description: >-
            Per-customer aging breakdown (sorted by total outstanding
            descending)
      required:
        - as_of_date
        - business_id
        - currency
        - customers
        - group_by
        - total_aging_buckets
        - total_outstanding_cents
    ValidationErrorResponse:
      type: object
      description: Validation error response with field-specific errors
      properties:
        error_code:
          type: string
          description: Error code (e.g., 'validation_error')
        message:
          type: string
          nullable: true
          description: Human-readable error message
        detail:
          type: object
          additionalProperties: {}
          description: Contains field_errors and additional context
        request_id:
          type: string
          description: Request ID for tracing
      required:
        - detail
        - error_code
        - message
    ErrorResponse:
      type: object
      description: Standard error response format
      properties:
        error_code:
          type: string
          description: Error code for programmatic handling
        message:
          type: string
          nullable: true
          description: Human-readable error message
        detail:
          type: object
          additionalProperties: {}
          description: Additional error details including field_errors and debug info
        request_id:
          type: string
          description: Request ID for tracing
      required:
        - error_code
        - message
    ARAgingBuckets:
      type: object
      description: |-
        Aging buckets for outstanding amounts.

        Buckets:
        - current: Due today or in the future (0 days overdue or negative)
        - 1_30_days: 1-30 days overdue
        - 31_60_days: 31-60 days overdue
        - 61_90_days: 61-90 days overdue
        - over_90_days: 90+ days overdue

        All amounts in cents.
      properties:
        current:
          type: integer
          description: Amount not yet due (0 days overdue) in cents
        days_1_30:
          type: integer
          description: Amount 1-30 days overdue in cents
        days_31_60:
          type: integer
          description: Amount 31-60 days overdue in cents
        days_61_90:
          type: integer
          description: Amount 61-90 days overdue in cents
        over_90_days:
          type: integer
          description: Amount 90+ days overdue in cents
      required:
        - current
        - days_1_30
        - days_31_60
        - days_61_90
        - over_90_days
    CustomerAging:
      type: object
      description: |-
        AR aging for a single customer.

        Includes:
        - Customer identification
        - Total outstanding amount
        - Breakdown by aging bucket
      properties:
        customer_id:
          type: string
          format: uuid
          description: Customer UUID
        customer_name:
          type: string
          description: Customer name (company_name or individual_name)
        total_outstanding_cents:
          type: integer
          description: Total outstanding amount for this customer in cents
        aging_buckets:
          allOf:
            - $ref: '#/components/schemas/ARAgingBuckets'
          description: Outstanding amount by aging bucket
      required:
        - aging_buckets
        - customer_id
        - customer_name
        - total_outstanding_cents
  securitySchemes:
    PartnerJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Partner-level JWT token (unscoped). Token payload includes `partner_id`.
        Business access is validated via partner ownership. Format: `Bearer
        <your-jwt-token>`


        **Use this for**: Multi-business operations where the business_id is
        specified in the URL and partner has access to multiple businesses.
    BusinessScopedJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Business-scoped JWT token. Token payload includes `business_id` to
        automatically scope requests. Format: `Bearer <your-jwt-token>`


        **Use this for**: Business-specific operations where the business
        context is embedded in the token.
    BasicAuth:
      type: http
      scheme: basic
      description: >-
        Basic authentication for OAuth2 token endpoint. Use partner_uuid:api_key
        as username:password. Example: Authorization: Basic
        base64(partner_uuid:api_key)
    BearerUnscoped:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Partner (unscoped) JWT Bearer token. Obtain via POST
        /v1/platform/oauth2/token with Basic auth (partner_uuid:api_key). Use
        header: Authorization: Bearer {access_token}
    BearerBusinessScoped:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Business-scoped JWT Bearer token. Obtain via POST
        /v1/platform/{business_id}/oauth2/token/ using a partner Bearer token.
        Only valid for endpoints whose URL contains that business_id.

````