# Mail Merge

> Turn templates and JSON data into PDF or DOCX with the document/merge Web API: merge fields, blocks, images, HTML, culture, settings and the template editor.

- **Product:** ReportingCloud
- **Section:** Documentation
- **Kind:** Topic
- **Path:** ReportingCloud > Mail Merge
- **1050 words**
- **Web URL:** https://docs.textcontrol.com/reporting-cloud/mail-merge/
- **LLMs URL:** https://docs.textcontrol.com/reporting-cloud/mail-merge/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/reporting-cloud/mail-merge/llms-full.txt

---

Mail merge is the main task of ReportingCloud: you design a template once, your application sends JSON data with each request, and the Web API returns finished invoices, quotes, letters or reports as PDF, DOCX or another format. Each merge depends on a request with the right parameters, data shaped like the template, merge fields and blocks that match the data and settings for empty values and formats.

If you haven't merged a template yet, start with the [Web API](https://docs.textcontrol.com/reporting-cloud/getting-started/web-api/llms-full.txt) tutorial in Getting Started, which merges the demo template of your trial account.

### How Mail Merge Works

A merge brings three parts together:

- **The template** is an MS Word compatible document, designed in the template editor of the ReportingCloud portal or in a word processor that saves DOCX, DOC or RTF. It contains merge fields for single values, merge blocks for repeating and optional sections, and image placeholders. A merge uses a template from your template storage or one sent with the request.
- **The data** is a JSON array of records. Its names match the names of the fields and blocks of the template.
- **`POST /v1/document/merge`** fills the template with each record and returns the created documents as Base64 strings, in PDF, DOCX or another format, as one document or as one document per record.

Formatting and layout stay in the template, so your code doesn't change when a designer changes them.

### Find the Right Page

