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

# Change an email template

> Changes what you send of a template: its name, type, description, subject, sender, HTML or state. Campaigns and flows read a template each time they send, draft or published, so a change goes out on their next send, as an edit in the app does (a flow email already waiting for approval keeps what it rendered). A template that is or was published must still meet what publishing needs after the change, even one that makes it a draft. The HTML of a template built in the app's visual editor changes only with editor: html, which moves it to the HTML editor and drops its visual design (a 409 otherwise). A 409 with Retry-After means another change held the template, so nothing was written: send it again.



## OpenAPI

````yaml /api/statisfy-api.openapi.json patch /v1/templates/{template_id}
openapi: 3.1.0
info:
  description: >-
    The agent-first Statisfy API. Authenticate with an API key (`Authorization:
    Bearer stfy_live_…`), then call `GET /v1/meta/capabilities` to discover
    every operation and its schemas.
  title: Statisfy API
  version: 1.0.0
servers:
  - url: https://api.statisfy.com
    description: Production
security: []
paths:
  /v1/templates/{template_id}:
    patch:
      tags:
        - templates
      summary: Change an email template
      description: >-
        Changes what you send of a template: its name, type, description,
        subject, sender, HTML or state. Campaigns and flows read a template each
        time they send, draft or published, so a change goes out on their next
        send, as an edit in the app does (a flow email already waiting for
        approval keeps what it rendered). A template that is or was published
        must still meet what publishing needs after the change, even one that
        makes it a draft. The HTML of a template built in the app's visual
        editor changes only with editor: html, which moves it to the HTML editor
        and drops its visual design (a 409 otherwise). A 409 with Retry-After
        means another change held the template, so nothing was written: send it
        again.
      operationId: templates_update
      parameters:
        - description: The template's id, from GET /v1/templates
          in: path
          name: template_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                description:
                  anyOf:
                    - maxLength: 2000
                      type: string
                    - type: 'null'
                  default: null
                  description: null clears it
                  title: Description
                editor:
                  const: html
                  default: null
                  description: >-
                    html: the app opens it in its HTML editor from now on, and a
                    design made in the visual editor is dropped. Needed to
                    change the HTML of a template built in the visual editor
                  title: Editor
                  type: string
                html:
                  default: null
                  description: >-
                    The email's HTML, with Jinja merge tags such as
                    {{contact.first_name}}, {{account.name}}, {{user.name}} (the
                    sender) and {{unsubscribe_this}} (the unsubscribe link's
                    address). GET /v1/templates/merge-tags lists the
                    workspace's. A merge tag with no value for a recipient
                    renders empty, except a {{user.*}} tag (the sender): it
                    takes its value from the person the campaign sends as
                    through an owner role, and when there is no such person or
                    their field is blank, the campaign's send fails. To change
                    the HTML of a template built in the visual editor, send
                    editor: html too
                  maxLength: 2000000
                  title: Html
                  type: string
                name:
                  default: null
                  description: Unique among templates of its type
                  maxLength: 255
                  minLength: 1
                  title: Name
                  type: string
                sender_email:
                  anyOf:
                    - maxLength: 320
                      minLength: 3
                      pattern: ^[^@\s]+@[^@\s]+$
                      type: string
                    - type: 'null'
                  default: null
                  description: null clears it
                  title: Sender Email
                sender_name:
                  anyOf:
                    - maxLength: 255
                      type: string
                    - type: 'null'
                  default: null
                  description: null clears it
                  title: Sender Name
                state:
                  default: null
                  description: >-
                    published as on create; draft hides it when someone sets up
                    a campaign or flow, but those already using it keep sending
                    it, so a template that was published still needs what
                    publishing needs
                  enum:
                    - draft
                    - published
                  title: State
                  type: string
                subject:
                  anyOf:
                    - maxLength: 998
                      type: string
                    - type: 'null'
                  default: null
                  description: >-
                    null clears it. Sent as written: merge tags in a subject are
                    not filled in
                  title: Subject
                type:
                  default: null
                  description: >-
                    promotion, newsletter, updates or custom, as the app offers
                    them. An updates email may go without an unsubscribe link;
                    the others need one to be published
                  enum:
                    - promotion
                    - newsletter
                    - updates
                    - custom
                  title: Type
                  type: string
              type: object
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailTemplate'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    EmailTemplate:
      properties:
        attachments:
          description: Files sent with it, added in the app
          items:
            $ref: '#/components/schemas/EmailTemplateAttachment'
          title: Attachments
          type: array
        created_at:
          format: date-time
          title: Created At
          type: string
        creator:
          anyOf:
            - type: string
            - type: 'null'
          description: The email of the member who created it; null when an API key did
          title: Creator
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        editor:
          description: >-
            Which of the app's editors opens it: visual (the drag-and-drop
            builder, which keeps its own design of the email) or html (its HTML
            editor)
          enum:
            - visual
            - html
          title: Editor
          type: string
        html:
          description: >-
            The email's HTML, with Jinja merge tags such as
            {{contact.first_name}}, {{account.name}}, {{user.name}} (the sender)
            and {{unsubscribe_this}} (the unsubscribe link's address). GET
            /v1/templates/merge-tags lists the workspace's. A merge tag with no
            value for a recipient renders empty, except a {{user.*}} tag (the
            sender): it takes its value from the person the campaign sends as
            through an owner role, and when there is no such person or their
            field is blank, the campaign's send fails
          title: Html
          type: string
        id:
          title: Id
          type: string
        merge_tags:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          description: >-
            The merge tags its HTML uses, as group.key (account.name) or a name
            (unsubscribe_this); null when the HTML isn't valid Jinja (a preview
            says why)
          title: Merge Tags
        name:
          description: Unique among templates of its type (deleted ones included)
          title: Name
          type: string
        sender_email:
          anyOf:
            - type: string
            - type: 'null'
          title: Sender Email
        sender_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Sender Name
        state:
          description: >-
            draft or published. The app offers only published templates when
            someone sets up a campaign or flow, but a campaign or flow already
            using a template reads it each time it sends, draft or published: a
            change goes out on its next send. Deleting a template is what stops
            it
          enum:
            - draft
            - published
          title: State
          type: string
        subject:
          anyOf:
            - type: string
            - type: 'null'
          description: 'Sent as written: merge tags in a subject are not filled in'
          title: Subject
        type:
          description: >-
            promotion, newsletter, updates or custom, as the app offers them. An
            updates email may go without an unsubscribe link; the others need
            one to be published
          title: Type
          type: string
        updated_at:
          format: date-time
          title: Updated At
          type: string
        used_by_campaigns:
          description: >-
            How many campaigns point at it, whatever their status. Each reads
            the template when it sends; a campaign whose template is deleted
            skips sending. Agent Studio flows that send it are not counted
          title: Used By Campaigns
          type: integer
      required:
        - id
        - name
        - description
        - type
        - state
        - editor
        - subject
        - sender_name
        - sender_email
        - creator
        - created_at
        - updated_at
        - html
        - merge_tags
        - used_by_campaigns
        - attachments
      title: EmailTemplate
      type: object
    EmailTemplateAttachment:
      properties:
        filename:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
        size_bytes:
          anyOf:
            - type: integer
            - type: 'null'
          title: Size Bytes
      required:
        - id
        - filename
        - mime_type
        - size_bytes
      title: EmailTemplateAttachment
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http
      description: >-
        An API key, sent as `Authorization: Bearer stfy_live_…`. See
        [Authentication](/rest-api/authentication) for how to get one and which
        scopes it needs.

````

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