> This page is for API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.spreadspace.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.spreadspace.app/_mcp/server.

# The AP Aging object

> The extracted AP aging record: vendor balances across aging buckets as of the report date.

An extracted accounts payable aging report, in summary or detail form.

The retrieve endpoint returns this object on its own. The list endpoint
returns one per document, wrapped as
`{ "borrower_id": …, "agings": [ { "extracted_document_id", "document_category", "report_data" } ] }`,
and takes `?form=summary` or `?form=detail` to keep one form.

## Explore

[Retrieve an AP aging](/api/api-reference/ap-agings/get-ap-aging)

<path d="m9 18 6-6-6-6" />

GET`/api/borrowers/:borrower_id/extractions/:doc_id/ap-aging`

[List all AP agings](/api/api-reference/ap-agings/get-ap-agings)

<path d="m9 18 6-6-6-6" />

GET`/api/borrowers/:borrower_id/extractions/ap-agings`

`report_subtype` is `summary` or `detail` and decides the shape: a summary
carries one row per vendor in `customers` (the key is shared with AR agings)
with the aging buckets as printed, a detail carries `transactions` with
`customer_subtotals`. `grand_totals` carries the totals the document prints
and `computed_totals` the same totals taken over the rows, so the two can be
compared.

The documents behind this object carry `document_category` `ap`, `accounts_payable`, `ap_aging_platform`, `ap_aging`, `accounts_payable_summary`, `accounts_payable_detail`, `ap_aging_detail`, `ap_detail_platform` or `ap_detail`. Money keys are JSON strings with exactly two decimals (`"9200000.00"`, `"-1250.50"`). Date keys are as printed on the document unless a key's Type column states a format.

`report_subtype` says which shape follows. Each shape's fields are listed under its own heading.

## Summary

A summary aging: one row per counterparty with the balance per aging column.

| Key                   | Type                                   | Present when                                                                                                                      | Description                                                                                                                                                                                                                                         |
| --------------------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `document_type`       | always `ap_aging`                      | Always                                                                                                                            | Which family of document this is.                                                                                                                                                                                                                   |
| `report_subtype`      | always `summary`                       | Always                                                                                                                            | Always summary.                                                                                                                                                                                                                                     |
| `company_name`        | string, nullable                       | Always                                                                                                                            | The reporting company as printed.                                                                                                                                                                                                                   |
| `as_of_date`          | string (YYYY-MM-DD), nullable          | Always                                                                                                                            | The aging date.                                                                                                                                                                                                                                     |
| `currency`            | string                                 | Always                                                                                                                            | Currency code; USD.                                                                                                                                                                                                                                 |
| `customers`           | array of AgingCustomerRow              | Always                                                                                                                            | One entry per counterparty.                                                                                                                                                                                                                         |
| `grand_totals`        | object (AgingGrandTotals)              | Always                                                                                                                            | The printed grand totals.                                                                                                                                                                                                                           |
| `computed_totals`     | object                                 | When the document states it                                                                                                       | The counterparty rows added together, column by column, beside the printed totals.                                                                                                                                                                  |
| `bucket_columns`      | array of objects, nullable             | When the document states it                                                                                                       | The aging columns as the report prints them, in print order.                                                                                                                                                                                        |
| `formula_census`      | object, nullable                       | When the document states it                                                                                                       | On a spreadsheet aging whose printed total covers only some of its rows, how many rows it covers; null otherwise.                                                                                                                                   |
| `anomalies`           | array of string                        | Always                                                                                                                            | Irregularities noted on the report, in words.                                                                                                                                                                                                       |
| `signals`             | array of AgingSignal                   | When the document states it                                                                                                       | Notes about the aging date, when any.                                                                                                                                                                                                               |
| `status`              | string, one of `RECONCILED`, `FLAGGED` | When the document states it                                                                                                       | `RECONCILED` when the printed grand totals equal the rows added together; `FLAGGED` otherwise.                                                                                                                                                      |
| `entity_source`       | string                                 | When the document states it                                                                                                       | What names the company when the report heading does not: the page image (`page_image`); absent when the heading names it.                                                                                                                           |
| `entity_source_sheet` | string                                 | On a spreadsheet upload whose own sheet does not name the company, when the workbook names exactly one company; absent otherwise. | The sheet of the uploaded workbook that names the company, when this aging's own sheet does not and the workbook names exactly one company; absent otherwise.                                                                                       |
| `period_source`       | string                                 | When the document states it                                                                                                       | Which part of the document dates the report when its printed as-of line states no date: the page image (`page_image`), the file's name (`filename`) or the file's own creation date (`file_metadata`); absent when the as-of line dates the report. |

