> ## Documentation Index
> Fetch the complete documentation index at: https://signatureapi-daf4ee54.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Generate documents programmatically using templates and dynamic data.

When defining a document resource within an envelope, you have two options: using documents or templates.

<Note>If you want to add signature places or dynamic data, such as the time a recipient signed, see [Places](/docs/integrations/power-automate/places/place).</Note>

## Documents vs Templates

### Documents

If you have a PDF document ready you can simply provide the file in the **File Content** field of the [Add a document : PDF](/docs/integrations/power-automate/actions/add-document#param-file-content) action. This is a static document, meaning it will not change based on the data you provide.

### Templates

SignatureAPI can generate documents programmatically from a static template combined with dynamic data.

We accept templates in the <Tooltip tip="Office Open XML Document">DOCX format</Tooltip>, which is widely supported by software such as Microsoft Word, Google Docs, and open-source productivity suites like [LibreOffice](https://www.libreoffice.org/).

<Tip>DOCX files created with software other than Microsoft Word (like Google Docs or LibreOffice) may not be processed correctly. If you get a [cannot-parse-document](/docs/v1/errors/cannot-parse-document) error, try opening the file in Microsoft Word and saving it again. If you don’t have Microsoft Word, contact support for help.</Tip>

Within the template, you can add [fields](#fields) and [conditionals](#conditionals). To add a document template to an envelope, use the [Add a template](/docs/integrations/power-automate/actions/add-template) action. This action allows you to upload a DOCX file and specify the data to be inserted into the template.

#### Example

Consider a template like this:

<div className="border p-2">
  This Dummy Agreement is entered into by \{\{person.name}}, currently residing at \{\{person.address}}. The terms and conditions outlined in this agreement shall be governed by the laws of \{\{jurisdiction}}.

  \{\{if mediation}}<br />
  Any dispute shall be resolved by mediation, with each party bearing its own costs.<br />
  \{\{else}}<br />
  Any dispute shall be settled by arbitration, and the arbitrator's decision is final.<br />
  \{\{endif}}
</div>

When data is inserted:

<Frame>
  <img src="https://mintcdn.com/signatureapi-daf4ee54/5kf_xnmgDccjHgkV/docs/integrations/power-automate/images/document-templates-full.png?fit=max&auto=format&n=5kf_xnmgDccjHgkV&q=85&s=952c78c15c11f9e1fb60b5121c41ff60" alt="" width="2992" height="1717" data-path="docs/integrations/power-automate/images/document-templates-full.png" />
</Frame>

You get this document:

<div className="border p-2">
  This Dummy Agreement is entered into by Sherlock Holmes, currently residing at 221b Baker Street, London. The terms and conditions outlined in this agreement shall be governed by the laws of The United Kingdom.

  Any dispute shall be settled by arbitration, and the arbitrator's decision is final.<br />
</div>

## Fields

Fields are markers within a template that indicate where specific information should be inserted. They are defined within your template with **double curly braces**, for example: `{{name}}`.

For example, a template:

<div className="border p-2">
  This Dummy Agreement is entered into by \{\{name}}.
</div>

With data:

<Frame>
  <img src="https://mintcdn.com/signatureapi-daf4ee54/5kf_xnmgDccjHgkV/docs/integrations/power-automate/images/document-templates-field.png?fit=max&auto=format&n=5kf_xnmgDccjHgkV&q=85&s=89d302b20012097d846f8ad3c449e368" alt="" width="2992" height="1717" data-path="docs/integrations/power-automate/images/document-templates-field.png" />
</Frame>

Will return the document:

<div className="border p-2">
  This Dummy Agreement is entered into by Sherlock Holmes.
</div>

### Nested objects

You can use nested objects in the data value. For example, a template:

<div className="border p-2">
  This Dummy Agreement is entered into by \{\{person.name}}, currently residing at \{\{person.address.houseNumber}} \{\{person.address.streetName}}, \{\{person.address.city}}.
</div>

With a data value:

<Frame>
  <img src="https://mintcdn.com/signatureapi-daf4ee54/5kf_xnmgDccjHgkV/docs/integrations/power-automate/images/document-templates-nested.png?fit=max&auto=format&n=5kf_xnmgDccjHgkV&q=85&s=b97983e47918a8faefffe61336a29920" alt="" width="2992" height="1717" data-path="docs/integrations/power-automate/images/document-templates-nested.png" />
</Frame>

Will return the document:

<div className="border p-2">
  This Dummy Agreement is entered into by Sherlock Holmes, currently residing at 221b Baker Street, London.
</div>

## Conditionals

Conditionals in templates allow for the inclusion or exclusion of content based on certain conditions.

### If

You can use `{{if Condition}}` and `{{endif}}` to show or hide the content in between, depending on whether `Condition` is true or not.

For example, a template:

<div className="border p-2">
  Please read before proceeding.

  \{\{if showDisclaimer}}<br />
  Information provided is for educational purposes only and should not be considered as professional advice.<br />
  \{\{endif}}

  Use at your own discretion.
</div>

With the data value:

<Frame>
  <img src="https://mintcdn.com/signatureapi-daf4ee54/5kf_xnmgDccjHgkV/docs/integrations/power-automate/images/document-templates-conditional-true.png?fit=max&auto=format&n=5kf_xnmgDccjHgkV&q=85&s=f3c76d0a30d985f2e9d17964f932f116" alt="" width="2992" height="1717" data-path="docs/integrations/power-automate/images/document-templates-conditional-true.png" />
</Frame>

Will return the document:

<div className="border p-2">
  Please read before proceeding.<br />

  Information provided is for educational purposes only and should not be considered as professional advice.<br />

  Use at your own discretion.<br />
</div>

But with the data value:

<Frame>
  <img src="https://mintcdn.com/signatureapi-daf4ee54/5kf_xnmgDccjHgkV/docs/integrations/power-automate/images/document-templates-conditional-false.png?fit=max&auto=format&n=5kf_xnmgDccjHgkV&q=85&s=2e2e760951d9042dd6f349f4d0fb7070" alt="" width="2992" height="1717" data-path="docs/integrations/power-automate/images/document-templates-conditional-false.png" />
</Frame>

Will return the document:

<div className="border p-2">
  Please read before proceeding.

  Use at your own discretion.
</div>

### If-Else

You can use `{{if Condition}}`, `{{else}}`, and `{{endif}}` to conditionally display content based on whether `Condition` is true or false."

For example, a template:

<div className="border p-2">
  \{\{if mediation}}<br />
  Any dispute shall be resolved by mediation, with each party bearing its own costs.<br />
  \{\{else}}<br />
  Any dispute shall be settled by arbitration, and the arbitrator’s decision is final.<br />
  \{\{endif}}<br />
</div>

With data:

<Frame>
  <img src="https://mintcdn.com/signatureapi-daf4ee54/5kf_xnmgDccjHgkV/docs/integrations/power-automate/images/document-templates-conditional-true.png?fit=max&auto=format&n=5kf_xnmgDccjHgkV&q=85&s=f3c76d0a30d985f2e9d17964f932f116" alt="" width="2992" height="1717" data-path="docs/integrations/power-automate/images/document-templates-conditional-true.png" />
</Frame>

Will return the document:

<div className="border p-2">
  Any dispute shall be resolved by mediation, with each party bearing its own costs.
</div>

But with data:

<Frame>
  <img src="https://mintcdn.com/signatureapi-daf4ee54/5kf_xnmgDccjHgkV/docs/integrations/power-automate/images/document-templates-conditional-false.png?fit=max&auto=format&n=5kf_xnmgDccjHgkV&q=85&s=2e2e760951d9042dd6f349f4d0fb7070" alt="" width="2992" height="1717" data-path="docs/integrations/power-automate/images/document-templates-conditional-false.png" />
</Frame>

Will return the document:

<div className="border p-2">
  Any dispute shall be settled by arbitration, and the arbitrator’s decision is final.
</div>
