# Rule Formatting

This Page Explains the Rule Formatting System in Detail.

To gain an understanding of the rule system, read the following page:

{% content-ref url="../concepts/rules" %}
[rules](https://docs.squidex.io/id-02-documentation/concepts/rules)
{% endcontent-ref %}

## Introduction

Rule formatting is used to format your custom payloads in rule actions, for example, when you use email actions and you want to use certain values from the event that's inside the email subject or body.

To gain an understanding of what can be done with the rule system let's have a look at an event.

The example below is a full content event that has been triggered following creation of a new item:

```javascript
{
    "id": "123...", // Id of the content.
    "actor": { "type": "subject", "id": "123..." }, // Id of the user
    "appId": { "name": "my-app", "id": "123..." }, // App name and id
    "created": "2018-01-01T12:00:00Z",
    "createdBy":  { "type": "subject", "id": "123..." },
    "data": { // Content data
        "city": {
            "en": "Munich",
            "de": "München"
        },
        "population": {
            "iv": 123000
        }
    },
    "lastModified": "2018-01-01T12:00:00Z",
    "lastModifiedBy": { "type": "subject", "id": "123..." },
    "schemaId": { "name": "my-schema", "id": "123..." }, // Schema id
    "status": "Draft", // Status of the content: Draft, Archived, Published
    "timestamp": "2018-01-01T12:00:00Z",
    "type": "Created", // The type of the event.
    "user": { // The user information.
        "id": "123...",
        "name": "John Doe",
        "email": "john@email.com"
    },
    "version": 1 // Version of the content, increased with any operation
}
```

## Formatting Options

The rule formatter grants access to all of this event's properties.

At the moment, there are three options for formatting:

{% content-ref url="rule-formatting/simple" %}
[simple](https://docs.squidex.io/id-02-documentation/developer-guides/rule-formatting/simple)
{% endcontent-ref %}

{% content-ref url="rule-formatting/script" %}
[script](https://docs.squidex.io/id-02-documentation/developer-guides/rule-formatting/script)
{% endcontent-ref %}

{% content-ref url="rule-formatting/liquid" %}
[liquid](https://docs.squidex.io/id-02-documentation/developer-guides/rule-formatting/liquid)
{% endcontent-ref %}

The syntax is selected based on the value of the rule property.

* If a value follows the format `Liquid(<Template>)`, then `Template` is interpreted as a liquid syntax. It is interpreted using a template engine.
* If a value follows the format `Script(<Script>)`, then `Script` is interpreted as Javascript expression and interpreted using a scripting engine.
* If none of the syntaxes above are detected, the value is interpreted as simple formatting.  Therefore, it is interpreted using a built-in solution.

In newer versions of Squidex, the user interface has been improved and custom input fields have been introduced which allows you to select the syntax and automatically add the necessary prefix.

<div align="left"><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2Fgit-blob-6b4df180b5c1de309de2b94a61398f9c213c6c6e%2Fimage.png?alt=media" alt="Custom Editors for rules"></div>

{% hint style="info" %}
The liquid syntax is the most powerful and easiest option, which is why it is recommended for most user cases.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.squidex.io/id-02-documentation/developer-guides/rule-formatting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