### `computed_totals`

The counterparty rows added together, column by column, beside the printed totals.

| Key                  | Type           | Present when                | Description                                                                    |
| -------------------- | -------------- | --------------------------- | ------------------------------------------------------------------------------ |
| `current_sum`        | string (money) | When the document states it | The rows' current total, stated beside the printed total for comparison.       |
| `bucket_1_30_sum`    | string (money) | When the document states it | The rows' 1 to 30 days total, stated beside the printed total for comparison.  |
| `bucket_31_60_sum`   | string (money) | When the document states it | The rows' 31 to 60 days total, stated beside the printed total for comparison. |
| `bucket_61_90_sum`   | string (money) | When the document states it | The rows' 61 to 90 days total, stated beside the printed total for comparison. |
| `bucket_91_plus_sum` | string (money) | When the document states it | The rows' over 90 days total, stated beside the printed total for comparison.  |
| `retainage_sum`      | string (money) | When the document states it | The rows' retainage total, stated beside the printed total for comparison.     |
| `prepayments_sum`    | string (money) | When the document states it | The rows' prepayments total, stated beside the printed total for comparison.   |
| `total_sum`          | string (money) | Always                      | The rows' total, stated beside the printed grand total for comparison.         |

### `bucket_columns[]`

One aged column as the report prints it.

| Key     | Type   | Present when | Description                                                                 |
| ------- | ------ | ------------ | --------------------------------------------------------------------------- |
| `key`   | string | Always       | The key the column's figures carry on each row, for example bucket_91_plus. |
| `label` | string | Always       | The column heading as printed.                                              |

### `formula_census`

Present when the report is a workbook whose printed total is a cell the workbook computes itself from only some of its rows, rather than a typed value: how many rows that total covers, how many it leaves out, and what those left out add up to, so the rows and the printed total can be read together.

| Key                  | Type           | Present when | Description                                                                |
| -------------------- | -------------- | ------------ | -------------------------------------------------------------------------- |
| `foots`              | boolean        | Always       | Whether the rows the printed total covers add up to it.                    |
| `rows_in_total`      | integer        | Always       | Number of rows the printed total covers.                                   |
| `rows_outside_total` | integer        | Always       | Number of rows the printed total leaves out.                               |
| `outside_sum`        | string (money) | Always       | The total column of the rows the printed total leaves out, added together. |

## Detail

A detail aging: one row per open transaction.

