Skip to main content
A template is the foundation of every signing workflow in DocuTrust. It combines a source document (PDF, DOCX, or HTML) with a field schema that defines what data signers need to provide and where it appears on the document.

Template object

Every template returned by the API includes these fields:

Submitter roles

Every template defines one or more submitter roles. Each role represents a party who will sign or fill fields in the document. When creating a submission, you map real people to these roles.

Field schema

The schema array defines every fillable field in the template. Each field specifies its type, position on the document, which submitter role it belongs to, and optional defaults or constraints.

Field properties

Field areas

Each field has one or more areas defining its visual position on the document pages.

Field types

DocuTrust supports 19 field types:

Field validation

Add validation rules to text fields to enforce specific input formats. Validation is checked when the signer submits their form — invalid values display an error message and prevent completion until corrected. There are two ways to add validation to a field:
  1. Preset validation — Use the validation property with a preset name for common patterns (SSN, email, phone, etc.).
  2. Custom regex — Use the pattern property with any regular expression string for custom formats.

Example: field with preset validation

Example: field with custom regex pattern

Validation presets

DocuTrust includes 11 built-in validation presets. Use the validation property on a text field to apply one:
When both validation and pattern are set on a field, the pattern regex takes precedence. The validation preset is ignored in that case.
Validation only applies to text and cells field types. Other field types (date, number, select, etc.) have their own built-in format enforcement.

Creating templates

From PDF

Upload one or more PDF files to create a template. DocuTrust extracts pages and creates a blank field schema that you can populate later.

From DOCX

Upload a Word document. DocuTrust converts it to PDF internally while preserving layout and formatting.

From HTML

Send raw HTML to create a template. This is useful for programmatically generating documents with dynamic layouts.
Use double-brace tokens like {{invoice_number}} in your HTML. These can be pre-filled via the API when creating submissions.

Retrieving templates

Get a single template

Response:

List all templates

Results are paginated using cursor-based pagination. See the Pagination guide for details. Response:

Filter by folder

Filter by external ID

Updating templates

Update a template’s name, schema, submitters, folder, or sharing settings with a PUT request.
Updating the schema or submitters replaces the entire array. Always include all fields and roles you want to keep, not just the ones you are changing.

Fixing auto-mapping safely (API)

If AI smart setup assigned fields to the wrong submitter, use these endpoints instead of replacing the full schema:
  • POST /api/templates/{id}/validate_assignments — dry-run validator
  • POST /api/templates/{id}/remap_submitters — apply targeted remaps

1) Validate proposed remap

2) Preview remap (dry_run)

3) Apply remap

Validation checks returned by API

The validator returns structured issues such as:
  • unknown_field_uuid
  • unknown_submitter_uuid
  • duplicate_field_assignment
  • submitter_without_fields
  • required_submitter_missing_signature

Cloning templates

Create an independent copy of an existing template. The clone gets a new ID and slug but inherits the schema, submitters, and documents.
Response:
The cloned template gets new submitter UUIDs. If you have code that references the original UUIDs, update it to use the new ones.

Merging templates

Combine two or more templates into a single document. This is useful for assembling contracts from modular sections (e.g., terms + addendum + signature page).
Response:
Templates are merged in the order provided. Fields and pages from the second template appear after the first.

AI field detection

DocuTrust can automatically analyze a template’s document and detect where fields should be placed. This is especially useful for complex PDFs with many signature lines, date fields, and text blanks.
The AI analyzes the document, identifies field locations, assigns appropriate types, and updates the template schema. You can review and adjust the detected fields in the template builder or via the API. Additional AI endpoints:

Managing documents

Replace or add documents

Upload new documents to an existing template:

Download a document PDF

Retrieve the original uploaded document:

Thumbnails

Get a thumbnail image of the first page:
If a thumbnail has not been generated yet, trigger generation manually:

Archiving templates

Archive a template to remove it from active use. Archived templates are not deleted — existing submissions remain intact — but no new submissions can be created from them.
This uses the HTTP DELETE method but performs a soft archive, not a permanent deletion. The template can still be retrieved via the API using its ID.

Formula fields

Formula fields compute their value dynamically from other fields using arithmetic expressions. Use them for calculated totals, taxes, discounts, and other derived values.

Formula syntax

Add a formula property to any number field in the template schema. The formula can reference other fields by name using {Field Name} syntax and supports standard arithmetic operators.

Supported operators

Full example: invoice with tax

Formula evaluation uses safe arithmetic parsing — no arbitrary code execution. Only numeric values, field references, arithmetic operators, and parentheses are allowed. Division by zero returns 0.
Formula fields are typically set to readonly: true so the signer sees the computed value but cannot edit it. If you leave readonly: false, the signer can override the calculated value.

Dynamic payment pricing

Combine formula fields with the payment field type to compute dynamic payment amounts based on signer input:

Conditional document display

Control which documents in a multi-document template are shown to the signer based on field values. Use the document_conditions property in the template preferences to define conditions.

Configuration

Set document_conditions in the template preferences via PUT /api/templates/:id:

Condition properties

Full example

A template with three documents — a base agreement, a premium addendum, and an enterprise addendum — where the addenda are shown conditionally based on the plan selection:
When the signer selects “Premium” from the Payment Method field (or any select/radio field referenced by field_uuid), document 43 (the premium addendum) is displayed. When they select “Enterprise”, document 44 is shown instead. The base agreement document (without a condition) is always shown.
Conditions are evaluated in real time as the signer fills in fields. Documents appear or disappear dynamically without page reload.

Document upload limits

Each decoded PDF, DOCX, or HTML source is limited to 25 MB by default, and each generated PDF is limited to 100 pages. Multipart uploads are checked before reading, while Base64 uploads use strict decoding and are checked both before and after decoding. DOCX and HTML sources are checked before conversion; the resulting PDF is page-checked before any template or document is stored. An over-limit request returns 422 naming the file and applicable limit. Self-hosted operators may adjust MAX_DOCUMENT_SIZE_MB and MAX_DOCUMENT_PAGES; invalid or non-positive values fall back to the defaults above.