# Automations

> Set a rule once so that it applies itself to the right templates: attach an annex, apply a brand identity, choose the template from the data.

An automation is a "When… Then…" rule that applies itself to your templates. You set it once instead of repeating the same setting template by template. For example: attach your terms and conditions to every purchase order, or apply the BMW identity to the BMW templates and the MINI identity to the MINI templates.

The **Automations** page is in the left column. It is open to designers, developers and administrators, on every plan.

## Create an automation

1. Open **Automations**, then click **New automation**.

   ![The New automation button](https://mizanpage.com/docs/medias/tutos/automatisations-1.en.webp)

2. At the top of the window, choose the action: **Attach an annex** (a PDF from My files, before or after the document), **Apply an identity** (a brand identity shared with the team) or **Choose the template**.

3. Under **For**, keep **every template** or choose **some templates**, then add one or more conditions: name contains (ignoring case and accents), document type is, folder is.

   ![The conditions of the rule and the templates it targets](https://mizanpage.com/docs/medias/tutos/automatisations-2.en.webp)

4. Choose the identity or the annex, and rename the rule with the pencil next to its name, for example “T&Cs on purchase orders”.

   ![The Apply an identity action and the chosen identity](https://mizanpage.com/docs/medias/tutos/automatisations-3.en.webp)

5. Click **Create the automation**. The rule joins the list with the number of templates it targets.

   ![The rule in the list of automations](https://mizanpage.com/docs/medias/tutos/automatisations-4.en.webp)

While you fill in the window, it shows which templates the rule will apply to. All conditions must be true, five at most. With no condition, the rule applies to every template.

> The language is not a condition. To target the documents in English, use the name ("EN") or a folder. A template in several languages gets the same rule in all its languages.

## They act live

Nothing is written into your templates. The rule applies to every document generated: from the editor, through the API, from an Excel or CSV file, and in the Preview. If you change the BMW identity, every BMW document generated afterwards changes. A rule also covers templates created or renamed after it. A document already generated does not change.

## What you see in the editor

Whatever comes from a rule is shown and locked, with the reason:

- the annex appears in the **Annexes** section with a padlock, and its pages are on the canvas;
- the identity is shown in the page settings, and the font and colours it sets cannot be changed in the template.

To change this behaviour, edit or turn off the rule.

## Manage the rules

Each rule is a card: its name, When, Then, and the templates it covers.

- The switch turns it on or off. A rule that is off no longer acts.
- The **⋯** menu offers **Edit** and **Delete**. Deleting a rule leaves the templates as they are.

A workspace can have 50 rules at most.

## When several rules target the same template

- Annexes add up, in the order the rules were created, after the template's own annexes. An annex already attached to the template is not attached twice.
- For the identity, an identity linked directly to the template comes before every rule (see [Create a brand identity](https://mizanpage.com/en/docs/identite/creer.md)). Between two rules, the oldest wins. The card of the rule set aside says so.

## Choose the template from the data

From the Team plan, a rule can also choose **which template** prints a document, from the data your software sends. For example: the BMW layout for the repair invoices of the Charleroi branch that concern a BMW or a MINI, another one for repairs under warranty, the general layout otherwise. Your software only asks for the type of document.

1. **New automation**, then, under **What the rule does**, **Choose the template**.
2. Choose the **type of document**.
3. Under **When the data sent…**, add your conditions: a field, an operator (is, is not, is one of, contains, is empty, is greater than…) and a value. Choose **All conditions** or **At least one**, and add a group to mix both ("Charleroi **and** (BMW **or** under warranty)").
4. Under **Then…**, choose the template to use among the type's published templates.

These rules form the **Choice of template** section of the page, numbered in the order they are read: the first one that matches wins. The **⋯** menu of each card offers **Move up** and **Move down**. If no rule matches, the type's default template is used.

Comparisons ignore capital letters, accents and surrounding spaces. "Is greater than" and its neighbours compare numbers ("1,500.50") or dates in the YYYY-MM-DD format.

> The **Import, export, test** menu opens **Test the choice of template**: enter values as your software would send them, and the window tells you which template would be chosen and by which rule. Nothing is generated or counted. The same menu exports your rules as JSON and imports a file.

On the Solo plan, **Choose the template** is visible but inactive. A rule created on Team is kept after a move to Solo, with no effect until you are back on Team.

For developers: the same rules are created, ordered, exported and tested through the API (`/v1/automations`). Your software can also keep its own rules and name the template in each call (see [Generate a document](https://mizanpage.com/en/docs/api/generer.md)).

> If a rule's file or identity is deleted, or the identity becomes personal again, the rule does nothing. Its card says so. Templates offered by a partner software are not affected by your rules.

---

Documentation Mizanpage · Guide › Templates
https://mizanpage.com/en/docs/modeles/automatisations/
