> For the complete documentation index, see [llms.txt](https://docs.cw.crisisworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cw.crisisworks.com/security-and-support/technical-reference/merge-template-reference.md).

# Merge Template Reference

This page explains how smart templates work using HTML, CSS and tokens.

## Overview

The [Mail Merge Templates](https://docs.cw.crisisworks.com/system-administration/configuring-the-system/mail-merge-templates.md) system uses basic HTML along with some mail merge tokens and simple CSS to build the templates.

{% hint style="info" %}
For more information on general configuration see the [Mail Merge Templates](https://docs.cw.crisisworks.com/system-administration/configuring-the-system/mail-merge-templates.md) page.
{% endhint %}

### Capabilities

The templating system has the following capabilities

* Fully customisable using HTML templates and CSS styles
* Insert any content from the merged record, including photos
* Insert a single page background image for your letterhead
* Loop on related content and photos to output lists
* Add conditional logic to control content based on data in the item, as well as the item's presence in counters, lists or custom search CQL.
* A default (and extensible) CSS starter pack to control the most common document layouts and formats

{% hint style="info" %}
Hotlinking to external URLs to embed images is not supported due to security requirements.\
An alternative to embed background images is Base64 encoding. For assistance with this contact the [Service Desk](https://docs.cw.crisisworks.com/security-and-support/maintenance-and-support/accessing-support.md).
{% endhint %}

### Example

The following example shows a basic format for a multi-page letter. This forms the basis for the examples on this page.

<div><figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FTO8i07zdv9Gpzo5QqlPn%2FFPN%20Example%20ACME%20P1.png?alt=media&amp;token=1fd003e3-b01e-4374-ad68-9a86c2edb854" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FbEknwCk7uEvY0p0If2qJ%2FFPN%20Example%20ACME%20P2.png?alt=media&amp;token=97783b24-ccbd-476f-8967-5ac0ff247067" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FCBPZijGr6HjqO1RbYmx0%2FFPN%20Example%20ACME%20P3.png?alt=media&amp;token=ef7613ea-676b-4e92-9ace-0896f6254ac8" alt="" width="563"><figcaption></figcaption></figure></div>

### Register-specific tokens

Each token has its own set of tokens that map to that register's fields. For information specific to registers, such as Fire Prevention Notices, Permits or Cases, refer to the relevant guides.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cw.crisisworks.com/security-and-support/technical-reference/merge-template-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
