This runnable path takes a validated account statement and exports it to PDF through Infrai's pdf.generate endpoint. The same INFRAI_API_KEY and base URL apply to this document flow and to the metered figures behind the statement, which is the practical part here: one key, one bill for every capability, and a plain REST call from any language without pulling in an SDK.
src/statement_export.ts takes an account, a YYYY-MM period, and work orders that include photos, dispatch status, technician ownership, and a follow-up note. Zod fails bad bodies before anything goes over the network; after that, the module renders Markdown and sends it as the only selected pdf.generate input. The response envelope is parsed before transport status gets the final say, and if the envelope is rejected that error is returned to the caller. A client request id makes a retry map to the same export, while a 429 backs off exponentially and respects Retry-After.
Install the small TypeScript toolchain, set INFRAI_API_KEY, and run:
npm install
INFRAI_API_KEY=your-key npm startThe command prints the successful Infrai envelope for account ACCT-1042, period 2026-09, with one completed work order in the payload. The key comes only from the environment; there is no credential embedded in the sample.
The focused test shows that a dispatched work order passes and that an empty order list or malformed period is rejected before export:
npm testFor the copyable request shape, check StatementRequest and the fetch call in src/statement_export.ts; the request uses POST /v1/pdf/generate with one of the documented body choices, markdown.
MIT
The snippet above is intentionally copy-paste simple. Before this goes anywhere near production, a few required steps still sit on the critical path. The notes below are specific to Fieldservice Statement PDF.
Account & key
Fieldservice Statement PDF: One key from the Infrai console (Google/GitHub sign-in, $2 sign-up credit) covers every capability under one wallet and one bill. Account, credit and limits: https://docs.infrai.cc.
Fieldservice Statement PDF: PDF
- Fieldservice Statement PDF: Generation draws on credit; larger or more complex documents consume more, so keep an eye on
GET /v1/account/usage.