> ## 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 payable aging

> 
        Retrieve AP aging analysis grouped by vendor.

        **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 vendors
        - Total aging buckets (sum across all vendors)
        - Per-vendor 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/ap-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/ap-aging/:
    get:
      tags:
        - Insights
        - Accounts Payable
      summary: Get accounts payable aging
      description: |2-

                Retrieve AP aging analysis grouped by vendor.

                **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 vendors
                - Total aging buckets (sum across all vendors)
                - Per-vendor breakdown (sorted by total outstanding descending)

                All values are in cents. Currency is the business's base currency.
                
      operationId: get_ap_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:
              - total
              - vendor
            default: vendor
          description: 'Grouping: ''vendor'' (default) or ''total'''
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/APAging'
          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:
    APAging:
      type: object
      description: |-
        Complete AP aging response.

        Includes:
        - Business and date metadata
        - Total outstanding across all vendors
        - Total aging buckets (sum across all vendors)
        - Per-vendor 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:
            - vendor
            - total
          type: string
          x-spec-enum-id: b6fb7084481de76a
          description: |-
            Grouping: 'vendor' or 'total'

            * `vendor` - vendor
            * `total` - total
        currency:
          type: string
          description: Business base currency (e.g., EUR, GBP, USD)
        total_outstanding_cents:
          type: integer
          description: Total outstanding across all vendors in cents
        total_aging_buckets:
          allOf:
            - $ref: '#/components/schemas/APAgingBuckets'
          description: Total aging buckets (sum across all vendors)
        vendors:
          type: array
          items:
            $ref: '#/components/schemas/VendorAging'
          description: Per-vendor aging breakdown (sorted by total outstanding descending)
      required:
        - as_of_date
        - business_id
        - currency
        - group_by
        - total_aging_buckets
        - total_outstanding_cents
        - vendors
    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
    APAgingBuckets:
      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
    VendorAging:
      type: object
      description: |-
        AP aging for a single vendor.

        Includes:
        - Vendor identification
        - Total outstanding amount
        - Breakdown by aging bucket
      properties:
        vendor_id:
          type: string
          format: uuid
          description: Vendor UUID
        vendor_name:
          type: string
          description: Vendor name (company_name or individual_name)
        total_outstanding_cents:
          type: integer
          description: Total outstanding amount for this vendor in cents
        aging_buckets:
          allOf:
            - $ref: '#/components/schemas/APAgingBuckets'
          description: Outstanding amount by aging bucket
      required:
        - aging_buckets
        - total_outstanding_cents
        - vendor_id
        - vendor_name
  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.

````