Automating invoices with agents
Updated 2026-08-18
facturium's builder uses plain HTML form controls, and its state persists locally in the browser's IndexedDB — no hidden server-side session — which makes it straightforward for a Playwright-class browser agent to drive directly, today, before any dedicated scripting API exists.
What works today: the real controls
Every control in the builder carries a stable data-testid attribute, the same ones this site's own tests use, so they won't shift between releases without notice:
- Business settings (open
settings-openfirst — these controls mount inside the settings sheet and aren't in the page until it's open):biz-name,biz-address,biz-tax-id,biz-email,biz-phone,logo-input,logo-remove(conditional — only appears once a logo has been set),number-prefix,default-currency,default-tax-bps,accent-color,footer-toggle,paper-size,backup-export,backup-import,settings-close. - Client:
client-pick,client-name,client-address,client-email,client-save. - Line items:
item-row,item-desc-<n>,item-qty-<n>,item-unit-<n>,item-rate-<n>,item-remove-<n>,item-add. - Rates:
currency-select,tax-bps,discount-kind,discount-value(conditional — only appears oncediscount-kindis changed away from "none"). - Invoice details:
issue-date,due-mode,due-date(conditional — only appears oncedue-modeis set to "date"),invoice-number,po-ref,payment-text,notes-text,terms-text. - Actions:
new-invoice,save-invoice,download-pdf,print-invoice. - Saved lists:
invoice-list,invoice-row,mark-sent,mark-paid,duplicate-invoice,delete-invoice,client-list.
On a cold load, an agent should open settings first (settings-open) and fill the business fields, then close it and fill client-name and the first line item (item-desc-0, item-qty-0, item-rate-0). It can read the totals bar (totals-bar) and preview pane (preview-pane) to confirm the numbers, click save-invoice, and then download-pdf to trigger a real browser download — the same sequence a person would use, described step by step in how to create an invoice. The UI is localized; set an English locale (via the language switcher or a browser language preference) if you want the English label set above to match what you see.
The faster way: window.facturium.v1
A versioned, in-page scripting API — window.facturium.v1 — is available today. A page.evaluate()-style agent (Playwright, Puppeteer) can call methods like newInvoice(), setClient(), addItem(), saveInvoice(), and exportPdf() directly, instead of driving form controls one field at a time. It's local-only and frozen (account/sync verbs are a v2 concern and will never be added), built on the same validators the form fields use, and a mutation is visible to an immediately following getState() call in the same tick. exportPdf()/exportData() return their bytes on this window facade only — nothing document- or logo-shaped ever appears in a WebMCP tool result. See the Scripting API section of /llms.txt for the full method table, error codes, and a Playwright example.
Metadata-only WebMCP tools are also available via document.modelContext: facturium_get_capabilities (registered on every page, not just the builder), and, scoped to the builder, facturium_new_invoice, facturium_add_item, facturium_set_client, and facturium_export_download (triggers a real local download and returns only { ok, fileName, byteLength }).
Machine-readable references
This site publishes /llms.txt with an Automation section (the testids above) and a Scripting API section (the window.facturium.v1 method table), kept in sync with the real controls and the real contract, and an /agents.json manifest describing both interfaces as available.
Ready to try it? Open the builder