List, then download
Eleven record types have an Attachments endpoint. GET /api.xro/2.0/{Endpoint}/{Guid}/Attachments lists the files on one record, and each entry’s Url returns the raw file.
Endpoints with attachments: Invoices, Receipts, CreditNotes, RepeatingInvoices, BankTransactions, BankTransfers, Contacts, Accounts, ManualJournals, PurchaseOrders and Quotes. Prepayments, overpayments, inventory items and fixed assets are not on the list, so download their files in Xero. Receipts covers only classic expense claims. A claim in current Xero Expenses may reach the API as a bill once approved; otherwise download its receipts in Xero.
Skip records without files
Invoices and bank transactions carry a HasAttachments flag. Check it so you only call the Attachments endpoint where files exist.
Bills are invoices of type ACCPAY, so the same endpoint covers them. Spend and receive money are BankTransactions.
The Documents library
The Files API holds library files. GET Files/{FileId}/Content downloads one. List calls return 50 files per page by default, up to 100.
Rate limits set the pace
Per organisation, Xero allows 5 calls at once and 60 a minute, and 1,000 or 5,000 a day depending on your app’s tier. Extra calls get HTTP 429 with a Retry-After header.
A bulk export needs one call per record to list its files and one per file to download. So 3,000 records with one receipt each need about 6,000 calls: at least 100 minutes at 60 a minute, and six days on the 1,000-call tier.
Build or buy
A script suits a one-off export you can watch. For a job you repeat each month, a connected app saves the upkeep. AllAttached uses these endpoints to gather each sales invoice’s receipts into one PDF.
See the finished pack.
Start with your own Xero invoices, or download an example made with sample data.