Greenbarfor Sage 100
Guides / Recipes with code

Pull a Sage 100 AR aging report with Python

A complete Python script that pulls Sage 100 AR aging by customer, follows pagination, and writes a CSV your controller can open - tested against the sandbox.

For: DevelopersUpdated 2026-12-043 min read

The AR aging report is the Sage 100 report finance teams export most often, usually to Excel, usually every week, usually by hand. This recipe pulls the same numbers with Python so you can schedule it, email it, or feed it to another system.

Everything below runs as-is against the Greenbar sandbox, which serves a fictional Sage 100 company called ABC.

What Sage 100 means by aging

Sage 100 ages open invoices into buckets by days past due. The API returns the same buckets:

API fieldSage aging bucket
currentNot yet due
days_1_301 to 30 days past due
days_31_6031 to 60 days past due
days_61_9061 to 90 days past due
days_91_plusMore than 90 days past due

The /ar-aging endpoint returns company totals per bucket plus one row per customer. min_days_overdue=61 keeps only amounts at least 61 days late, which is the list collections usually wants.

The script

python
"""ar_aging.py - Sage 100 AR aging to CSV. Python 3.8+, needs `pip install requests`."""
import csv, datetime, sys
import requests

BASE = "https://api.greenbar.octor.top/v1/companies/ABC"
HEADERS = {"Authorization": "Bearer sk_test_demo"}

def get(path, **params):
    r = requests.get(f"{BASE}{path}", headers=HEADERS, params=params, timeout=30)
    if r.status_code == 429:
        sys.exit("Rate limited - wait a minute and run again.")
    r.raise_for_status()
    return r.json()

def all_rows(path, **params):
    params.setdefault("limit", 100)
    while True:
        page = get(path, **params)
        yield from page["data"]
        if not page.get("has_more"):
            return
        params["cursor"] = page["next_cursor"]

def main(min_days=61):
    summary = get("/ar-aging", min_days_overdue=0)
    print(f"Open AR as of {summary['as_of']}: ${summary['total_open']:,.2f}")
    for bucket, amount in summary["totals"].items():
        print(f"  {bucket:<14}{amount:>14,.2f}")

    rows = list(all_rows("/ar-aging", min_days_overdue=min_days))
    out = f"ar_aging_{min_days}plus_{datetime.date.today():%Y%m%d}.csv"
    with open(out, "w", newline="", encoding="utf-8") as fh:
        w = csv.DictWriter(fh, fieldnames=["division", "customer_no", "name", "amount", "total_balance"])
        w.writeheader()
        w.writerows(rows)
    print(f"{len(rows)} customers with amounts {min_days}+ days overdue -> {out}")

if __name__ == "__main__":
    main(int(sys.argv[1]) if len(sys.argv) > 1 else 61)

Run it:

bash
python ar_aging.py        # 61+ days
python ar_aging.py 31     # 31+ days

Sample output against the sandbox:

text
Open AR as of 2026-12-04: $163,808.30
  current           80,741.55
  days_1_30         31,285.40
  days_31_60        11,485.40
  days_61_90        18,525.00
  days_91_plus      21,770.95
4 customers with amounts 61+ days overdue -> ar_aging_61plus_20261204.csv

Making it a weekly job

Doing the same with ODBC

Without an API you would query AR_OpenInvoice through the ODBC driver and compute buckets yourself from due dates. It works on the customer's network, but the script then has to run there, with the driver installed and a DSN configured. See the ODBC guide.

Try it against the sandboxOpen the playground →
curl "https://api.greenbar.octor.top/v1/companies/ABC/ar-aging?min_days_overdue=61" \
  -H "Authorization: Bearer sk_test_demo"

A REST API for Sage 100, self-serve

One HTTPS endpoint and a typed SDK instead of BOI scripts and ODBC DSNs on every customer's server. Read access is free during the beta.

Join the waitlist