> ## 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](/docs/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>


## OpenAPI

````yaml /openapi.json get /v1/email-messages/{emailMessageId}/guardian
openapi: 3.1.0
info:
  title: Loops OpenAPI Spec
  description: This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
  version: 1.21.0
servers:
  - url: https://app.loops.so/api
security: []
tags:
  - name: API key
  - name: Audience segments
    description: View audience segments
  - name: Campaigns
    description: Create and manage email campaigns
  - name: Campaign groups
    description: Organize campaigns into groups
  - name: Components
    description: View email components
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - name: Email messages
    description: Manage email message content for campaigns
  - name: Events
    description: Trigger workflows with events
  - name: Event patterns
    description: View workflow event patterns
  - name: Mailing lists
    description: View mailing lists
  - name: Themes
    description: View email themes
  - name: Transactional emails
    description: Create, manage, and send transactional emails
  - name: Transactional groups
    description: Organize transactional emails into groups
  - name: Uploads
    description: Upload image assets
  - name: Workflows
    description: View and mutate workflow graphs
  - name: Workflow nodes
    description: View and mutate workflow nodes
paths:
  /v1/email-messages/{emailMessageId}/guardian:
    parameters:
      - name: emailMessageId
        in: path
        required: true
        description: The ID of the email message.
        schema:
          type: string
    get:
      tags:
        - Email messages
      summary: Run Guardian checks on an email message
      description: >-
        Validate an email message's content against Guardian rules and return
        any errors and warnings. Errors must be resolved before the email can be
        published, warnings are advisory.
      responses:
        '200':
          description: Successful.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailMessageGuardianResponse'
        '400':
          description: Invalid `emailMessageId`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailMessageFailureResponse'
        '401':
          description: Invalid API key or content API not enabled for this team.
        '404':
          description: Email message not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailMessageFailureResponse'
        '405':
          description: Wrong HTTP request method.
        '409':
          description: Email message uses MJML format.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailMessageFailureResponse'
      security:
        - apiKey: []
components:
  schemas:
    EmailMessageGuardianResponse:
      type: object
      properties:
        errors:
          type: array
          description: >-
            Validation errors. These must be resolved before the email can be
            published.
          items:
            $ref: '#/components/schemas/GuardianRule'
        warnings:
          type: array
          description: Validation warnings. These are advisory and do not block publishing.
          items:
            $ref: '#/components/schemas/GuardianRule'
      required:
        - errors
        - warnings
      example:
        errors:
          - rule: missingButtonHrefs
            title: Missing button link
            description: Buttons won't work without href value
            items:
              - label: Click here
          - rule: missingLinkHrefs
            title: Missing text link
            description: Links won't work without href value
            items:
              - label: See more
        warnings: []
    EmailMessageFailureResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
    GuardianRule:
      type: object
      properties:
        rule:
          type: string
          description: The identifier of the Guardian rule that fired.
          enum:
            - unsupportedContactProperties
            - missingFallbackContactProperties
            - unsupportedEventProperties
            - missingFallbackEventProperties
            - unsupportedDataVariables
            - invalidCustomDataVariables
            - missingRequiredDataVariables
            - missingButtonHrefs
            - invalidButtonHrefs
            - shortenedYouTubeButtonHrefs
            - missingLinkHrefs
            - invalidLinkHrefs
            - shortenedYouTubeLinkHrefs
            - shortenedYouTubeImageHrefs
            - emailWithoutMailtoButtonHrefs
            - emailWithoutMailtoLinkHrefs
            - emailWithoutMailtoImageHrefs
            - bareArrayNodes
            - missingSocialIconHrefs
        title:
          type: string
          description: A short summary of the rule.
        description:
          type: string
          description: A longer explanation of why the issue matters.
        items:
          type: array
          description: The specific elements that triggered the rule.
          items:
            type: object
            properties:
              label:
                type: string
                description: >-
                  A human-readable label for the item (for example, link text or
                  a property name).
              codeName:
                type: string
                description: >-
                  Machine-readable identifier when the rule refers to a property
                  or variable, when applicable.
                example: firstName
            required:
              - label
      required:
        - rule
        - title
        - description
        - items
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

## Related topics

- [Guardian](/docs/creating-emails/guardian.md)
- [API Introduction](/docs/api-reference/intro.md)
- [Email messages](/docs/cli/email-messages.md)
- [API Changelog](/docs/api-reference/changelog.md)
- [Check contact suppression status](/docs/api-reference/check-contact-suppression.md)
