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

# Update a message template

> Updates a workspace-owned message template. All fields are optional (at least one required); prompt text is re-validated and re-converted with the same strict token rules as create. Requires the AI variable split to be enabled for the workspace; otherwise returns 403.

    > **Required scope:** `AI_VARIABLES_WRITE`
    >
    > **Rate limit:** 30 requests per minute



## OpenAPI

````yaml https://openapi.enginy.ai/definitions.json patch /v1/ai-variables/message-templates/{messageTemplateId}
openapi: 3.1.0
info:
  title: Enginy API
  version: 1.0.0
  description: Public API for Enginy platform
servers:
  - url: https://openapi.enginy.ai
    description: Configured server
security: []
tags:
  - name: AI Variables
    description: >-
      Manage AI variables and discover the entity fields you can reference in
      prompts and entity requests.
  - name: Inbox
    description: >-
      Inbox endpoints for listing contact threads, reading thread messages,
      managing tags, and sending manual replies.
  - name: Workflows
    description: >-
      Build, validate, publish, run, and inspect advanced (graph) workflows,
      plus the block/condition catalog needed to author a workflow plan.
paths:
  /v1/ai-variables/message-templates/{messageTemplateId}:
    patch:
      tags:
        - AI Variables
      summary: Update a message template
      description: >-
        Updates a workspace-owned message template. All fields are optional (at
        least one required); prompt text is re-validated and re-converted with
        the same strict token rules as create. Requires the AI variable split to
        be enabled for the workspace; otherwise returns 403.

            > **Required scope:** `AI_VARIABLES_WRITE`
            >
            > **Rate limit:** 30 requests per minute
      parameters:
        - schema:
            type: string
            minLength: 1
          required: true
          name: messageTemplateId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                description:
                  type:
                    - string
                    - 'null'
                channel:
                  type: string
                  enum:
                    - EMAIL
                    - LINKEDIN
                    - WHATSAPP
                    - LINKEDIN_INMAIL
                    - LINKEDIN_CONNECTION
                messages:
                  type: array
                  items:
                    type: string
                    description: >-
                      Plain prompt text. Placeholders: `{fieldId}` for
                      contact/company/CRM/formula/notes fields (discover via the
                      contact/company field-metadata endpoints),
                      `{aiResearch:<id-or-name>}`, `{aiSnippet:<id-or-name>}`,
                      `{aiMessage:<id-or-name>}` for AI entity references.
                      Validation is strict: unknown or ambiguous tokens return
                      400 with the invalid tokens and a sample of valid ones.
                      Escape literal braces by doubling them (`{{` and `}}`).
                  minItems: 1
                  description: One entry per message in the sequence.
                subject:
                  type:
                    - string
                    - 'null'
                  description: Subject line for EMAIL / LINKEDIN_INMAIL channels.
                folderId:
                  type:
                    - number
                    - 'null'
                customPromptFieldValues:
                  type: array
                  items:
                    type: object
                    properties:
                      customPromptFieldId:
                        type: string
                        minLength: 1
                      value:
                        anyOf:
                          - type: string
                          - type: 'null'
                    required:
                      - customPromptFieldId
                      - value
      responses:
        '200':
          description: Message template updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  message:
                    type: string
                  data:
                    type: object
                    additionalProperties: true
                required:
                  - status
                  - message
        '400':
          description: >-
            Invalid prompt tokens (unknown, ambiguous name, or reference type
            not allowed for this entity) — `details.issues` lists each problem
            and `details.validTokenSample` shows valid tokens
        '403':
          description: >-
            AI variable split not enabled for this workspace, or the entity is a
            default one and cannot be edited
        '404':
          description: Message template not found in this workspace
        '409':
          description: Conflict - an entity with this name already exists
      security:
        - apiKey: []
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key

````