Template drafts
Agents can create, update, and preview template drafts programmatically. Publishing to production always requires a human action in the dashboard.
Drafts are sandboxed — they never affect your live templates until you click Publish in the dashboard. Agents can freely iterate on drafts without risk.
Draft lifecycle
1
create_template_draft
Creates a new draft with a name, HTML, and optional CSS. Returns a draftId.
2
update_template_draft
Iteratively refine the draft. Pass only the fields you want to change.
3
preview_template_draft
Render the draft with sample data. Returns a short-lived preview URL (1 hour expiry).
4
Publish in the dashboard
Open the draft in the template editor and click Publish. The template becomes available via the generate endpoint.
Parameters — create_template_draft
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | required | Display name for the draft |
html | string | required | Handlebars HTML template |
css | string | optional | Scoped CSS for the template |
schema | object | optional | JSON Schema describing expected data shape |
// 1. Create a draft
const draft = await pdfox.create_template_draft({
name: 'Monthly Report',
html: '<h1>{{title}}</h1><p>{{body}}</p>',
css: 'h1 { font-size: 24pt; color: #1a1a1a; }',
});
// 2. Preview with sample data
const preview = await pdfox.preview_template_draft({
draftId: draft.draftId,
data: { title: 'Q2 Report', body: 'Revenue up 12%.' },
});
// 3. Publish from the dashboard
console.log('Preview URL:', preview.url);