# Render an AI Template

Render a template for a specific contact and sender profile. The simplest usage is to pass an existing template `uuid` along with `lead_uuid` and `sender_profile_uuid` — the saved template configuration is used.
For ad-hoc rendering without a saved template, pass the full set of fields (subject, body, type, llm_uuid, llm_config, prompt, enable_validation, enable_fallback, settings).

Endpoint: POST /flows/api/ai-templates/render
Version: 2.0.0
Security: bearerAuth

## Request fields (application/json):

  - `uuid` (string)
    Existing template UUID. If provided, other fields default from saved template.

  - `lead_uuid` (string, required)

  - `sender_profile_uuid` (string, required)

  - `subject` (string)

  - `body` (string)

  - `type` (string)

  - `llm_uuid` (string)

  - `llm_config` (object)

  - `prompt` (string)

  - `enable_validation` (boolean)

  - `enable_fallback` (boolean)

  - `settings` (object)

## Response 200 fields (application/json):

  - `llm_instructions` (string)

  - `rendered_body` (string)

  - `ai_generated_body` (string)

  - `fallback_body` (string)

  - `handling_error` (string)

  - `validation_history` (array)

## Response 422 fields (application/json):

  - `error` (object)

  - `error.reason` (string)
    Machine-readable error code: `validation_error`, `bad_request`, `auth_exception`, `access_denied`, `payment_required`.
    Example: validation_error

  - `error.message` (string)
    Example: The name field is required.

  - `message` (string)
    Example: The given data was invalid.

  - `code` (integer)
    Example: 422

