Skip to main content
POST
Create DocumentTemplate
A DocumentTemplate is a location-scoped reusable layout for generating customer, booking, contract, and proposal documents. Designer templates (Editor = Designer) are authored as a design (DesignJson) with fields, conditions, repeats and signature blocks for a DataContext and compiled to Liquid HTML; Classic templates use Liquid source or an uploaded mail-merge document.

Authentication

This endpoint requires OAuth2 authentication. Include a valid bearer token in the Authorization header. The authenticated user must be a full unrestricted administrator or have the DocumentTemplate-Create role.

Enums

Request Body

Required Fields

integer
required
ID of the required location that owns this document template; only operators linked to that location can see or use it..
string
required
Required name used to identify this document template to operators; also used as the file name of documents generated from it..
integer
required
Selects the generated format: Html, Word (Liquid source converted to a Word document) or Binary (the uploaded BinaryDocument used for mail merge, so it only makes sense together with an uploaded file). Saving a Designer template forces this back to Html..
integer
required
Which editor owns the template: Classic (uploaded Word document merged with TX Text Control, or raw Liquid HTML) or Designer (a design authored in the Document Designer and compiled to Liquid HTML). Designer templates require DataContext and DesignJson, are validated and compiled on every save, and have TemplateOutputFormat forced to Html and any uploaded BinaryDocument cleared..
integer
required
What the template is about: Customer, Contract, Proposal or Booking. Decides which data roots (Location, Customer, Contract, Proposal, Booking) the design can use. Designer templates must set one of the four; saving a Designer template while this is Unspecified is rejected. Classic templates leave it Unspecified..

Optional Fields

string
Liquid HTML source rendered for Classic templates when TemplateOutputFormat is Html or Word. The variables available come from the data context built for the record the document is generated for (Location, Customer, Contract, Proposal and Booking roots), falling back to a small legacy set when no context can be built. For Designer templates this is generated from DesignJson on every save, so any value sent here is overwritten; change DesignJson instead..
string
URL of a new file to upload as the binary document.
boolean
Set to true to remove the current binary document file.
string
Document Designer design (JSON, schema version 1) for Designer templates, holding the blocks, fields, conditions, repeats and signature blocks. Validate it with the document_template_designer tool before saving; the platform validates it again and compiles it into Document (Liquid HTML) on save, and a failed validation aborts the save. Ignored for Classic templates..

Code Examples

Response

200

integer
HTTP status code. 200 on success.
string
A human-readable message confirming the creation.
object
Contains the Id of the newly created record.
boolean
true if the documenttemplate was created successfully.
array
null on success.
Example Response

400

string
A summary of the validation error(s), in the format PropertyName: error message.
any
null on validation failure.
object[]
Array of validation errors.
boolean
false when the request fails validation.
Example Response