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

# Update a template

> Modifies an existing template. Only the provided fields are changed.



## OpenAPI

````yaml /openapi.json patch /templates/{id}
openapi: 3.1.0
info:
  description: Helo Email API (https://helohq.com)
  version: 1.0.0
  title: Helo API
servers:
  - url: https://api.helohq.com
security: []
tags:
  - name: Activity
    description: >-
      Track and retrieve message activity, including messages, delivery and
      engagement events.
  - name: Broadcasts
    description: Manage and track broadcast email campaigns.
  - name: Channels
    description: Create and manage communication channels for organizing messages.
  - name: Domains
    description: Register, verify, and manage domains for email sending.
  - name: Sending
    description: Send transactional and broadcast emails.
  - name: Statistics
    description: Access activity statistics.
  - name: Templates
    description: Manage templates for sending.
  - name: Webhooks
    description: Create and manage webhooks for event notifications.
paths:
  /templates/{id}:
    patch:
      tags:
        - Templates
      summary: Update a template
      description: Modifies an existing template. Only the provided fields are changed.
      operationId: Templates_update
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTemplateRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateResponse'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '409':
          $ref: '#/components/responses/409'
        '422':
          $ref: '#/components/responses/422'
        '500':
          $ref: '#/components/responses/500'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: ruby
          source: |-
            Helo.configure do |config|
              config.api_key = ENV.fetch("HELO_API_KEY")
            end

            id = "550e8400-e29b-41d4-a716-446655440000"
            update_template_request = Helo::UpdateTemplateRequest.new(
              name: "test-name",
              subject: "test-subject",
              html: "test-html",
              mjml: "test-mjml",
              text: "test-text",
              channel_ids: ["550e8400-e29b-41d4-a716-446655440000", "6ba7b810-9dad-11d1-80b4-00c04fd430c8"],
              version: 123
            )
            Helo::Templates.update(id, update_template_request)
        - lang: javascript
          source: |-
            import Helo from "@helo-email/sdk";

            const apiKey = process.env.HELO_API_KEY;
            const helo = new Helo(apiKey);

            const result = await helo.templates.update(
              "550e8400-e29b-41d4-a716-446655440000",
              {
                name: "test-name",
                subject: "test-subject",
                html: "test-html",
                mjml: "test-mjml",
                text: "test-text",
                channelIds: ["550e8400-e29b-41d4-a716-446655440000"],
                version: 123,
              },
            );
        - lang: go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/helo-email/helo-sdk-go\"\n)\n\nfunc main() {\n\tclient := helo.NewHelo(os.Getenv(\"HELO_API_KEY\"))\n\tctx := context.Background()\n\n\tparams := &helo.UpdateTemplateRequest{\n\t\tName: \"test-name\",\n\t\tSubject: \"test-subject\",\n\t\tHtml: \"test-html\",\n\t\tMjml: \"test-mjml\",\n\t\tText: \"test-text\",\n\t\tChannelIds: []string{\"550e8400-e29b-41d4-a716-446655440000\"},\n\t\tVersion: 123,\n\t}\n\tresult, err := client.Templates.Update(ctx, \"550e8400-e29b-41d4-a716-446655440000\", params)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t_ = result\n}"
        - lang: csharp
          source: >-
            using HeloEmail.Sdk.Templates;


            var template = await
            helo.Templates.Update("550e8400-e29b-41d4-a716-446655440000", new
            UpdateTemplateRequest

            {
                Name = "test-name",
                Subject = "test-subject",
                Html = "test-html",
                Mjml = "test-mjml",
                Text = "test-text",
                ChannelIds = ["550e8400-e29b-41d4-a716-446655440000"],
                Version = 10,
            });
        - lang: python
          source: |-
            import sdk_helo_email as helo

            client = helo.Helo()  # reads HELO_API_KEY from the environment

            template = client.templates.update(
                "550e8400-e29b-41d4-a716-446655440000",
                name="test-name",
                subject="test-subject",
                html="test-html",
                mjml="test-mjml",
                text="test-text",
                channel_ids=["550e8400-e29b-41d4-a716-446655440000"],
                version=10,
            )
components:
  schemas:
    UpdateTemplateRequest:
      type: object
      properties:
        name:
          type: string
          description: Renames the template. Cannot be cleared. Maximum 64 characters.
        subject:
          type: string
          description: Cannot be cleared. Maximum 256 characters.
        html:
          type:
            - string
            - 'null'
          description: >
            Replaces the html, and clears any stored mjml (switching the
            template back to plain HTML authoring). Set to null to remove the
            html - blank values are rejected. Maximum 500,000 characters.
        mjml:
          type:
            - string
            - 'null'
          description: >
            Replaces the mjml source, recompiling the html from it. Set to null
            to remove the mjml source while keeping the html already compiled
            from it - blank values are rejected. Maximum 500,000 characters, and
            the compiled html must also be within the html limit.
        text:
          type:
            - string
            - 'null'
          description: >
            Replaces the plain text content. Set to null to remove it - blank
            values are rejected. Maximum 100,000 characters.
        channelIds:
          type:
            - array
            - 'null'
          items:
            type: string
            format: uuid
          description: >
            Replaces the channels the template is scoped to. Set to null or an
            empty array to remove channel scoping, making the template available
            to every channel in the account.
        version:
          type: integer
          format: int64
          description: >
            The version of the template the update was based on, as returned by
            a previous read. If the template has since been modified the update
            is rejected with 409 Conflict, so concurrent edits aren't silently
            overwritten.
      description: >
        Only provided fields are changed - an omitted field leaves the existing
        value unchanged. Supplying both html and mjml in the same request is
        rejected, as is an update that would leave the template with no html or
        text content. Supply version to make the update conditional - without
        it, the last write wins.
    TemplateResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        version:
          type: integer
          format: int64
          description: >
            Opaque version, changing on every update. Pass it back as the
            version of an update to have the update rejected if the template has
            been modified in the meantime.
        name:
          type: string
        subject:
          type: string
        html:
          type: string
        mjml:
          type: string
        text:
          type: string
        channelIds:
          type: array
          items:
            type: string
            format: uuid
      required:
        - id
        - createdAt
        - updatedAt
        - version
        - name
        - subject
    ErrorResponse:
      description: Standard error response body.
      type: object
      properties:
        type:
          description: A URI reference identifying the problem type.
          type: string
        title:
          description: Short, human-readable summary of the problem.
          type: string
        instance:
          description: URI reference identifying the specific occurrence of the problem.
          type: string
        status:
          description: HTTP status code.
          type: integer
          format: int32
        code:
          description: Application-specific error code.
          type: string
        detail:
          description: Human-readable explanation of this specific occurrence.
          type: string
        requestId:
          description: Unique request ID, useful for support correlation.
          type: string
        errors:
          description: Field-level validation errors, keyed by field name.
          type: object
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/ValidationError'
    ValidationError:
      description: A single field validation error.
      required:
        - message
      type: object
      properties:
        message:
          description: Description of the validation failure.
          type: string
  responses:
    '401':
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    '403':
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    '404':
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    '409':
      description: >
        Conflict - the template has been modified since the version supplied in
        the request. Fetch the template and retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    '422':
      description: Validation Failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    '500':
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.