Contract PDF generation API
Generate a contract PDF from a template and your deal JSON in a single call. Docweave binds parties, terms, payment schedule, and signature blocks into an HTML contract template and returns a ready-to-sign PDF — no headless browser to run yourself.
Generate a contract 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>{{ contract_title }}</h1><p>Contract No. {{ contract_number }}</p><p>Between {{ party_a }} and {{ party_b }}</p><p>Effective {{ effective_date }}</p>",
"data": {
"contract_title": "Master Services Agreement",
"contract_number": "MSA-2026-0143",
"party_a": "Acme Inc.",
"party_b": "Northwind Consulting LLC",
"effective_date": "July 15, 2026"
}
},
"options": { "format": "A4" },
"idempotencyKey": "msa-2026-0143"
}' \
--output msa-2026-0143.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>{{ contract_title }}</h1><p>Contract No. {{ contract_number }}</p><p>Between {{ party_a }} and {{ party_b }}</p><p>Effective {{ effective_date }}</p>",
data: {
contract_title: "Master Services Agreement",
contract_number: "MSA-2026-0143",
party_a: "Acme Inc.",
party_b: "Northwind Consulting LLC",
effective_date: "July 15, 2026"
}
},
outputPath: "/tmp/msa-2026-0143.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="text-align:center;">
<h1>{{ contract_title }}</h1>
<div>Contract No. {{ contract_number }}</div>
</header>
<p>
This agreement is entered into as of {{ effective_date }} by and between
<strong>{{ party_a }}</strong>, located at {{ party_a_address }} ("Party A"),
and <strong>{{ party_b }}</strong>, located at {{ party_b_address }} ("Party B").
</p>
<h2>1. Term</h2>
<p>This agreement remains in effect for {{ term_length }}, beginning on {{ effective_date }}.</p>
<h2>2. Scope of Services</h2>
<p>{{ scope_of_services }}</p>
<h2>3. Payment Terms</h2>
<p>Party A shall pay Party B {{ payment_amount }}, due {{ payment_schedule }}.</p>
<h2>4. Governing Law</h2>
<p>This agreement is governed by the laws of {{ governing_law }}.</p>
<table style="width:100%; margin-top:48px; border-collapse:collapse;">
<tr>
<td style="width:50%; padding-top:32px; border-top:1px solid #000;">{{ party_a_signatory }}<br/>Party A, {{ effective_date }}</td>
<td style="width:50%; padding-top:32px; border-top:1px solid #000;">{{ party_b_signatory }}<br/>Party B, {{ effective_date }}</td>
</tr>
</table>
</article>FAQ
How do I generate a contract PDF from the API?
Send a POST to /api/v1/pdf with a source of type "template": pass your contract HTML template and a data object with the parties, term, payment terms, and governing law. Docweave binds the JSON into the {{ placeholders }} and returns the signed-ready contract PDF.
Can I reuse the same contract template for different clients?
Yes. Store one contract template — an MSA, NDA, or SOW — and pass only the per-deal JSON (party names, addresses, dates, amounts) on each request. The clause structure and formatting stay identical while the terms change per contract.
How do I avoid generating a duplicate contract PDF?
Include an idempotencyKey (for example the contract number). A repeat request with the same key returns the stored result instead of re-rendering or re-billing, so retries from a flaky network are always safe.
How is contract PDF generation priced?
Pricing is per document, not per page. A one-page NDA and a ten-page master services agreement with exhibits count the same, so long-form contracts never cost extra.
Ready to generate contract PDFs in production?
Get an API key