Skip to content

feat: add invoice online URL and PDF download tools#127

Open
harryblam wants to merge 1 commit intoXeroAPI:mainfrom
harryblam:feat/invoice-url-and-pdf-tools
Open

feat: add invoice online URL and PDF download tools#127
harryblam wants to merge 1 commit intoXeroAPI:mainfrom
harryblam:feat/invoice-url-and-pdf-tools

Conversation

@harryblam
Copy link
Copy Markdown

Summary

Add two new read-only tools for accessing Xero invoice documents:

Tool Description
get-invoice-online-url Get the public shareable URL for an invoice (the link customers see for online viewing/payment)
get-invoice-as-pdf Download the Xero-rendered invoice PDF as base64

Changes

New files

  • src/handlers/get-xero-invoice-online-url.handler.ts — calls accountingApi.getOnlineInvoice(), extracts URL from response
  • src/handlers/get-xero-invoice-as-pdf.handler.ts — calls accountingApi.getInvoiceAsPdf(), converts Buffer to base64
  • src/tools/get/get-invoice-online-url.tool.ts — tool definition with invoiceId parameter; gracefully handles invoices without online viewing enabled
  • src/tools/get/get-invoice-as-pdf.tool.ts — tool definition with invoiceId parameter; returns PDF content as base64

Modified files

  • src/tools/get/index.ts — registers both new tools

Scope

Both tools use accountingApi.getOnlineInvoice() and accountingApi.getInvoiceAsPdf() which fall under the existing accounting.transactions scope. No new scopes required.

Testing

Tested against a live Xero account:

  • get-invoice-online-url returns the correct shareable URL (e.g. https://in.xero.com/...)
  • get-invoice-as-pdf returns a valid PDF (~90KB base64 for a simple invoice)
  • Invoices without online viewing enabled get a clear informative message instead of an error
  • Existing tools continue to work — no breaking changes

Add two new read-only tools for accessing Xero invoice documents:

- get-invoice-online-url: returns the public shareable URL for an invoice
  (gracefully handles invoices without online viewing enabled)
- get-invoice-as-pdf: returns the Xero-rendered invoice PDF as base64

Both use existing accounting.transactions scope — no new scopes required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant