Template Management
Templates define the structure and content of generated documents. This guide covers creating, updating, versioning, and promoting templates.
Creating a Template
- cURL
- JavaScript
curl -X POST "https://api.propper.ai/v1/docgen/templates" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Letter",
"description": "New customer welcome letter",
"content": "<h1>Welcome, {{customerName}}!</h1><p>Your account ({{accountId}}) is ready.</p>",
"format": "HTML"
}'
const response = await fetch('https://api.propper.ai/v1/docgen/templates', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Welcome Letter',
description: 'New customer welcome letter',
content:
'<h1>Welcome, {{customerName}}!</h1><p>Your account ({{accountId}}) is ready.</p>',
format: 'HTML',
}),
});
const template = await response.json();
Updating a Template
Update a template's name, description, or content. This creates a new version automatically.
- cURL
- JavaScript
curl -X PATCH "https://api.propper.ai/v1/docgen/templates/{templateId}" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Letter v2",
"content": "<h1>Welcome, {{customerName}}!</h1><p>Your account ({{accountId}}) is active since {{startDate}}.</p>"
}'
const response = await fetch(
`https://api.propper.ai/v1/docgen/templates/${templateId}`,
{
method: 'PATCH',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Welcome Letter v2',
content:
'<h1>Welcome, {{customerName}}!</h1><p>Your account ({{accountId}}) is active since {{startDate}}.</p>',
}),
},
);
Archiving a Template
Archive a template to prevent it from being used in new document generation. Requires docgen:admin scope.
curl -X POST "https://api.propper.ai/v1/docgen/templates/{templateId}/archive" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Template Versioning
Create a New Version
curl -X POST "https://api.propper.ai/v1/docgen/templates/{templateId}/versions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "<h1>Updated content for {{customerName}}</h1>",
"changeNotes": "Updated header formatting"
}'
List Versions
curl "https://api.propper.ai/v1/docgen/templates/{templateId}/versions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response:
{
"data": [
{
"id": "ver_001",
"version": 3,
"changeNotes": "Updated header formatting",
"createdAt": "2024-01-17T10:00:00Z"
},
{
"id": "ver_002",
"version": 2,
"changeNotes": "Added start date field",
"createdAt": "2024-01-16T10:00:00Z"
}
]
}
Restore a Version
Restore a previous version to make it the active version.
curl -X POST "https://api.propper.ai/v1/docgen/templates/{templateId}/versions/{versionId}/restore" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Cloning a Template
Create a copy of an existing template.
curl -X POST "https://api.propper.ai/v1/docgen/templates/{templateId}/clone" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Letter (Copy)"
}'
Promoting Templates
Promote a template between environments (DEV, TEST, PROD). Requires docgen:admin scope and may trigger an approval workflow.
curl -X POST "https://api.propper.ai/v1/docgen/templates/{templateId}/promote" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"targetEnvironment": "PROD"
}'
If approval is required, the response includes a pending approval:
{
"id": "tmpl_abc123",
"promotionStatus": "PENDING_APPROVAL",
"approvalId": "apr_def456"
}
See the Approvals Guide for managing approval workflows.