| If you want to | Read |
|---|---|
| Understand the merge request, choose between a stored and a sent template and create one document or one per record | [Overview](https://docs.textcontrol.com/reporting-cloud/mail-merge/overview/llms-full.txt) |
| Build the JSON data for a template, or let the .NET or PHP SDK build it from your objects or arrays | [Merge Data](https://docs.textcontrol.com/reporting-cloud/mail-merge/data-sources/llms-full.txt) |
| Name, format and list the merge fields of a template, and keep or remove empty fields | [Merge Fields](https://docs.textcontrol.com/reporting-cloud/mail-merge/fields/llms-full.txt) |
| Repeat table rows for line items and decide what happens to blocks without data | [Merge Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/blocks/llms-full.txt) |
| Merge data with several levels, such as sales with their items | [Nested Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/nested-blocks/llms-full.txt) |
| Merge logos and other images into image placeholders | [Images](https://docs.textcontrol.com/reporting-cloud/mail-merge/images/llms-full.txt) |
| Include a section of the document only when the data contains it | [Conditional Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/conditional-content/llms-full.txt) |
| Merge text with bold, italic and underlined parts into a field | [HTML Content](https://docs.textcontrol.com/reporting-cloud/mail-merge/html-content/llms-full.txt) |
| Look up every option of the `mergeSettings` object, from empty fields to a document password | [Merge Settings](https://docs.textcontrol.com/reporting-cloud/mail-merge/settings/llms-full.txt) |
| Format dates and currency amounts for a country | [Culture](https://docs.textcontrol.com/reporting-cloud/mail-merge/culture/llms-full.txt) |
| Design a template for your data with a datasource excerpt in the template editor or in MS Word | [Template Design](https://docs.textcontrol.com/reporting-cloud/mail-merge/template-design/llms-full.txt) |

### Where to Start

1. [Overview](https://docs.textcontrol.com/reporting-cloud/mail-merge/overview/llms-full.txt): the request, its parameters and its response.
2. [Merge Data](https://docs.textcontrol.com/reporting-cloud/mail-merge/data-sources/llms-full.txt): the data your application sends.
3. [Merge Fields](https://docs.textcontrol.com/reporting-cloud/mail-merge/fields/llms-full.txt) and [Merge Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/blocks/llms-full.txt): the elements of every template.
4. [Template Design](https://docs.textcontrol.com/reporting-cloud/mail-merge/template-design/llms-full.txt): a template built for your own data.

The parameters, the `MergeBody` and the `MergeSettings` object are listed in full in the reference of [POST /v1/document/merge](https://docs.textcontrol.com/reporting-cloud/reference/web-api/document/merge/post/llms-full.txt).

### Pages in This Section

- [Overview](https://docs.textcontrol.com/reporting-cloud/mail-merge/overview/llms-full.txt): how a template and data become documents, and how the merge request is built.
- [Merge Data](https://docs.textcontrol.com/reporting-cloud/mail-merge/data-sources/llms-full.txt): the JSON array of records and how the SDKs serialize objects.
- [Merge Fields](https://docs.textcontrol.com/reporting-cloud/mail-merge/fields/llms-full.txt): field names, formats, the fields of a stored template and empty fields.
- [Merge Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/blocks/llms-full.txt): repeat parts of a template for each element of an array.
- [Nested Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/nested-blocks/llms-full.txt): design and merge a template with blocks inside blocks.
- [Images](https://docs.textcontrol.com/reporting-cloud/mail-merge/images/llms-full.txt): bind image placeholders to Base64 image data.
- [Conditional Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/conditional-content/llms-full.txt): show or remove a block depending on the data.
- [HTML Content](https://docs.textcontrol.com/reporting-cloud/mail-merge/html-content/llms-full.txt): merge formatted HTML into merge fields.
- [Merge Settings](https://docs.textcontrol.com/reporting-cloud/mail-merge/settings/llms-full.txt): every option of the `mergeSettings` object.
- [Culture](https://docs.textcontrol.com/reporting-cloud/mail-merge/culture/llms-full.txt): format dates and currencies for a culture.
- [Template Design](https://docs.textcontrol.com/reporting-cloud/mail-merge/template-design/llms-full.txt): prepare data, create an excerpt and design a template.

---

## In This Section

- [Merge Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/blocks/llms-full.txt): Repeat a table row for each invoice line item with a merge block named after a JSON array: the template editor, removeEmptyBlocks and templates/info.
- [Conditional Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/conditional-content/llms-full.txt): Show or remove a template section depending on the merge data: merge blocks bound to objects, removeEmptyBlocks and curl and .NET samples for document/merge.
- [Culture](https://docs.textcontrol.com/reporting-cloud/mail-merge/culture/llms-full.txt): Format currency values and long dates for a country with the culture merge setting: language culture names such as de-DE, numeric format C, curl and .NET.
- [Merge Data](https://docs.textcontrol.com/reporting-cloud/mail-merge/data-sources/llms-full.txt): Structure the JSON mergeData array of a merge: records, values, arrays for merge blocks, nested objects and the serialization by the .NET and PHP SDKs.
- [Merge Fields](https://docs.textcontrol.com/reporting-cloud/mail-merge/fields/llms-full.txt): Name merge fields after JSON keys, use dot notation for nested objects, set numeric and date formats, list fields with templates/info, remove empty ones.
- [HTML Content](https://docs.textcontrol.com/reporting-cloud/mail-merge/html-content/llms-full.txt): Merge formatted HTML with strong, em and u tags into merge fields with the mergeHtml setting: the html wrapper, kept font settings and curl and .NET samples.
- [Images](https://docs.textcontrol.com/reporting-cloud/mail-merge/images/llms-full.txt): Merge JPG, PNG, BMP or GIF images from Base64 JSON data into image placeholders with document/merge: template editor steps, curl, .NET and removeEmptyImages.
- [Nested Blocks](https://docs.textcontrol.com/reporting-cloud/mail-merge/nested-blocks/llms-full.txt): Build a sales report with a merge block inside a merge block: nested JSON arrays, a datasource excerpt, the template editor, a curl request and the .NET SDK.
- [Overview](https://docs.textcontrol.com/reporting-cloud/mail-merge/overview/llms-full.txt): Build the POST /v1/document/merge request: templateName, returnFormat, append and test, the JSON MergeBody, status codes, stored or sent templates and SDKs.
- [Merge Settings](https://docs.textcontrol.com/reporting-cloud/mail-merge/settings/llms-full.txt): Every property of the MergeSettings object of document/merge: remove options, mergeHtml, culture, document properties, userPassword, defaults and SDK names.
- [Template Design](https://docs.textcontrol.com/reporting-cloud/mail-merge/template-design/llms-full.txt): Design templates for your data: sample JSON from .NET classes, a datasource excerpt, an invoice template built in the editor and the fonts it can use.

---

## Nearby

- **Previous:** [Transactions and Statistics](https://docs.textcontrol.com/reporting-cloud/portal/statistics/llms-full.txt)
- **Next:** [Overview](https://docs.textcontrol.com/reporting-cloud/mail-merge/overview/llms-full.txt)
