Create document template
Creates a new document template for generating standardized documents with dynamic content.
What are Document Templates? Document templates standardize recurring documents (contracts, cover letters, requirement specs) by combining static text with variables that get automatically replaced with actual values when generating documents in projects.
Step-by-step process:
- Provide template metadata (name, description, language, type)
- Define the template content as HTML or Markdown
- Optionally define custom variables for template-specific placeholders
- The system converts your content to internal format and stores the template
Content format: You can provide content as HTML or Markdown. The content supports:
- Rich text formatting (headings, lists, tables, bold, italic, etc.)
- System variables (e.g.,
#project.name,#organization.companyName,#currentUser.firstName) - Custom variables (defined in the
customVariablesarray) - Conditional sections that show/hide based on variable values
- Page breaks for document structure
Using variables in content:
Variables are represented as HTML spans: <span data-type="variable" data-id="project.name">...</span>
Custom variables use the format: <span data-type="variable" data-id="custom.variable_name">...</span>
Custom variables: Custom variables allow you to add template-specific fields that aren’t covered by standard system variables. Each variable has a name, type (Text, Number, Date, Boolean, Select, etc.), optional default value, and can be marked as required. When generating a document, users will be prompted to fill in these values.
What is returned: The created template with content converted back to HTML format and all custom variables included.
/administration/document-templatesAuthorizationOAuth2 access token · headerrequiredapi:writeAuthorizationBearer token (JWT) · headerrequiredfieldsToReturnstringresponseShapestringcompactfullLT-Response-Shapestringfullapplication/jsoncontentstringrequiredcustomVariablesDocumentCustomVariableDto[]Show propertiesHide properties
DocumentCustomVariableDtodescriptionstringidstringnamestringrequiredoptionsstring[]requiredbooleantypestringrequiredTextLongTextNumberDateBooleanSelectMultiSelectvaluestring | number | boolean | string[]Show propertiesHide properties
stringnumberbooleanstringstringdescriptionstringrequiredlanguagestringrequirednamestringrequiredtypestringrequiredProjectDocumentcontentstringrequiredcreatedAtstring<date-time>requiredcreatedBystringrequireddescriptionstringrequireddocumentCustomVariablesobject[]requiredidstringrequiredlanguagestringrequirednamestringrequiredtypestringrequiredProjectDocumentupdatedAtstring<date-time>requiredupdatedByobject | nullrequiredworkspaceIdstringrequiredcurl -X POST "https://leadtime.app/api/public/administration/document-templates" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "<h1>Project Overview</h1><p>Created by <span data-type=\"variable\" data-id=\"currentUser.firstName\">John</span> for <span data-type=\"variable\" data-id=\"project.name\">Website Redesign</span>.</p>",
"customVariables": [
{
"description": "Client company name",
"name": "client_name",
"required": true,
"type": "Text",
"value": "Acme Corporation"
},
{
"description": "Project budget in USD",
"name": "project_budget",
"required": false,
"type": "Number",
"value": 50000
}
],
"description": "Standard contract template for project agreements with custom payment terms",
"language": "en",
"name": "Project Contract Template",
"type": "ProjectDocument"
}'const response = await fetch("https://leadtime.app/api/public/administration/document-templates", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"content": "<h1>Project Overview</h1><p>Created by <span data-type=\"variable\" data-id=\"currentUser.firstName\">John</span> for <span data-type=\"variable\" data-id=\"project.name\">Website Redesign</span>.</p>",
"customVariables": [
{
"description": "Client company name",
"name": "client_name",
"required": true,
"type": "Text",
"value": "Acme Corporation"
},
{
"description": "Project budget in USD",
"name": "project_budget",
"required": false,
"type": "Number",
"value": 50000
}
],
"description": "Standard contract template for project agreements with custom payment terms",
"language": "en",
"name": "Project Contract Template",
"type": "ProjectDocument"
})
});import requests
response = requests.post(
"https://leadtime.app/api/public/administration/document-templates",
headers={
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
},
json={
"content": "<h1>Project Overview</h1><p>Created by <span data-type=\"variable\" data-id=\"currentUser.firstName\">John</span> for <span data-type=\"variable\" data-id=\"project.name\">Website Redesign</span>.</p>",
"customVariables": [
{
"description": "Client company name",
"name": "client_name",
"required": True,
"type": "Text",
"value": "Acme Corporation"
},
{
"description": "Project budget in USD",
"name": "project_budget",
"required": False,
"type": "Number",
"value": 50000
}
],
"description": "Standard contract template for project agreements with custom payment terms",
"language": "en",
"name": "Project Contract Template",
"type": "ProjectDocument"
},
){
"content": "<h1>Project Contract</h1><p>Project: <span data-type=\"variable\" data-id=\"project.name\">Website Redesign</span></p>",
"createdAt": "2024-01-15T10:30:00Z",
"createdBy": "123e4567-e89b-12d3-a456-426614174000",
"description": "Standard contract template for project agreements",
"documentCustomVariables": [
{
"description": "Client company name",
"id": "var-123",
"name": "client_name",
"options": [],
"required": true,
"type": "Text",
"value": "Acme Corp"
}
],
"id": "123e4567-e89b-12d3-a456-426614174000",
"language": "en",
"name": "Project Contract Template",
"type": "ProjectDocument",
"updatedAt": "2024-01-20T14:45:00Z",
"updatedBy": "123e4567-e89b-12d3-a456-426614174000",
"workspaceId": "123e4567-e89b-12d3-a456-426614174000"
}