---
title: "Validate Template Variables"
method: POST
path: "/v1/templates/validate"
tags: ["templates"]
---

# Validate Template Variables

`POST /v1/templates/validate`

## Request

- Base URL: `https://api.mentium.io` (the document declares no server; this is the origin it was published from)
- URL: `https://api.mentium.io/v1/templates/validate`
- Auth: HTTP bearer

Validate that all variables in template content are valid Pydantic fields.

This endpoint checks:
1. All {{variable}} references are extracted
2. Each variable corresponds to a field in LoadSchema or CarrierSchema
3. Nested paths are valid (e.g., load.customer.name)
4. Array access is valid (e.g., load.stops.0.city)

Returns validation result with any errors found.

Use this for:
- Real-time validation in template editor
- Pre-save validation
- Displaying helpful error messages to users

## Headers

- `mentium-workspace-id` string, nullable

## Request body

- ValidateTemplateRequest: Request schema for template validation
  - `content` string, required

## Response `200`

Successful Response

- TemplateValidationResult: Result of template variable validation
  - `is_valid` boolean, required
  - `variables_found` string[]
  - `invalid_variables` string[]
  - `error_messages` string[]

## Other responses

- `404`: Not found
- `422`: Validation Error

---

[API](https://skmtc.dev/mentium/apis/mentium-api.md) - [All operations](https://skmtc.dev/mentium/apis/mentium-api/llms.txt) - [OpenAPI document](https://skmtc.dev/mentium/apis/mentium-api/revisions/b4ed8e59432e?raw)
