Xero reports, plus flatten-report, which turns a report's sections
into flat records an agent or a spreadsheet can use.
Each report takes Xero's own parameters: fromDate / toDate /
date (YYYY-MM-DD), periods and timeframe (MONTH,
QUARTER, YEAR) for comparisons, trackingCategoryID /
trackingOptionID, standardLayout, paymentsOnly (cash basis).
Null values are dropped. Reports need the granular report scopes
(accounting.reports.profitandloss.read, ...) or, for apps created
before 2 March 2026, accounting.reports.read.
::r ::xero::reports
pnl ::r/profit-and-loss({fromDate: "2026-07-01", toDate: "2026-09-30"})
rows ::r/flatten-report(pnl)
net find-first(rows, (row) { eq(row.label, "Net Profit") })
Values
REPORTS
REPORTS: Vec [
"ProfitAndLoss",
"BalanceSheet",
"TrialBalance",
"AgedReceivablesByContact",
"AgedPayablesByContact",
"BankSummary",
"ExecutiveSummary",
"BudgetSummary"
]
Functions
aged-payables
fn (contact-id: Str, params: Map): Map
fn (contact-id: Str, params: Map, opts: Map): Map
The AgedPayablesByContact report for one contact (contactId required).
Params: date, fromDate, toDate.
Example
report ::xero::reports/aged-payables("6d2b51ce-0a4f-4a8b-9f7a-3c1e2d4b5a69", {date: "2026-09-30"})
::xero::reports/flatten-report(report)
aged-receivables
fn (contact-id: Str, params: Map): Map
fn (contact-id: Str, params: Map, opts: Map): Map
The AgedReceivablesByContact report for one contact (Xero requires
contactId). Params: date, fromDate, toDate.
Example
report ::xero::reports/aged-receivables("6d2b51ce-0a4f-4a8b-9f7a-3c1e2d4b5a69", {date: "2026-09-30"})
::xero::reports/flatten-report(report)
balance-sheet
fn (params: Map): Map
fn (params: Map, opts: Map): Map
The BalanceSheet report. Params: date, periods, timeframe,
trackingOptionID1, trackingOptionID2, standardLayout,
paymentsOnly.
Example
sheet ::xero::reports/balance-sheet({date: "2026-09-30"})
sheet.ReportTitles
bank-summary
fn (params: Map): Map
fn (params: Map, opts: Map): Map
The BankSummary report: opening balance, cash received, cash spent and
closing balance per bank account. Params: fromDate, toDate. The
usual starting point for a bank reconciliation check.
Example
report ::xero::reports/bank-summary({fromDate: "2026-09-01", toDate: "2026-09-30"})
::xero::reports/flatten-report(report)
column-keys
fn (report: Map): Vec
Column keys from a report's Header row: each header cell's text, else
col{i}; repeated keys get _{i} appended.
Example
::xero::reports/column-keys({Rows: [{RowType: "Header", Cells: [{Value: ""}, {Value: "31 Oct 2026"}]}]}) // ["col0", "31 Oct 2026"]
flatten-report
fn (report: Map): Vec
Flatten a report (as run-report returns it) into records:
type-"Row"or"SummaryRow"(section totals)section- the section title ("Income","Less Operating Expenses"), when not blanklabel- the first cell (account or line name)account-id- the account GUID when Xero links onevalues- every cell keyed by the header row ({"31 Oct 2026": "1200.00"})cells- the cell values as a Vec of Str
Header rows are used for the keys, not returned. Amounts stay as Strs;
parse-amount converts one.
Example
report {Rows: [
{RowType: "Header", Cells: [{Value: ""}, {Value: "31 Oct 2026"}]},
{RowType: "Section", Title: "Income", Rows: [
{RowType: "Row", Cells: [{Value: "Sales"}, {Value: "1200.00"}]}
]}
]}
row first(::xero::reports/flatten-report(report))
row.section // "Income"
row.label // "Sales"
row.cells // ["Sales", "1200.00"]
parse-amount
fn (value: Any): Dec?
A report amount Str ("1200.00", "-35.50", "1,200.00") as a Dec;
null for blanks and non-numbers.
Example
::xero::reports/parse-amount("1,200.00") // 1200.0
::xero::reports/parse-amount("n/a") // null
profit-and-loss
fn (params: Map): Map
fn (params: Map, opts: Map): Map
The ProfitAndLoss report. Params: fromDate, toDate, periods,
timeframe, trackingCategoryID, trackingOptionID, standardLayout,
paymentsOnly.
Example
pnl ::xero::reports/profit-and-loss({fromDate: "2026-07-01", toDate: "2026-09-30"})
::xero::reports/flatten-report(pnl)
// Three months compared, cash basis
::xero::reports/profit-and-loss({fromDate: "2026-09-01", toDate: "2026-09-30", periods: 2, timeframe: "MONTH", paymentsOnly: true})
run-report
fn (name: Str): Map
fn (name: Str, params: Map): Map
fn (name: Str, params: Map, opts: Map): Map
GET /Reports/{name} with params. Returns the first report
(ReportName, ReportTitles, ReportDate, Rows, ...). Use
flatten-report for records.
Example
report ::xero::reports/run-report("ExecutiveSummary", {date: "2026-10-31"})
report.ReportName
trial-balance
fn (params: Map): Map
fn (params: Map, opts: Map): Map
The TrialBalance report. Params: date, paymentsOnly.
Example
report ::xero::reports/trial-balance({date: "2026-09-30"})
::xero::reports/flatten-report(report)