| Key                   | Type                                   | Present when                                                                                                                      | Description                                                                                                                                                                                                                                         |
| --------------------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `document_type`       | always `ap_aging`                      | Always                                                                                                                            | Which family of document this is.                                                                                                                                                                                                                   |
| `report_subtype`      | always `detail`                        | Always                                                                                                                            | Always detail.                                                                                                                                                                                                                                      |
| `company_name`        | string, nullable                       | Always                                                                                                                            | The reporting company as printed.                                                                                                                                                                                                                   |
| `as_of_date`          | string (YYYY-MM-DD), nullable          | Always                                                                                                                            | The aging date.                                                                                                                                                                                                                                     |
| `currency`            | string                                 | Always                                                                                                                            | Currency code; USD.                                                                                                                                                                                                                                 |
| `customers`           | array of AgingCustomerRow              | When the document states it                                                                                                       | Empty on a detail aging.                                                                                                                                                                                                                            |
| `transactions`        | array of objects                       | Always                                                                                                                            | One entry per open transaction.                                                                                                                                                                                                                     |
| `customer_subtotals`  | array of objects                       | Always                                                                                                                            | One entry per counterparty.                                                                                                                                                                                                                         |
| `grand_totals`        | object (AgingGrandTotals)              | Always                                                                                                                            | The printed grand totals.                                                                                                                                                                                                                           |
| `computed_totals`     | object                                 | Always                                                                                                                            | The transaction rows added together.                                                                                                                                                                                                                |
| `anomalies`           | array of string                        | Always                                                                                                                            | Irregularities noted on the report, in words.                                                                                                                                                                                                       |
| `signals`             | array of AgingSignal                   | When the document states it                                                                                                       | Notes about the aging date, when any.                                                                                                                                                                                                               |
| `status`              | string, one of `RECONCILED`, `FLAGGED` | Always                                                                                                                            | `RECONCILED` when the printed grand total equals the rows added together; `FLAGGED` otherwise.                                                                                                                                                      |
| `entity_source`       | string                                 | When the document states it                                                                                                       | What names the company when the report heading does not: the page image (`page_image`); absent when the heading names it.                                                                                                                           |
| `entity_source_sheet` | string                                 | On a spreadsheet upload whose own sheet does not name the company, when the workbook names exactly one company; absent otherwise. | The sheet of the uploaded workbook that names the company, when this aging's own sheet does not and the workbook names exactly one company; absent otherwise.                                                                                       |
| `period_source`       | string                                 | When the document states it                                                                                                       | Which part of the document dates the report when its printed as-of line states no date: the page image (`page_image`), the file's name (`filename`) or the file's own creation date (`file_metadata`); absent when the as-of line dates the report. |

### `transactions[]`

One open transaction on a detail aging.

| Key                  | Type                                                                                                | Present when                                                                                     | Description                                                                                                                                                                            |
| -------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `customer_name`      | string, nullable                                                                                    | Always                                                                                           | The customer, or the vendor on a payables aging.                                                                                                                                       |
| `transaction_type`   | string, nullable                                                                                    | Always                                                                                           | The transaction's kind as printed: invoice, credit, payment.                                                                                                                           |
| `transaction_number` | string, nullable                                                                                    | Always                                                                                           | The transaction's number as printed.                                                                                                                                                   |
| `transaction_date`   | string (as printed), nullable                                                                       | Always                                                                                           | The transaction date as printed.                                                                                                                                                       |
| `due_date`           | string (as printed), nullable                                                                       | Always                                                                                           | The due date as printed.                                                                                                                                                               |
| `po_number`          | string, nullable                                                                                    | Always                                                                                           | Purchase order number, when printed.                                                                                                                                                   |
| `age_days`           | integer, nullable                                                                                   | Always                                                                                           | Days past the transaction or due date at the aging date, as printed.                                                                                                                   |
| `bucket`             | string, one of `current`, `bucket_1_30`, `bucket_31_60`, `bucket_61_90`, `bucket_91_plus`, nullable | On a detail aging; null when the report prints no aging sections; absent on an older extraction. | The aging column the row sits under, as the column's key: `current`, `bucket_1_30`, `bucket_31_60`, `bucket_61_90` or `bucket_91_plus`; null when the report prints no aging sections. |
| `amount`             | string (money), nullable                                                                            | Always                                                                                           | The transaction's original amount.                                                                                                                                                     |
| `balance_due`        | string (money), nullable                                                                            | Always                                                                                           | The open balance.                                                                                                                                                                      |

### `customer_subtotals[]`

One counterparty's subtotal on a detail aging.

| Key               | Type           | Present when                | Description                                                                                    |
| ----------------- | -------------- | --------------------------- | ---------------------------------------------------------------------------------------------- |
| `customer_name`   | string         | Always                      | The customer, or the vendor on a payables aging.                                               |
| `subtotal`        | string (money) | Always                      | Total balance due across the counterparty's transactions.                                      |
| `is_intercompany` | boolean        | When the document states it | True when the counterparty's name shares a distinctive word with the reporting company's name. |

