Xero Accounting API bindings, built for agentic finance ops: reconciliation, invoicing, AP/AR and reporting.

  • ::xero::oauth - authorize URL (with PKCE), code exchange, refresh (the refresh token rotates on every use: persist the one each refresh returns), Custom Connections (client credentials), revoke, and the tenant connections endpoint
  • ::xero::auth - credential resolution (context or per-call opts), the per-run access-token cache and the opt-in ::hot::store-backed token keeper
  • ::xero::api - the request helpers (xero-tenant-id on every call, If-Modified-Since, Idempotency-Key), HttpError with validation errors and rate-limit headers, is-retryable, paging and Xero date parsing
  • ::xero::accounting - list, get, create, update, upsert and delete for contacts, invoices, credit notes, payments, bank transactions and transfers, accounts, items, manual journals, purchase orders, quotes, tax rates, tracking categories and the organisation; PDFs, invoice email and attachments
  • ::xero::where - safe where filter building
  • ::xero::reports - profit and loss, balance sheet, trial balance, aged receivables and payables, bank summary, and a row flattener
  • ::xero::webhooks - x-xero-signature verification, the intent-to-receive response, and event parsing

Setup (Context Variables):

VariableSecretMeaning
xero.client.idnoYour app's OAuth client id
xero.client.secretyesYour app's client secret
xero.refresh.tokenyesA user's refresh token (rotates on every refresh)
xero.access.tokenyesA ready access token (skips refresh)
xero.tenant.idnoThe organisation (tenant) id sent as xero-tenant-id
xero.custom-connectionnotrue for a Custom Connection (client credentials)
xero.scopesnoScopes for a Custom Connection token
xero.token.storenoStore name for the token keeper (opt-in)
xero.webhook.keyyesThe webhook signing key

Quick start

::acc ::xero::accounting
::w ::xero::where

unpaid ::acc/list-all("Invoices", {
  where: ::w/all-of([["Type", "==", "ACCREC"], ["AmountDue", ">", 0]]),
  order: "DueDate"
}, 500)
pdf ::acc/invoice-pdf(first(unpaid).InvoiceID)

Values

API_ROOT

API_ROOT: Str "https://api.xero.com/api.xro/2.0"

AUTHORIZE_URL

AUTHORIZE_URL: Str "https://login.xero.com/identity/connect/authorize"

CONNECTIONS_URL

CONNECTIONS_URL: Str "https://api.xero.com/connections"

DEFAULT_PAGE_SIZE

DEFAULT_PAGE_SIZE: Int 100

MAX_PAGE_SIZE

MAX_PAGE_SIZE: Int 1000

REVOKE_URL

REVOKE_URL: Str "https://identity.xero.com/connect/revocation"

SCOPES_FINANCE_OPS

SCOPES_FINANCE_OPS: Vec [
  "openid",
  "profile",
  "email",
  "offline_access",
  "accounting.contacts",
  "accounting.settings",
  "accounting.invoices",
  "accounting.payments",
  "accounting.banktransactions",
  "accounting.manualjournals",
  "accounting.attachments",
  "accounting.reports.profitandloss.read",
  "accounting.reports.balancesheet.read",
  "accounting.reports.trialbalance.read",
  "accounting.reports.aged.read",
  "accounting.reports.banksummary.read"
]

The granular scopes (required for apps created on or after 2 March 2026) for read-write finance ops with this package: contacts, settings (accounts, items, tax rates, tracking), invoices (also credit notes, purchase orders, quotes), payments, bank transactions and transfers, manual journals, attachments and the reports, plus offline_access for a refresh token and openid profile email. Older apps can still use the broad accounting.transactions and accounting.reports.read until 13 September 2027.

SCOPES_READ_ONLY

SCOPES_READ_ONLY: Vec [
  "openid",
  "profile",
  "email",
  "offline_access",
  "accounting.contacts.read",
  "accounting.settings.read",
  "accounting.invoices.read",
  "accounting.payments.read",
  "accounting.banktransactions.read",
  "accounting.manualjournals.read",
  "accounting.attachments.read",
  "accounting.reports.profitandloss.read",
  "accounting.reports.balancesheet.read",
  "accounting.reports.trialbalance.read",
  "accounting.reports.aged.read",
  "accounting.reports.banksummary.read"
]

The read-only granular scopes for the same areas as SCOPES_FINANCE_OPS, plus offline_access.

TOKEN_URL

TOKEN_URL: Str "https://identity.xero.com/connect/token"