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

# Validate Template Blocks

> Use this endpoint to validate a sequence of template blocks before saving a template.

Validation issues are returned in the `200` response with `valid` set to `false` and a per-block list of messages. HTTP `400` is reserved for a malformed request body.



## OpenAPI

````yaml en/openapi/v3-current/reporter.yaml post /v1/templates/validate
openapi: 3.1.0
info:
  title: Reporter
  description: ''
  version: 2.1.2
servers:
  - url: https://reporter.sandbox.lerian.net
security: []
tags: []
paths:
  /v1/templates/validate:
    post:
      tags:
        - Templates API
      summary: Validate Template Blocks
      description: >-
        Use this endpoint to validate a sequence of template blocks before
        saving a template.


        Validation issues are returned in the `200` response with `valid` set to
        `false` and a per-block list of messages. HTTP `400` is reserved for a
        malformed request body.
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - $ref: '#/components/parameters/XOrganizationId'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                blocks:
                  type: array
                  description: The template blocks to validate.
                  items:
                    type: object
            example:
              blocks:
                - type: loop
                  collection: accounts
                  iterator: account
                  children:
                    - type: field
                      field: account.name
        required: true
      responses:
        '200':
          description: The validation result. Check `valid` before saving the template.
          content:
            application/json:
              schema:
                type: object
                properties:
                  valid:
                    type: boolean
                    description: Whether all blocks passed validation.
                  errors:
                    type: array
                    description: Validation messages, one per invalid block.
                    items:
                      type: object
                      properties:
                        blockId:
                          type: string
                          description: Identifier of the block that failed validation.
                        field:
                          type: string
                          description: The block field the message refers to.
                        message:
                          type: string
                          description: Description of the validation issue.
              example:
                valid: false
                errors:
                  - blockId: block-2
                    field: collection
                    message: collection is required for loop blocks
          headers: {}
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0016:
                  $ref: '#/components/examples/Error0016'
                Error0017:
                  $ref: '#/components/examples/Error0017'
          headers: {}
      security: []
components:
  parameters:
    Authorization:
      name: Authorization
      in: header
      description: >-
        The authorization token in the 'Bearer <token>' format.  


        **Important:** This header is required if your environment has Access
        Manager enabled. For more information, refer to the [Access
        Manager](/en/access-manager) documentation.
      required: false
      schema:
        type: string
    XOrganizationId:
      name: X-Organization-id
      in: header
      description: The unique identifier of the Organization associated with the request.
      required: true
      example: 019c96a0-0a98-7287-9a31-786e0809c769
      schema:
        type: string
  schemas:
    Error:
      type: object
      properties:
        code:
          type: string
          description: A unique, stable identifier for the error.
        title:
          type: string
          description: A brief summary of the issue.
        message:
          type: string
          description: Detailed guidance for resolving the error.
      description: Response message error.
      required:
        - code
        - title
        - message
  examples:
    Error0016:
      summary: Missing Fields in Request
      value:
        code: TPL-0016
        title: Missing Fields in Request
        message: >-
          Your request is missing one or more required fields. Please refer to
          the documentation to ensure all necessary fields are included in your
          request.
    Error0017:
      summary: Bad Request
      value:
        code: TPL-0017
        title: Bad Request
        message: >-
          The server could not understand the request due to malformed syntax.
          Please check the listed fields and try again.

````