> ## Documentation Index
> Fetch the complete documentation index at: https://loops.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Guardian checks on an email message

> Run Guardian content validation on an email message and return errors and warnings before you publish or send.

Run the same [Guardian](/creating-emails/guardian) checks that run in the Loops editor on a saved email message. Use this to validate campaign, workflow, and transactional email content before publishing or sending.

Checks depend on the email message's parent type:

* **Campaign** validates contact properties and rendered links and buttons.
* **Workflow** validates contact properties, event properties from the workflow's event trigger, and rendered links and buttons.
* **Transactional** validates data variables and rendered links and buttons.
* **System transactional** validates required data variables and rendered links and buttons.

<Info>
  This will not work on MJML email messages, as they are not supported in the API.
</Info>

## Request

### Path parameters

<ParamField path="emailMessageId" type="string" required>
  The ID of the email message.
</ParamField>

## Response

### Success

<ResponseField name="errors" type="array" required>
  Guardian rules that failed as errors. Empty when all error checks pass.

  <Expandable title="error" defaultOpen={true}>
    <ResponseField name="rule" type="string" required>
      The rule identifier.

      Possible values:

      * `unsupportedContactProperties`
      * `missingFallbackContactProperties`
      * `unsupportedEventProperties`
      * `missingFallbackEventProperties`
      * `unsupportedDataVariables`
      * `invalidCustomDataVariables`
      * `missingRequiredDataVariables`
      * `missingButtonHrefs`
      * `invalidButtonHrefs`
      * `shortenedYouTubeButtonHrefs`
      * `missingLinkHrefs`
      * `invalidLinkHrefs`
      * `shortenedYouTubeLinkHrefs`
      * `shortenedYouTubeImageHrefs`
      * `emailWithoutMailtoButtonHrefs`
      * `emailWithoutMailtoLinkHrefs`
      * `emailWithoutMailtoImageHrefs`
      * `bareArrayNodes`
      * `missingSocialIconHrefs`
    </ResponseField>

    <ResponseField name="title" type="string" required>
      A short summary of the issue.
    </ResponseField>

    <ResponseField name="description" type="string" required>
      A longer explanation of why the issue matters.
    </ResponseField>

    <ResponseField name="items" type="array" required>
      The specific elements that triggered the rule.

      <Expandable title="item">
        <ResponseField name="label" type="string" required>
          Human-readable label for the matched element (for example, link text or
          a property name).
        </ResponseField>

        <ResponseField name="codeName" type="string">
          Machine-readable identifier when the rule refers to a property or
          variable (for example, `firstName`).
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="warnings" type="array" required>
  Guardian rules that failed as warnings. Empty when all warning checks pass.
  Each entry uses the same shape as entries in `errors`.
</ResponseField>

Only rules with at least one matching item are included. When both arrays are empty, all Guardian checks passed.

### Error

A `400 Bad Request` is returned when `emailMessageId` is missing or invalid.

A `404 Not Found` is returned if the email message does not exist.

A `409 Conflict` is returned when the email message uses MJML format.

If the API key is invalid (or content API is not enabled for your team), a
`401 Unauthorized` is returned.

<ResponseField name="message" type="string" required>
  An error message describing what went wrong.
</ResponseField>

<ResponseExample>
  ```json Response theme={"dark"}
  {
    "errors": [
      {
        "rule": "missingFallbackContactProperties",
        "title": "Missing contact property fallback",
        "description": "Emails won't be sent to contacts without fallback values",
        "items": [
          {
            "label": "firstName",
            "codeName": "firstName"
          }
        ]
      },
      {
        "rule": "missingButtonHrefs",
        "title": "Missing button link",
        "description": "Buttons won't work without href value",
        "items": [
          {
            "label": "Add your button text"
          }
        ]
      },
      {
        "rule": "missingLinkHrefs",
        "title": "Missing text link",
        "description": "Links won't work without href value",
        "items": [
          {
            "label": "else, now is the perfect time to get it."
          }
        ]
      }
    ],
    "warnings": []
  }
  ```

  ```json Error response theme={"dark"}
  {
    "message": "MJML format is not supported via API."
  }
  ```
</ResponseExample>
