Purchase Order PDF generation API
Generate a purchase order PDF from a template and your procurement JSON in a single call. Docweave binds vendor details, line items, and totals into an HTML PO template and returns a ready-to-send PDF — no headless browser to run yourself.
Generate a purchase order 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" \
-d '{
"source": {
"type": "template",
"template": "<h1>Purchase Order {{ po_number }}</h1><p>Vendor: {{ vendor_name }}</p><p>Total: {{ total }}</p>",
"data": {
"po_number": "PO-2031",
"vendor_name": "Northline Supply Co.",
"total": "$4,860.00"
}
},
"options": { "format": "A4" },
"idempotencyKey": "po-2031"
}' \
--output po-2031.pdf…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>Purchase Order {{ po_number }}</h1><p>Vendor: {{ vendor_name }}</p><p>Total: {{ total }}</p>",
data: { po_number: "PO-2031", vendor_name: "Northline Supply Co.", total: "$4,860.00" }
},
outputPath: "/tmp/po-2031.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;">
<h1>Purchase Order {{ po_number }}</h1>
<div>Order date {{ order_date }}</div>
</header>
<div style="display:flex; justify-content:space-between; margin-top:16px;">
<div>
<strong>Vendor</strong><br />
{{ vendor_name }}<br />
{{ vendor_address }}
</div>
<div>
<strong>Ship to</strong><br />
{{ ship_to_name }}<br />
{{ ship_to_address }}
</div>
</div>
<p>Requested delivery: {{ delivery_date }} · Payment terms: {{ payment_terms }}</p>
<table style="width:100%; border-collapse:collapse; margin-top:12px;">
{{{ line_items }}}
</table>
<p style="text-align:right;">Subtotal: {{ subtotal }}</p>
<p style="text-align:right;">Shipping: {{ shipping }}</p>
<p style="text-align:right;">Tax: {{ tax }}</p>
<p style="text-align:right;"><strong>Total: {{ total }}</strong></p>
<p style="margin-top:24px;">Authorized by: {{ approver_name }}</p>
</article>FAQ
How do I generate a purchase order PDF from the API?
Send a POST to /api/v1/pdf with a source of type "template": pass your purchase order HTML template and a data object with the PO number, vendor, ship-to details, line items, and totals. Docweave binds the JSON into the {{ placeholders }} and returns the PO as a PDF.
Can I reuse the same purchase order template across vendors?
Yes. Send the template inline on each request, or store one template and reference it, then pass only the per-order JSON. The layout and terms stay identical while the vendor, line items, and delivery details change per call.
How do I avoid generating a duplicate purchase order PDF?
Include an idempotencyKey (for example the PO number). A repeat request with the same key returns the stored result instead of re-rendering or re-billing, so retries from a procurement workflow are always safe.
How is purchase order PDF generation priced?
Pricing is per document, not per page. A single-line PO and a multi-page order with dozens of line items count the same, so a long itemized order never costs extra.
Ready to generate purchase order PDFs in production?
Get an API key