Statement PDF generation API
Generate an account statement PDF from a template and your transaction JSON in a single call. Docweave binds account details, transactions, and balances into an HTML statement template and returns a ready-to-send PDF — no headless browser to run yourself.
Generate an account statement PDF via the API
POST your template and data to /api/v1/pdf:
curl https://docweave.dev/api/v1/pdf \
-H "Authorization: Bearer dw_live_your_key" \
-H "Content-Type: application/json" \
-H "Accept: application/pdf" \
--output statement-4821-2026-06.pdf \
-d '{
"source": {
"type": "template",
"template": "<h1>Account Statement</h1><p>Account holder: {{ account_holder }}</p><p>Account number: {{ account_number }}</p><p>Statement period: {{ period_start }} – {{ period_end }}</p><p>Closing balance: {{ closing_balance }}</p>",
"data": {
"account_holder": "Jordan Weiss",
"account_number": "****4821",
"period_start": "2026-06-01",
"period_end": "2026-06-30",
"opening_balance": "$4,210.55",
"closing_balance": "$3,876.02"
}
},
"options": { "format": "A4" },
"idempotencyKey": "stmt-4821-2026-06"
}'…or from an AI agent
Add the Docweave MCP server and your agent gets a generate_pdf tool — the same orchestration, no HTTP boilerplate:
// From an AI agent over MCP — no HTTP plumbing:
generate_pdf({
source: {
type: "template",
template: "<h1>Account Statement</h1><p>Account holder: {{ account_holder }}</p><p>Account number: {{ account_number }}</p><p>Statement period: {{ period_start }} – {{ period_end }}</p><p>Closing balance: {{ closing_balance }}</p>",
data: {
account_holder: "Jordan Weiss",
account_number: "****4821",
period_start: "2026-06-01",
period_end: "2026-06-30",
opening_balance: "$4,210.55",
closing_balance: "$3,876.02"
}
},
outputPath: "/tmp/statement-4821-2026-06.pdf"
})Template example
Any HTML works as a template. Use {{ placeholders }} for the values you pass in data:
<article style="font-family: sans-serif;">
<header style="display:flex; justify-content:space-between;">
<div>
<h1>Account Statement</h1>
<div>{{ account_holder }} · Account {{ account_number }}</div>
</div>
<div>Statement period: {{ period_start }} – {{ period_end }}</div>
</header>
<table style="width:100%; border-collapse:collapse; margin-top:24px;">
<tr>
<td>Opening balance</td>
<td style="text-align:right;">{{ opening_balance }}</td>
</tr>
{{{ transaction_rows }}}
<tr>
<td>Total deposits</td>
<td style="text-align:right;">{{ total_deposits }}</td>
</tr>
<tr>
<td>Total withdrawals</td>
<td style="text-align:right;">{{ total_withdrawals }}</td>
</tr>
</table>
<p style="text-align:right;">Interest earned: {{ interest_earned }}</p>
<p style="text-align:right;">Fees charged: {{ fees_charged }}</p>
<p style="text-align:right;"><strong>Closing balance: {{ closing_balance }}</strong></p>
</article>FAQ
How do I generate an account statement PDF from the API?
Send a POST to /api/v1/pdf with a source of type "template": pass your statement HTML template and a data object with the account holder, account number, statement period, and balances. Docweave binds the JSON into the {{ placeholders }} and returns the statement PDF.
Can I generate account statement PDFs for every customer from one template?
Yes. Send the same statement template on each request and change only the per-account data — account holder, transactions, opening and closing balances. The layout and branding stay identical while the figures update per customer.
How do I avoid generating a duplicate statement for the same billing period?
Include an idempotencyKey (for example the account number plus statement period). A repeat request with the same key returns the stored result instead of re-rendering or re-billing, so retries and reruns of a monthly job are always safe.
How is account statement PDF generation priced?
Pricing is per document, not per page. A one-page statement and a multi-page statement with a full month of transactions count the same, so an active account's statement never costs extra.
Ready to generate account statement PDFs in production?
Get an API key