### `computed_totals`

The transaction rows added together.

| Key               | Type           | Present when | Description                                                                  |
| ----------------- | -------------- | ------------ | ---------------------------------------------------------------------------- |
| `balance_due_sum` | string (money) | Always       | The rows' balance due total, stated beside the printed total for comparison. |
| `n_transactions`  | integer        | Always       | Number of open items in the report.                                          |

## Shared objects

Object types that several keys above carry. The Type column names them.

### AgingCustomerRow

One counterparty row of a summary aging: a customer on a receivables aging, a vendor on a payables aging. A column the report prints beyond the standard tiers appears under its own bucket\_ key.

| Key               | Type                     | Present when                | Description                                                                                                |
| ----------------- | ------------------------ | --------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `customer_name`   | string, nullable         | Always                      | The customer, or the vendor on a payables aging.                                                           |
| `customer_no`     | string, nullable         | When the document states it | The counterparty's account number, when printed.                                                           |
| `terms`           | string, nullable         | When the document states it | Payment terms, when printed.                                                                               |
| `status_flag`     | string, nullable         | When the document states it | A status mark printed on the row, when any.                                                                |
| `status`          | string, nullable         | When the document states it | The status word printed on the row, when the report has a status column.                                   |
| `current`         | string (money), nullable | When the document states it | Not yet due.                                                                                               |
| `bucket_1_30`     | string (money), nullable | When the document states it | 1 to 30 days past due.                                                                                     |
| `bucket_31_60`    | string (money), nullable | When the document states it | 31 to 60 days past due.                                                                                    |
| `bucket_61_90`    | string (money), nullable | When the document states it | 61 to 90 days past due.                                                                                    |
| `bucket_91_plus`  | string (money), nullable | When the document states it | 91 or more days past due.                                                                                  |
| `retainage`       | string (money), nullable | When the document states it | Retainage held, when the report has the column.                                                            |
| `prepayments`     | string (money), nullable | When the document states it | Prepayments on the row, when the report has the column. A credit, counted toward the total like retainage. |
| `total`           | string (money), nullable | When the document states it | The row's total.                                                                                           |
| `is_intercompany` | boolean                  | When the document states it | True when the counterparty's name shares a distinctive word with the reporting company's name.             |

### AgingGrandTotals

The report's own printed totals row. Each aged column the report prints beyond the standard five carries its own key.

| Key              | Type                     | Present when                | Description                                |
| ---------------- | ------------------------ | --------------------------- | ------------------------------------------ |
| `current`        | string (money), nullable | When the document states it | Printed total of the current column.       |
| `bucket_1_30`    | string (money), nullable | When the document states it | Printed total of the 1 to 30 days column.  |
| `bucket_31_60`   | string (money), nullable | When the document states it | Printed total of the 31 to 60 days column. |
| `bucket_61_90`   | string (money), nullable | When the document states it | Printed total of the 61 to 90 days column. |
| `bucket_91_plus` | string (money), nullable | When the document states it | Printed total of the over 90 days column.  |
| `retainage`      | string (money), nullable | When the document states it | Printed total of the retainage column.     |
| `prepayments`    | string (money), nullable | When the document states it | Printed total of the prepayments column.   |
| `grand_total`    | string (money), nullable | When the document states it | The printed grand total.                   |

### AgingSignal

A note about the report's as-of date.

| Key        | Type                                                                                                                                                             | Present when | Description                                     |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ----------------------------------------------- |
| `severity` | string, one of `info`, `warn`                                                                                                                                    | Always       | How much weight the note carries: info or warn. |
| `code`     | string, one of `coverage_unreadable`, `no_reporting_period`, `year_from_file_metadata`, `year_from_filename`, `year_from_page_image`, `year_matches_print_stamp` | Always       | The note's identifier.                          |
| `detail`   | string                                                                                                                                                           | Always       | The note in words.                              |