Obtain an OAuth 2.0 access token with the accounting.settings scope and retrieve the Xero-Tenant-Id header value for the target organisation.
List existing tracking categories with GET https://api.xero.com/api.xro/2.0/TrackingCategories; note that an organisation supports a maximum of two ACTIVE tracking categories and four total (including archived) — plan category names accordingly.
Create a tracking category via PUT https://api.xero.com/api.xro/2.0/TrackingCategories with a JSON body containing Name and Status=ACTIVE, then create its options (e.g., division or branch names) by PUT-ing to /TrackingCategories/{TrackingCategoryID}/Options.
Assign tracking options to invoice, bill, or journal line items by including a Tracking array on each LineItem object when creating or updating transactions, specifying TrackingCategoryID and TrackingOptionID.
Pull divisional P&L by calling GET https://api.xero.com/api.xro/2.0/Reports/ProfitAndLoss with query parameters trackingCategoryID and trackingOptionID to filter the report to a specific branch.
Export the report payload and load it into a data warehouse; automate nightly pulls using a scheduled job that iterates over all active tracking options to build a full divisional reporting matrix.
Known gotchas
The two-active-category limit is a hard system constraint; attempting to activate a third category returns a validation error — archive unused categories before creating new ones.
Tracking category data is not available in the TrialBalance report endpoint; to get a tracked trial balance, use the ProfitAndLoss and BalanceSheet reports with tracking filters and merge the results programmatically.
Rate limits on the Xero Accounting API apply per-app per-tenant (60 calls per minute as of current documentation); bulk reporting loops across many tracking options should implement per-call delays and retry-after headers.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp