Skip to content
Leadtime
English
Esc
↑↓navigate↵open⌘Jpreview

Partially update document template

Updates only the content and/or custom variables of a document template. All other fields remain unchanged.

What can be updated:

  • Template content (optional - only if provided)
  • Custom variables (optional - only if provided)
  • Metadata fields (name, description, language, type) are NOT updated via this endpoint

Content format: If provided, content should be HTML or Markdown with support for:

  • Rich text formatting (headings, lists, tables, etc.)
  • System variables (e.g., #project.name, #organization.companyName)
  • Custom variables (defined in the customVariables array)
  • Conditional sections and page breaks

Using variables: Variables are represented as HTML spans: <span data-type="variable" data-id="project.name">...</span> Custom variables use: <span data-type="variable" data-id="custom.variable_name">...</span>

Custom variables: If provided, the entire custom variables array replaces the existing one. Each variable defines a template-specific field with name, type, optional default value, and required flag.

What is returned: The updated template with content converted to HTML format and all custom variables included.

Note: For full updates including metadata, use the PUT endpoint instead.

PATCH/administration/document-templates/{id}
Authorization
AuthorizationOAuth2 access token · headerrequired
Scopes:api:write
or
AuthorizationBearer token (JWT) · headerrequired
Path parameters
idstringrequired
Query parameters
fieldsToReturnstring

Comma-separated list of top-level response fields to return. Overrides the endpoint compact default unless responseShape=full is used.

responseShapestring

Advanced override. Omit for the endpoint compact default. Use full only when you need the complete endpoint response, including nested fields that are not selectable with fieldsToReturn.

Allowed:compactfull
Header parameters
LT-Response-Shapestring

Advanced override. Set to full only when you need the complete endpoint response, including nested fields that are not selectable with fieldsToReturn.

Allowed:full
Request body
requiredapplication/json
contentstringrequired

Accepts Markdown or HTML for complex formatting. This content is rendered by the Leadtime rich editor, not by a plain Markdown viewer.

For quick/simple text, Markdown is acceptable. For polished user-facing content from an agent or integration, prefer structured HTML because it preserves editor blocks, links, and layout more predictably.

Use only the nodes and marks documented below for this field. Supported editor features differ by endpoint and field. Choose formatting for readability, not decoration: use headings for real sections, paragraphs for narrative text, lists or tables for structured facts, blockquotes for quoted context, callouts for important outcomes/risks/notes when supported, and explicit anchors for links. Do not rely on bare URLs or Markdown links when the link must be clickable; use explicit anchors such as <a href="https://example.com" target="_blank" rel="noopener noreferrer nofollow">link text</a>.

In HTML you can use:

Node Types and Marks

Nodes

paragraph Type: block Content: inline* (inline only — do not use block tags such as <p> inside; use e.g. <br>, <strong>, <em>, <span>…) Default paragraph. extraPlaceholder is an internal structure for the editor to show a ghost placeholder in empty “template” lines (ProseMirror JSON fragment or null). For normal agent output leave extraPlaceholder as null. Only set it if you are intentionally mirroring a field placeholder the user already has in the open editor; do not set random placeholder data for free-form answers. Atts:

  • extraPlaceholder: null
<p class="paragraph-base" extraplaceholder="null/some-value"></p>

heading Type: block Content: inline* (inline only — do not use block tags such as <p> inside; use e.g. <br>, <strong>, <em>, <span>…) Atts:

  • level: 1
<h1 class="heading-base"></h1>

bulletList Type: block list Content: listItem+ Atts: none

<ul class="list-base"><li></li></ul>

hardBreak Type: inline Atts: none

<br>

horizontalRule Type: block Atts: none

<hr class="hr-base">

orderedList Type: block list Content: listItem+ Atts:

  • start: 1
  • type: null
<ol class="order-list-base" type="null/some-value"><li></li></ol>

listItem Content: (paragraph|list)* (paragraphs and/or lists, in any order) Atts: none

<li></li>

blockquote Type: block Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts: none

<blockquote class="blockquote-base"><p class="paragraph-base"></p></blockquote>

table Type: block Content: tableRow+ Atts: none

<table style="width: 0px;"><colgroup></colgroup><tbody><tr></tr></tbody></table>

tableRow Content: (tableCell | tableHeader)* Atts: none

<tr></tr>

tableHeader Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts:

  • colspan: 1
  • rowspan: 1
  • colwidth: null
  • align: null
<th colspan="1" rowspan="1" colwidth="null/some-value" style="text-align: null/some-value;"><p class="paragraph-base"></p></th>

tableCell Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts:

  • colspan: 1
  • rowspan: 1
  • colwidth: null
  • align: null
<td colspan="1" rowspan="1" colwidth="null/some-value" style="text-align: null/some-value;"><p class="paragraph-base"></p></td>

variable Type: inline Document/template variable token (span with data-type="variable" and data-id).

  • id: Variable key, often scoped (e.g. currentUser.firstName, project.name). Only use keys that exist for the document type you are in; product docs list the allowed variable ids. Do not invent new variable names in HTML for production templates. Atts:
  • id: null
<span data-type="variable" data-id="null/some-value" id="null/some-value"></span>

pageBreak Type: block Page break for PDF/print output (void <page-break> element). Inserts a hard page break when exporting. Use sparingly where the user asked for a new printed page, not for normal on-screen line breaks (use hardBreak/paragraphs instead). Atts: none

<page-break></page-break>

condition Type: block Content: conditionBody (a single condition body block) This node conditionally renders its content based on a set of rules. The rules are defined in the 'conditions' attribute. 'conditions' is an object like: { type: 'and' | 'or', expressions: Array<Expression | ConditionGroup> }. An 'Expression' is { field: string, operator: string, value: any }. A 'ConditionGroup' is a nested { type: 'and' | 'or', expressions: [...] }. Example for an expression: { field: 'invoice.total', operator: 'gt', value: 100 } means 'if invoice total is greater than 100'. Supported operators typically include: eq (equals), neq (not equals), gt (greater than), gte (greater than or equal to), lt (less than), lte (less than or equal to), contains, in, is_true, is_false, etc. Check editor UI for available fields and operators. ALL FIELDS CAN ONLY BE EXISTING VARIABLES. DO NOT INVENT NEW FIELDS. Atts:

  • conditions: { "type": "and", "expressions": [] }
<condition conditions="{&quot;type&quot;:&quot;and&quot;,&quot;expressions&quot;:[]}"><condition-body><p class="paragraph-base"></p></condition-body></condition>

conditionBody Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts: none

<condition-body><p class="paragraph-base"></p></condition-body>

Marks

link Atts:

  • href: null
  • target: _blank
  • rel: noopener noreferrer nofollow
  • class: null
  • title: null
<a target="_blank" rel="noopener noreferrer nofollow" href="">link text example</a>

bold Atts: none

<strong>bold text example</strong>

code Atts: none

<code>code text example</code>

italic Atts: none

<em>italic text example</em>

strike Atts: none

<s>strike text example</s>

underline Atts: none

<u>underline text example</u>

Available Template Variables

You can use the following variables in your document templates. Variables are represented as HTML spans:

workspace: workspace.vat, workspace.hourRate, workspace.invoiceDaysTillOverdue, workspace.standardReminderFee, workspace.baseInterestRate, workspace.interestRate company: company.companyName, company.legalForm, company.country, company.zip, company.city, company.street, company.houseNumber, company.phone, company.email, company.website, company.fax, company.taxNumber, company.registrationNumber, company.registrationCourt organization: organization.companyName, organization.shortName, organization.legalForm, organization.description, organization.country, organization.zip, organization.city, organization.street, organization.houseNumber, organization.phone, organization.email, organization.website, organization.fax, organization.taxNumber, organization.registrationNumber, organization.registrationCourt, organization.hourRate, organization.invoiceDaysTillOverdue, organization.standardReminderFee, organization.baseInterestRate, organization.interestRate project: project.name, project.category, project.status, project.defaultAccountable, project.country, project.projectId, project.activeVersionId, project.activeVersionName currentUser: currentUser.title, currentUser.degree, currentUser.email, currentUser.firstName, currentUser.lastName, currentUser.country, currentUser.zip, currentUser.city, currentUser.street, currentUser.houseNr, currentUser.birthday, currentUser.phone, currentUser.signature recipient: recipient.firstName, recipient.lastName, recipient.position, recipient.gender, recipient.title, recipient.degree, recipient.birthdate, recipient.activeVersionName, recipient.country, recipient.zip, recipient.city, recipient.street, recipient.houseNumber, recipient.phone, recipient.email, recipient.socialNetwork macros: macros.todaysDate, macros.dearCustomer

Example HTML: <span data-type="variable" data-id="currentUser.firstName">John</span>, <span data-type="variable" data-id="project.name">Website Redesign</span>

customVariablesDocumentCustomVariableDto[]

Custom variables define template-specific placeholders that extend beyond standard system variables. Each variable can be referenced in the template content using <span data-type="variable" data-id="custom.variable_name">...</span> syntax. When generating a document from this template, users will be prompted to fill in these values. Variables support different types (Text, Number, Date, Boolean, Select, MultiSelect) and can be marked as required. If provided, the entire custom variables array replaces the existing one.

Show properties
Array of DocumentCustomVariableDto
descriptionstring

Human-readable label/description for this variable. This is displayed to users when they are prompted to fill in the variable value when generating a document.

idstring

Variable ID (UUID). Only required when updating an existing variable. Omit when creating a new variable.

namestringrequired

Variable name/key used to reference this variable in the template content. Use lowercase with underscores (e.g., "client_name", "project_budget"). This name is used in the variable reference: custom.variable_name.

optionsstring[]

Available options for Select or MultiSelect variable types. For Select, users choose one option. For MultiSelect, users can choose multiple options. This field is ignored for other variable types.

requiredboolean

Whether this variable must be filled in when generating a document from the template. If true, users cannot proceed without providing a value. If false, the variable is optional.

default: false
typestringrequired

The data type of this variable. Determines what kind of input is expected and how the value is validated. Available types: Text (short text), LongText (multi-line text), Number (numeric value), Date (date/time), Boolean (true/false), Select (single choice from options), MultiSelect (multiple choices from options).

Allowed:TextLongTextNumberDateBooleanSelectMultiSelect
valuestring | number | boolean | string[]

Default value for this variable. The type of value depends on the variable type: - Text/LongText/Select: string

  • Number: number
  • Boolean: boolean
  • Date: ISO 8601 date string (e.g., "2024-01-15")
  • MultiSelect: array of strings

This value is pre-filled when generating a document, but users can override it.

Show properties
One of:
string
string
number
number
boolean
boolean
string[]
Array of string
string
Responses
200
contentstringrequired

Template content as HTML. The content includes static text, formatting, and variable placeholders. Variables are represented as HTML spans: <span data-type="variable" data-id="project.name">...</span>. The content may also include conditional sections and page breaks.

createdAtstring<date-time>required

ISO 8601 timestamp when the template was created

createdBystringrequired

User ID of the user who created this template

descriptionstringrequired

A brief description explaining the purpose or use case of this template

documentCustomVariablesobject[]required

Array of custom variables defined for this template. Custom variables extend beyond standard system variables and allow template-specific placeholders. Each variable includes its type, default value (if any), options (for Select/MultiSelect), and whether it is required when generating documents from this template.

idstringrequired

Unique identifier for the document template (UUID)

languagestringrequired

ISO 639-1 language code for the template (e.g., "en", "de")

namestringrequired

The name/title of the document template

typestringrequired

The type of document this template generates

Allowed:ProjectDocument
updatedAtstring<date-time>required

ISO 8601 timestamp when the template was last updated

updatedByobject | nullrequired

User ID of the user who last updated this template (null if never updated)

workspaceIdstringrequired

The workspace ID this template belongs to

401

Unauthorized - Invalid or missing authentication token

403

Forbidden - Insufficient API scopes or permissions

Try it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X PATCH "https://leadtime.app/api/public/administration/document-templates/string" \
  -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
    }
  ]
}'
Response
{
  "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"
}