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

# Update template



## OpenAPI

````yaml /api-reference/openapi.json put /api/v1/templates/{id}
openapi: 3.0.3
info:
  title: SegmentFlow.ai API
  description: Unified SegmentFlow.ai API documentation
  version: 1.0.0
servers:
  - url: http://localhost:3001
    description: Local development
  - url: https://api-staging.segmentflow.ai
    description: Staging
  - url: https://api.segmentflow.ai
    description: Production
security:
  - apiKeyAuth: []
tags:
  - name: Profiles
    description: Profiles (Contacts)
  - name: Events
    description: Server-side business event tracking
  - name: Assets
    description: Assets
  - name: BackgroundJobs
    description: Background job progress
  - name: Brand-Kit
    description: Brand kits
  - name: Catalog-Products
    description: Catalog products
  - name: Templates
    description: Templates
  - name: Broadcasts
    description: Broadcasts
  - name: Segments
    description: Segments
  - name: Journeys
    description: Journeys
  - name: Emails
    description: Email sends
paths:
  /api/v1/templates/{id}:
    put:
      tags:
        - Templates
      summary: Update template
      operationId: Templates_Templates_Update
      parameters:
        - schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          in: path
          name: id
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                key:
                  nullable: true
                  type: string
                  minLength: 1
                  maxLength: 120
                definition:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - Email
                    emailContentsType:
                      type: string
                      enum:
                        - Code
                    codeFormat:
                      type: string
                      enum:
                        - json
                    purpose:
                      type: string
                      enum:
                        - General
                        - Newsletter
                        - Promotional
                        - Transactional
                        - LeadMagnetDelivery
                    subType:
                      type: string
                      nullable: true
                    authoringMode:
                      type: string
                      enum:
                        - manual_message_document
                        - automated_email_spec
                    from:
                      default: ''
                      type: string
                    subject:
                      default: ''
                      anyOf:
                        - type: string
                        - type: object
                          properties:
                            $template:
                              type: string
                            vars:
                              type: object
                              additionalProperties:
                                description: Any JSON value.
                                nullable: true
                                x-stainless-any: true
                          required:
                            - $template
                          additionalProperties: false
                    replyTo:
                      type: string
                    preheader:
                      anyOf:
                        - type: string
                        - type: object
                          properties:
                            $template:
                              type: string
                            vars:
                              type: object
                              additionalProperties:
                                description: Any JSON value.
                                nullable: true
                                x-stainless-any: true
                          required:
                            - $template
                          additionalProperties: false
                    body:
                      type: object
                      properties:
                        specVersion:
                          type: string
                          enum:
                            - email-spec.v1
                        root:
                          type: string
                          minLength: 1
                        elements:
                          type: object
                          additionalProperties:
                            type: object
                            properties:
                              type:
                                type: string
                                minLength: 1
                              props:
                                nullable: true
                                type: object
                                additionalProperties:
                                  description: Any JSON value.
                                  nullable: true
                                  x-stainless-any: true
                              children:
                                type: array
                                items:
                                  type: string
                            required:
                              - type
                      required:
                        - specVersion
                        - root
                        - elements
                      additionalProperties: false
                    defaultBody:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - doc
                        content:
                          type: array
                          items:
                            description: Any JSON value.
                            nullable: true
                            x-stainless-any: true
                      required:
                        - type
                    renderVariables:
                      type: object
                      additionalProperties:
                        description: Any JSON value.
                        nullable: true
                        x-stainless-any: true
                    sensitiveTransactionalVariablePaths:
                      type: array
                      items:
                        type: string
                        minLength: 1
                  required:
                    - type
                    - emailContentsType
                    - codeFormat
                    - purpose
                    - body
                senderProfileId:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  nullable: true
                brandKitId:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  nullable: true
                purpose:
                  type: string
                  enum:
                    - General
                    - Newsletter
                    - Promotional
                    - Transactional
                    - LeadMagnetDelivery
                subType:
                  type: string
                  nullable: true
                defaultSegmentId:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  nullable: true
                language:
                  type: string
                  minLength: 2
                  maxLength: 35
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  organizationId:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  name:
                    type: string
                  key:
                    type: string
                    nullable: true
                  type:
                    type: string
                  status:
                    $ref: '#/components/schemas/TemplateStatus'
                  resourceType:
                    type: string
                  senderProfileId:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    nullable: true
                  brandKitId:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    nullable: true
                  purpose:
                    type: string
                    enum:
                      - General
                      - Newsletter
                      - Promotional
                      - Transactional
                      - LeadMagnetDelivery
                  defaultSegmentId:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    nullable: true
                  definition:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - Email
                      emailContentsType:
                        type: string
                        enum:
                          - Code
                      codeFormat:
                        type: string
                        enum:
                          - json
                      purpose:
                        type: string
                        enum:
                          - General
                          - Newsletter
                          - Promotional
                          - Transactional
                          - LeadMagnetDelivery
                      subType:
                        type: string
                        nullable: true
                      authoringMode:
                        type: string
                        enum:
                          - manual_message_document
                          - automated_email_spec
                      from:
                        default: ''
                        type: string
                      subject:
                        default: ''
                        anyOf:
                          - type: string
                          - type: object
                            properties:
                              $template:
                                type: string
                              vars:
                                type: object
                                additionalProperties:
                                  description: Any JSON value.
                                  nullable: true
                                  x-stainless-any: true
                            required:
                              - $template
                            additionalProperties: false
                      replyTo:
                        type: string
                      preheader:
                        anyOf:
                          - type: string
                          - type: object
                            properties:
                              $template:
                                type: string
                              vars:
                                type: object
                                additionalProperties:
                                  description: Any JSON value.
                                  nullable: true
                                  x-stainless-any: true
                            required:
                              - $template
                            additionalProperties: false
                      body:
                        type: object
                        properties:
                          specVersion:
                            type: string
                            enum:
                              - email-spec.v1
                          root:
                            type: string
                            minLength: 1
                          elements:
                            type: object
                            additionalProperties:
                              type: object
                              properties:
                                type:
                                  type: string
                                  minLength: 1
                                props:
                                  description: Any JSON value.
                                  nullable: true
                                  x-stainless-any: true
                                children:
                                  type: array
                                  items:
                                    type: string
                              required:
                                - type
                                - props
                              additionalProperties: false
                        required:
                          - specVersion
                          - root
                          - elements
                        additionalProperties: false
                      defaultBody:
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - doc
                          content:
                            type: array
                            items:
                              description: Any JSON value.
                              nullable: true
                              x-stainless-any: true
                        required:
                          - type
                        additionalProperties: false
                      renderVariables:
                        type: object
                        additionalProperties:
                          description: Any JSON value.
                          nullable: true
                          x-stainless-any: true
                      sensitiveTransactionalVariablePaths:
                        type: array
                        items:
                          type: string
                          minLength: 1
                    required:
                      - type
                      - emailContentsType
                      - codeFormat
                      - purpose
                      - from
                      - subject
                      - body
                    additionalProperties: false
                  definitionCompatibility:
                    type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - ok
                          - migrated_for_read
                          - blocked
                      expectedVersion:
                        type: string
                        enum:
                          - email-spec.v1
                      fromVersion:
                        type: string
                      reason:
                        type: string
                        enum:
                          - missing_spec_version
                          - missing_definition_purpose
                          - ambiguous_legacy_header
                          - validation_failed
                      issues:
                        type: array
                        items:
                          type: object
                          properties:
                            code:
                              type: string
                            message:
                              type: string
                            path:
                              type: string
                          required:
                            - code
                            - message
                          additionalProperties: false
                      canAutoRepair:
                        type: boolean
                    required:
                      - status
                      - expectedVersion
                      - fromVersion
                      - issues
                      - canAutoRepair
                    additionalProperties: false
                  templateAuthoring:
                    type: object
                    properties:
                      version:
                        type: string
                        enum:
                          - template-authoring.v1
                      mode:
                        nullable: true
                        type: string
                        enum:
                          - manual_message_document
                          - automated_email_spec
                      modeSource:
                        type: string
                        enum:
                          - declared
                          - inferred
                          - unknown
                      label:
                        type: string
                        enum:
                          - Manual editor
                          - Autopilot design
                          - Unknown
                      manualMessageDocument:
                        type: object
                        properties:
                          compatible:
                            type: boolean
                          reasons:
                            type: array
                            items:
                              type: string
                              enum:
                                - template_archived
                                - template_deleted
                                - unsupported_template_type
                                - unsupported_resource_type
                                - unsupported_purpose
                                - missing_definition
                                - missing_authoring_mode
                                - unsupported_authoring_mode
                                - authoring_mode_mismatch
                                - missing_spec_version
                                - invalid_email_spec
                                - malformed_body
                                - missing_body_host
                                - missing_editor_body
                                - ambiguous_editor_body
                                - invalid_editor_body_ref
                                - editor_body_present
                                - not_extractable
                                - missing_required_shell
                                - missing_reusable_layout_blocks
                                - brandkit_resolution_failed
                                - not_ready_to_send
                        required:
                          - compatible
                          - reasons
                        additionalProperties: false
                      manualBroadcast:
                        type: object
                        properties:
                          selectable:
                            type: boolean
                          reasons:
                            type: array
                            items:
                              type: string
                              enum:
                                - template_archived
                                - template_deleted
                                - unsupported_template_type
                                - unsupported_resource_type
                                - unsupported_purpose
                                - missing_definition
                                - missing_authoring_mode
                                - unsupported_authoring_mode
                                - authoring_mode_mismatch
                                - missing_spec_version
                                - invalid_email_spec
                                - malformed_body
                                - missing_body_host
                                - missing_editor_body
                                - ambiguous_editor_body
                                - invalid_editor_body_ref
                                - editor_body_present
                                - not_extractable
                                - missing_required_shell
                                - missing_reusable_layout_blocks
                                - brandkit_resolution_failed
                                - not_ready_to_send
                        required:
                          - selectable
                          - reasons
                        additionalProperties: false
                      manualNewsletter:
                        type: object
                        properties:
                          selectable:
                            type: boolean
                          reasons:
                            type: array
                            items:
                              type: string
                              enum:
                                - template_archived
                                - template_deleted
                                - unsupported_template_type
                                - unsupported_resource_type
                                - unsupported_purpose
                                - missing_definition
                                - missing_authoring_mode
                                - unsupported_authoring_mode
                                - authoring_mode_mismatch
                                - missing_spec_version
                                - invalid_email_spec
                                - malformed_body
                                - missing_body_host
                                - missing_editor_body
                                - ambiguous_editor_body
                                - invalid_editor_body_ref
                                - editor_body_present
                                - not_extractable
                                - missing_required_shell
                                - missing_reusable_layout_blocks
                                - brandkit_resolution_failed
                                - not_ready_to_send
                        required:
                          - selectable
                          - reasons
                        additionalProperties: false
                      automatedEmailSpec:
                        type: object
                        properties:
                          selectable:
                            type: boolean
                          reasons:
                            type: array
                            items:
                              type: string
                              enum:
                                - template_archived
                                - template_deleted
                                - unsupported_template_type
                                - unsupported_resource_type
                                - unsupported_purpose
                                - missing_definition
                                - missing_authoring_mode
                                - unsupported_authoring_mode
                                - authoring_mode_mismatch
                                - missing_spec_version
                                - invalid_email_spec
                                - malformed_body
                                - missing_body_host
                                - missing_editor_body
                                - ambiguous_editor_body
                                - invalid_editor_body_ref
                                - editor_body_present
                                - not_extractable
                                - missing_required_shell
                                - missing_reusable_layout_blocks
                                - brandkit_resolution_failed
                                - not_ready_to_send
                        required:
                          - selectable
                          - reasons
                        additionalProperties: false
                      defaultDesign:
                        type: object
                        properties:
                          selectable:
                            type: boolean
                          reasons:
                            type: array
                            items:
                              type: string
                              enum:
                                - template_archived
                                - template_deleted
                                - unsupported_template_type
                                - unsupported_resource_type
                                - unsupported_purpose
                                - missing_definition
                                - missing_authoring_mode
                                - unsupported_authoring_mode
                                - authoring_mode_mismatch
                                - missing_spec_version
                                - invalid_email_spec
                                - malformed_body
                                - missing_body_host
                                - missing_editor_body
                                - ambiguous_editor_body
                                - invalid_editor_body_ref
                                - editor_body_present
                                - not_extractable
                                - missing_required_shell
                                - missing_reusable_layout_blocks
                                - brandkit_resolution_failed
                                - not_ready_to_send
                        required:
                          - selectable
                          - reasons
                        additionalProperties: false
                    required:
                      - version
                      - mode
                      - modeSource
                      - label
                      - manualMessageDocument
                      - manualBroadcast
                      - manualNewsletter
                      - automatedEmailSpec
                      - defaultDesign
                    additionalProperties: false
                  source:
                    type: string
                    nullable: true
                  sourceMetadata:
                    nullable: true
                  currentSnapshotId:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    nullable: true
                  language:
                    type: string
                  createdAt:
                    $ref: '#/components/schemas/IsoDateTimeString'
                  updatedAt:
                    $ref: '#/components/schemas/IsoDateTimeString'
                required:
                  - id
                  - organizationId
                  - name
                  - key
                  - type
                  - status
                  - resourceType
                  - senderProfileId
                  - brandKitId
                  - purpose
                  - defaultSegmentId
                  - templateAuthoring
                  - source
                  - language
                  - createdAt
                  - updatedAt
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TemplateStatus:
      type: string
      enum:
        - Active
        - Archived
      description: Lifecycle status of a message template (Active or Archived)
    IsoDateTimeString:
      type: string
      format: date-time
      pattern: >-
        ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
    ErrorResponse:
      type: object
      properties:
        errorCode:
          $ref: '#/components/schemas/SegmentflowErrorCode'
          description: >-
            Stable machine-readable error code. SDKs map this to typed exception
            classes.
          example: TEMPLATE_NAME_EXISTS
        message:
          type: string
          description: >-
            Human-readable error message. May change between releases; do not
            parse.
          example: Template name 'Hello' already exists in this organization.
        details:
          description: >-
            Optional structured detail. `issues` carries per-field validation
            problems; other keys are reserved.
          type: object
          properties:
            issues:
              type: array
              items:
                $ref: '#/components/schemas/ErrorIssue'
          additionalProperties:
            description: Any JSON value.
            nullable: true
            x-stainless-any: true
      required:
        - errorCode
        - message
      additionalProperties: false
      description: 'Canonical error envelope (ADR-0008): `{ errorCode, message, details? }`.'
    SegmentflowErrorCode:
      type: string
      enum:
        - BAD_REQUEST
        - UNAUTHORIZED
        - FORBIDDEN
        - NOT_FOUND
        - CONFLICT
        - GONE
        - UNPROCESSABLE_ENTITY
        - TOO_MANY_REQUESTS
        - VALIDATION_ERROR
        - INTERNAL_ERROR
        - NOT_IMPLEMENTED
        - SERVICE_UNAVAILABLE
        - DATABASE_ERROR
        - IDEMPOTENCY_KEY_TOO_LONG
        - IDEMPOTENCY_KEY_REUSED
        - IDEMPOTENCY_IN_FLIGHT
        - JOURNEY_NOT_FOUND
        - JOURNEY_WRONG_ENTRY_NODE
        - JOURNEY_MISSING_RECIPIENT_EMAIL
        - JOURNEY_MISSING_REQUIRED_VARIABLES
        - JOURNEY_RECIPIENT_ERASED
        - JOURNEY_RUN_NOT_FOUND
        - BROADCAST_NOT_FOUND
        - BROADCAST_SCHEDULING_NOT_IMPLEMENTED
        - BROADCAST_INVALID_STATE
        - BROADCAST_SEND_NOT_ALLOWED
        - PREPARED_SEND_NOT_FOUND
        - PREPARED_SEND_EXPIRED
        - PREPARED_SEND_CROSS_USER
        - PREPARED_SEND_CORRUPT
        - PREPARED_SEND_CONCURRENT_REDEEM
        - PREPARED_SEND_VALIDATION_FAILED
        - TEMPLATE_NOT_FOUND
        - TEMPLATE_NAME_EXISTS
        - PROFILE_NOT_FOUND
        - PROFILE_SUBSCRIPTION_GROUP_NOT_FOUND
        - PROFILE_TRAITS_WRITE_UNSUPPORTED
        - MISSING_CREDENTIAL
        - INVALID_API_KEY
        - INVALID_OAUTH_TOKEN
        - AMBIGUOUS_CREDENTIAL
        - INSUFFICIENT_SCOPE
        - MULTIPLE_CREDENTIALS_PRESENT
        - BEARER_CREDENTIAL_REMOVED
        - SESSION_ROLE_INSUFFICIENT
        - API_KEY_SCOPE_INSUFFICIENT
        - BILLING_DISABLED
        - BILLING_NOT_CONFIGURED
      description: >-
        Stable machine-readable error code. SDK codegen maps these to typed
        exception classes.
    ErrorIssue:
      type: object
      properties:
        path:
          anyOf:
            - type: string
            - type: array
              items:
                anyOf:
                  - type: string
                  - type: number
          description: >-
            Where in the request the issue occurred. String for simple paths;
            array for nested paths.
          example: name
        code:
          type: string
          description: >-
            Stable, machine-readable kind of issue (e.g. 'required',
            'invalid_type').
          example: duplicate
        message:
          type: string
          description: Human-readable description of the issue.
          example: Template name already exists in this organization.
      required:
        - path
        - code
        - message
      additionalProperties: false
      description: A single validation issue inside an error response's `details.issues[]`.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Unified API key for server-side SDK and API integrations

````