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

# Update a template

> Updates an existing template. Creates a new version of the template.



## OpenAPI

````yaml /openapi.json post /api/templates.update
openapi: 3.0.3
info:
  title: Notifuse API
  description: API for Notifuse - a transactional email and newsletter management platform
  version: 1.0.0
  contact:
    name: Notifuse Support
    url: https://www.notifuse.com/support
    email: hello@notifuse.com
servers:
  - url: https://{notifuseDomain}
    description: Customer-specific Notifuse API server
    variables:
      notifuseDomain:
        description: Your unique Notifuse domain
        default: demo.notifuse.com
security: []
paths:
  /api/templates.update:
    post:
      summary: Update a template
      description: Updates an existing template. Creates a new version of the template.
      operationId: updateTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTemplateRequest'
      responses:
        '200':
          description: Template updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  template:
                    $ref: '#/components/schemas/Template'
        '400':
          description: Bad request - validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - invalid or missing authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Template not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Template not found
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Failed to update template
      security:
        - BearerAuth: []
components:
  schemas:
    UpdateTemplateRequest:
      type: object
      required:
        - workspace_id
        - id
        - name
        - channel
        - category
      properties:
        workspace_id:
          type: string
          description: The ID of the workspace
          example: ws_1234567890
        id:
          type: string
          description: ID of the template to update
          example: welcome_email
          maxLength: 32
        name:
          type: string
          description: Name of the template
          example: Welcome Email
          maxLength: 32
        channel:
          type: string
          enum:
            - email
            - web
          description: Communication channel
          example: email
        email:
          $ref: '#/components/schemas/EmailTemplate'
        web:
          $ref: '#/components/schemas/WebTemplate'
        category:
          type: string
          enum:
            - marketing
            - transactional
            - welcome
            - opt_in
            - unsubscribe
            - bounce
            - blocklist
            - blog
            - other
          description: Template category
          example: transactional
        template_macro_id:
          type: string
          nullable: true
          description: ID of the template macro (layout) to use
        test_data:
          type: object
          additionalProperties: true
          description: Test data for template preview
        settings:
          type: object
          additionalProperties: true
          description: Channel-specific settings
    Template:
      type: object
      properties:
        id:
          type: string
          description: >-
            Unique identifier for the template (alphanumeric, underscores, and
            hyphens only)
          example: welcome_email
          maxLength: 32
          pattern: ^[a-zA-Z0-9_-]+$
        name:
          type: string
          description: Name of the template
          example: Welcome Email
          maxLength: 32
        version:
          type: integer
          format: int64
          description: Version number of the template
          example: 1
        channel:
          type: string
          enum:
            - email
            - web
          description: Communication channel
          example: email
        email:
          $ref: '#/components/schemas/EmailTemplate'
        web:
          $ref: '#/components/schemas/WebTemplate'
        category:
          type: string
          enum:
            - marketing
            - transactional
            - welcome
            - opt_in
            - unsubscribe
            - bounce
            - blocklist
            - blog
            - other
          description: Template category
          example: transactional
          maxLength: 20
        template_macro_id:
          type: string
          nullable: true
          description: ID of the template macro (layout) to use
        integration_id:
          type: string
          nullable: true
          description: ID of the integration managing this template (e.g., Supabase)
        test_data:
          type: object
          additionalProperties: true
          description: Test data for template preview
          example:
            user_name: John Doe
            action_url: https://example.com/action
        settings:
          type: object
          additionalProperties: true
          description: Channel-specific third-party settings
        created_at:
          type: string
          format: date-time
          description: When the template was created
        updated_at:
          type: string
          format: date-time
          description: When the template was last updated
        deleted_at:
          type: string
          format: date-time
          nullable: true
          description: When the template was deleted (null if active)
      required:
        - id
        - name
        - channel
        - category
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message
      required:
        - error
    EmailTemplate:
      type: object
      properties:
        sender_id:
          type: string
          description: ID of the sender configuration to use
          example: sender_123
        reply_to:
          type: string
          format: email
          description: Reply-To email address
          example: support@example.com
        subject:
          type: string
          description: Email subject line (supports Liquid templating)
          example: Welcome, {{user_name}}!
        subject_preview:
          type: string
          nullable: true
          description: Preview text shown in email clients
          example: Get started with your account
        compiled_preview:
          type: string
          description: Compiled HTML preview of the email
        visual_editor_tree:
          type: object
          description: MJML visual editor tree structure
          example:
            type: mjml
            children: []
        text:
          type: string
          nullable: true
          description: Plain text version of the email
      required:
        - subject
        - compiled_preview
        - visual_editor_tree
    WebTemplate:
      type: object
      properties:
        content:
          type: object
          additionalProperties: true
          description: Tiptap JSON content (source of truth for web templates)
        html:
          type: string
          description: Pre-rendered HTML for display
        plain_text:
          type: string
          description: Extracted text for search indexing
      required:
        - content
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API token for authentication

````