curl https://api.dynamicdocumentapi.com/v1/pdf/from-template \
-H "Authorization: Bearer $DYNAMIC_DOCUMENT_API_KEY" \
-H "Idempotency-Key: CERT-2026-0481" \
-H "Content-Type: application/json" \
-d '{
"template_id": "tpl_certificate",
"data": {
"recipient": "Ada Lovelace",
"course": "Data Engineering 101",
"completed_on": "2026-09-25",
"hours": 24,
"certificate_id": "CERT-2026-0481",
"verify_url": "https://academy.example.com/verify/CERT-2026-0481",
"signed_by": "Dr. Erin Cole, Head of Academy"
},
"pdf": {
"paper": { "format": "A4" },
"orientation": "landscape",
"margin": { "top": "0mm", "right": "0mm", "bottom": "0mm", "left": "0mm" },
"metadata": { "title": "Certificate — Ada Lovelace" }
},
"filename": "CERT-2026-0481.pdf"
}'
// Node.js 18+: one participant → certificate PDF + shareable PNG
const API = "https://api.dynamicdocumentapi.com/v1";
async function render(path, body, key) {
const res = await fetch(API + path, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DYNAMIC_DOCUMENT_API_KEY}`,
"Idempotency-Key": key,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(await res.text());
return (await res.json()).files[0].url;
}
export async function issueCertificate(data) {
const base = { template_id: "tpl_certificate", data };
const [pdf, image] = await Promise.all([
render("/pdf/from-template", { ...base,
pdf: { paper: { format: "A4" }, orientation: "landscape" },
}, data.certificate_id + "-pdf"),
render("/images/from-template", { ...base,
image: { format: "png", viewport: { width: 1600, height: 1131 }, scale: 2 },
}, data.certificate_id + "-png"),
]);
return { pdf, image };
}
import csv, os
import requests
API = "https://api.dynamicdocumentapi.com/v1"
AUTH = {"Authorization": f"Bearer {os.environ['DYNAMIC_DOCUMENT_API_KEY']}"}
def issue_certificate(row: dict) -> str:
"""One participant → one certificate PDF. Returns a signed link."""
res = requests.post(
f"{API}/pdf/from-template",
headers={**AUTH, "Idempotency-Key": row["certificate_id"]},
json={
"template_id": "tpl_certificate",
"data": row,
"pdf": {"paper": {"format": "A4"}, "orientation": "landscape"},
"filename": f"{row['certificate_id']}.pdf",
},
timeout=60,
)
res.raise_for_status()
return res.json()["files"][0]["url"]
with open("cohort.csv") as f:
for row in csv.DictReader(f):
print(row["recipient"], issue_certificate(row))
<?php
function issueCertificate(array $participant): 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: ' . $participant['certificate_id'],
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'template_id' => 'tpl_certificate',
'data' => $participant,
'pdf' => [
'paper' => ['format' => 'A4'],
'orientation' => 'landscape',
],
'delivery' => 'binary', // attach it to the completion email
]),
]);
return curl_exec($ch); // PDF bytes
}