curl https://api.dynamicdocumentapi.com/v1/pdf/from-template \
-H "Authorization: Bearer $DYNAMIC_DOCUMENT_API_KEY" \
-H "Idempotency-Key: acme-2026-Q3" \
-H "Content-Type: application/json" \
-d '{
"template_id": "tpl_quarterly_report",
"data": {
"client": "Acme Co.",
"period": "Q3 2026",
"locale": "en-US",
"currency": "USD",
"kpis": { "revenue": 482150.00, "orders": 1284, "growth": 0.18 },
"series": [82000, 97400, 113200, 140550],
"rows": [ { "channel": "Search", "sessions": 48120, "revenue": 190400 } ]
},
"pdf": {
"paper": { "format": "A4" },
"margin": { "top": "22mm", "bottom": "18mm" },
"outline": true,
"tagged": true,
"footer": { "enabled": true,
"left": "Acme Co. · Q3 2026",
"right": "Page {{page}} of {{pages}}" },
"wait": { "until": "selector", "selector": "#charts[data-ready]",
"timeout_ms": 20000, "strict": false }
},
"filename": "acme-q3-2026.pdf"
}'
// Node.js 18+: render one client report and return the signed link
export async function renderReport(client, period, data) {
const res = await fetch("https://api.dynamicdocumentapi.com/v1/pdf/from-template", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DYNAMIC_DOCUMENT_API_KEY}`,
"Idempotency-Key": `${client}-${period}`, // one report per period
"Content-Type": "application/json",
},
body: JSON.stringify({
template_id: "tpl_quarterly_report",
data,
pdf: {
outline: true,
tagged: true,
footer: { enabled: true, right: "Page {{page}} of {{pages}}" },
wait: { until: "selector", selector: "#charts[data-ready]" },
},
filename: `${client}-${period}.pdf`,
}),
});
if (!res.ok) throw new Error(await res.text());
const render = await res.json();
return render.files[0].url; // signed link, 1 hour by default
}
import os
import requests
def render_report(client: str, period: str, data: dict) -> bytes:
res = requests.post(
"https://api.dynamicdocumentapi.com/v1/pdf/from-template",
headers={
"Authorization": f"Bearer {os.environ['DYNAMIC_DOCUMENT_API_KEY']}",
"Idempotency-Key": f"{client}-{period}",
},
json={
"template_id": "tpl_quarterly_report",
"data": data,
"pdf": {
"outline": True, # PDF bookmarks per section
"tagged": True, # structure for screen readers
"footer": {"enabled": True, "right": "Page {{page}} of {{pages}}"},
"wait": {"until": "selector", "selector": "#charts[data-ready]"},
},
"delivery": "binary", # PDF bytes, ready to attach
},
timeout=120,
)
res.raise_for_status()
return res.content
<?php
function renderReport(string $client, string $period, array $data): string
{
$ch = curl_init('https://api.dynamicdocumentapi.com/v1/pdf/from-template');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('DYNAMIC_DOCUMENT_API_KEY'),
'Idempotency-Key: ' . $client . '-' . $period,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'template_id' => 'tpl_quarterly_report',
'data' => $data,
'pdf' => [
'outline' => true,
'footer' => ['enabled' => true, 'right' => 'Page {{page}} of {{pages}}'],
'wait' => ['until' => 'selector', 'selector' => '#charts[data-ready]'],
],
'delivery' => 'binary',
]),
]);
return curl_exec($ch); // PDF bytes
}