A Document Template is the file that defines the layout and appearance of your generated output. You author it in a familiar tool — Microsoft Word, Excel, PowerPoint, Google Docs, Google Sheets, or Google Slides — and enrich it with Elements and Expressions that tell Doctavian where and how to inject data at generation time.
Templates are reusable. A single template can be attached to several Document Solutions, and a single Document Solution can have several templates — useful when the same data needs to produce different layouts.
Doctavian supports seven template formats across Microsoft and Google ecosystems:
fileFormat | Authoring tool | Where the file can live |
|---|---|---|
docx | Microsoft Word | Storage or OneDrive |
xlsx | Microsoft Excel | Storage or OneDrive |
xlsm | Microsoft Excel (macro-enabled) | Storage or OneDrive |
pptx | Microsoft PowerPoint | Storage or OneDrive |
gdoc | Google Docs | Google Drive only |
gsheet | Google Sheets | Google Drive only |
gslide | Google Slides | Google Drive only |
Every template can produce a PDF. See Supported File Formats for the full list of output types each can produce.
Templates are authored by embedding merge fields and elements directly in the document, right where you'd normally create it. That's also where it's stored and edited — Doctavian only ever receives a temporary copy for generation (see Where template files live).
Merge fields follow the notation {!Object.FieldName} and are replaced with real values at generation time. Object and FieldName are the list and field names in your data. Elements handle more complex rendering logic — repeating rows, conditional sections, images, barcodes, and more — using their own tag syntax. See the Elements Reference and Expressions Reference for the full syntax and available functions.
Create your Word document, Excel workbook, or PowerPoint deck exactly as you normally would. Then go through it and swap in merge fields wherever real data should appear, add elements for anything that needs to repeat or render conditionally, and layer in expressions wherever a value needs formatting or logic. Once that's done, your template is ready to be uploaded or referenced for generation.
Create your Google Doc, Sheet, or Slide deck exactly as you normally would. Then go through it and swap in merge fields wherever real data should appear, add elements for anything that needs to repeat or render conditionally, and layer in expressions wherever a value needs formatting or logic. Once that's done, your template is ready to be referenced for generation from Google Drive.
On the Salesforce-connected platform, an Add-in (Word, Excel) and Add-on (Docs, Sheets) help you browse fields and insert elements without typing the notation by hand — a shortcut, not a requirement. Neither supports PPTX or Slides. See the Maven Documents guide if you're using them.
A template can pull in content from other templates with the Include element. When generating through the API, list each included template in template.relatedItems on the generate request, with a name that matches the reference the Include element uses exactly. Otherwise the include resolves to nothing.
| Location | How to reference it | Retention |
|---|---|---|
| Storage | Upload with POST /documents/template/upload (.docx, .xlsx or .pptx) and use the returned id as urn with loadMethod: "Storage" | Held for 24 hours, and removed sooner by the first generation that reads it — whether it succeeds or fails |
| OneDrive | The OneDrive file id as urn with loadMethod: "OneDrive" | Stays on the drive |
| Google Drive | The Google Drive file id as urn with loadMethod: "GoogleDrive" | Stays on the drive |
| Any URL | A direct download url instead of urn + loadMethod | Downloaded into memory for each generation |
Drive files must be accessible to the drive account associated with the caller, or the request fails. See Storage and File IDs for retention and connected accounts.
For one-call generation you can reference a template file directly. To reuse a template by name with Document Solutions and Document Requests, register it as a template record:
POST https://api.doctavian.com/v1/documents/template/create
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"documentTemplate": {
"name": "Standard Invoice",
"description": "Company standard invoice layout.",
"title": "Invoice",
"urn": "9f86d081-884c-4d30-8934-9c1e6cbcb9f5",
"loadMethod": "Storage",
"fileFormat": "docx",
"documentSolutions": [ { "id": "6ccb8ca9-2952-4dbf-a4b0-4a48bdeb1922" } ]
}
}The record names where the file is (urn and loadMethod, or a url) and its format, which must agree with where it lives. Its title is written into the generated output's document properties; it is not the template's label. The record's id is at result.data.documentTemplate.id.
A template record does not hold a copy of the file. For a
Storagetemplate, the record survives after generation but itsurnstops resolving: upload the file again and update the record before the next run.PUT /documents/template/{documentTemplateId}/updateis a full replacement — send every field, not just the newurn. Templates on OneDrive or Google Drive are not affected.
Deleting a template record also removes it from every solution it was attached to. See the full set of template endpoints in the API Reference.
A template record describes the source file only. How a document is produced from it is set elsewhere:
document object: format, delivery, locale, time zone, and options such as PDF settings and drive sharing.See Locales and Timezones and PDF settings for the accepted values.
Ready to put this into practice? See Multi-locale Output for a step-by-step guide to configuring locale and language per request.
Template Labels allow you to define translatable text strings in your template. Instead of maintaining separate template files per language, you define labels once and map them to translations — Doctavian selects the right language at generation time based on the language field of the Document Solution Configuration used.