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

# Update Template

> This API allows you to update an existing email template in Mailercloud.
You can update a template either by providing its id or by using the templateName — at least one of them is required.

**Required Fields:**

- id: The unique ID of the template you want to update. (Required if templateName is not provided.)

- templateName: The name of the template you want to update. (Required if id is not provided.)

- name: The new name for the template (maximum 100 characters). The name must be unique.

- html:  The updated HTML content of the template.

**Optional Fields:**

- categoryId:  Specifies the category ID of the template, you can get it from the **Get Template Categories** API. It would be 0 by default.

- plainText:  Specifies the plain text content



## OpenAPI

````yaml /openapi-v1.json post /templates/update
openapi: 3.1.0
info:
  title: Mailercloud Marketing API
  version: 1.0.0
  description: >-
    Campaigns, contacts, lists, segments, automations, and webhooks for the
    Mailercloud Marketing Platform.
servers:
  - url: https://cloudapi.mailercloud.com/v1
security:
  - apiKey: []
tags:
  - name: Campaigns
  - name: Contacts
  - name: Lists
  - name: Tags
  - name: Segments
  - name: Custom Properties
  - name: Senders
  - name: Templates
  - name: Automations
  - name: Webhooks
  - name: Webforms
  - name: Inbox Tracker
  - name: Account
paths:
  /templates/update:
    post:
      tags:
        - Templates
      summary: Update Template
      description: >-
        This API allows you to update an existing email template in Mailercloud.

        You can update a template either by providing its id or by using the
        templateName — at least one of them is required.


        **Required Fields:**


        - id: The unique ID of the template you want to update. (Required if
        templateName is not provided.)


        - templateName: The name of the template you want to update. (Required
        if id is not provided.)


        - name: The new name for the template (maximum 100 characters). The name
        must be unique.


        - html:  The updated HTML content of the template.


        **Optional Fields:**


        - categoryId:  Specifies the category ID of the template, you can get it
        from the **Get Template Categories** API. It would be 0 by default.


        - plainText:  Specifies the plain text content
      operationId: update-template
      parameters:
        - name: Content-Type
          in: header
          required: false
          description: 'Request body type '
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              x-examples:
                Example 1:
                  categoryId: 0
                  html: <html><body> Sample HTML </body></html>
                  name: New Template
                  plainText: Sample HTML
              properties:
                categoryId:
                  type: integer
                html:
                  type: string
                name:
                  type: string
                plainText:
                  type: string
                templateName:
                  type: string
            examples:
              Example-1:
                value:
                  id: AXY
                  categoryId: 0
                  html: string
                  name: string
                  plainText: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                x-examples:
                  Example 1:
                    message: updated template successfully
              examples:
                Example-1:
                  value:
                    message: updated template successfully
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                x-examples:
                  Example 1:
                    error: HTML is a required field
              examples:
                Example-1:
                  value:
                    error: html is a required field
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                        message:
                          type: string
                x-examples:
                  Example 1:
                    errors:
                      - field: ''
                        message: Authorization failed
              examples:
                Example-1:
                  value:
                    errors:
                      - field: ''
                        message: Authorization failed
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your Mailercloud API key (plain text, no Bearer prefix). Create keys in
        Settings → API.

````