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

# Update template

> Updates a template. Caller must be the owner, a workspace admin (for
workspace-scoped templates), or a global admin.

Set `template_type: chain` with a `chain_config` to convert a single
template into a chain, or send `chain_config` to edit an existing
chain (HAR-1098). Subject to the same per-plan step cap as chain launch.




## OpenAPI

````yaml /api-reference/openapi.yaml patch /templates/{id}
openapi: 3.1.0
info:
  title: Harmonica API
  version: 1.0.0
  description: >
    REST API for the Harmonica structured deliberation platform.

    Provides access to sessions and their data, including creating, updating,
    and querying sessions, plus response submission for active sessions.
  contact:
    name: Harmonica
    url: https://harmonica.chat
servers:
  - url: https://app.harmonica.chat/api/v1
    description: Production
  - url: http://localhost:3000/api/v1
    description: Local development
security:
  - apiKey: []
paths:
  /templates/{id}:
    patch:
      tags:
        - Templates
      summary: Update template
      description: |
        Updates a template. Caller must be the owner, a workspace admin (for
        workspace-scoped templates), or a global admin.

        Set `template_type: chain` with a `chain_config` to convert a single
        template into a chain, or send `chain_config` to edit an existing
        chain (HAR-1098). Subject to the same per-plan step cap as chain launch.
      operationId: updateTemplate
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTemplateRequest'
      responses:
        '200':
          description: Updated template
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Template'
        '400':
          description: >-
            Validation error (no updatable fields), or the template has local
            edits since install and `force` was not set (HAR-1108).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            No permission to edit this template, or the chain step count exceeds
            the caller's plan limit (HAR-1098).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Template not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    UpdateTemplateRequest:
      type: object
      description: All fields optional; at least one must be provided.
      properties:
        title:
          type: string
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
        facilitation_prompt:
          type: string
          nullable: true
        default_session_name:
          type: string
          nullable: true
        default_goal:
          type: string
          nullable: true
        default_critical:
          type: string
          nullable: true
        default_context:
          type: string
          nullable: true
        is_public:
          type: boolean
        template_type:
          type: string
          enum:
            - single
            - chain
          description: >-
            Set to 'chain' to convert a single template into a chain
            (chain_config required) (HAR-1098).
        chain_config:
          $ref: '#/components/schemas/ChainConfig'
        source_provenance:
          type: object
          description: >-
            Spec identity for a registry re-install; the server stamps
            install_hash + timestamps (HAR-1108).
          properties:
            spec_id:
              type: string
            spec_version:
              type: string
            registry:
              type: string
          required:
            - spec_id
            - spec_version
            - registry
        force:
          type: boolean
          description: Overwrite a template that has local edits since install (HAR-1108).
    Template:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
        facilitation_prompt:
          type: string
          nullable: true
        default_session_name:
          type: string
          nullable: true
        default_goal:
          type: string
          nullable: true
        default_critical:
          type: string
          nullable: true
        default_context:
          type: string
          nullable: true
        template_type:
          type: string
          description: single or chain
        chain_config:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/ChainConfig'
          description: >-
            Chain definition for chain templates; null for single templates
            (HAR-1098).
        cross_pollination_default:
          type: boolean
        is_public:
          type: boolean
        workspace_id:
          type: string
          format: uuid
          nullable: true
        created_by:
          type: string
          nullable: true
        archived_at:
          type: string
          format: date-time
          nullable: true
        source_provenance:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/SourceProvenance'
          description: >-
            Provenance for a template installed from the OFL method-specs
            registry; null for admin-authored templates (HAR-1108).
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - title
        - template_type
        - cross_pollination_default
        - is_public
        - created_at
        - updated_at
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - unauthorized
                - forbidden
                - not_found
                - validation_error
                - rate_limited
                - internal_error
                - unprocessable
            message:
              type: string
          required:
            - code
            - message
      required:
        - error
    ChainConfig:
      type: object
      description: >-
        Multi-step chain definition (used when template_type is 'chain').
        Validated server-side (HAR-915): at least one step, unique step ids,
        valid role / assignment / completion shapes.
      required:
        - steps
      properties:
        steps:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - id
            properties:
              id:
                type: string
              title:
                type: string
              description:
                type: string
              facilitation_prompt:
                type: string
              default_session_name:
                type: string
              context_mode:
                type: string
                enum:
                  - none
                  - previous_summary
                  - all_summaries
                  - custom
              individual_memory:
                type: boolean
              roles:
                type: array
                items:
                  type: object
                  required:
                    - slug
                    - label
                  properties:
                    slug:
                      type: string
                    label:
                      type: string
                    weight:
                      type: string
                      enum:
                        - normal
                        - elevated
                        - lead
              assignment_strategy:
                type: string
                enum:
                  - explicit
                  - round_robin
                  - first_come_first_served
                  - host_assigned
                  - all_participants
              completion_criteria:
                type: object
                description: >-
                  e.g. { "type": "host_continue" } or { "type": "quorum",
                  "count": 3 }
        output_artifact:
          type: string
          enum:
            - wardley
    SourceProvenance:
      type: object
      description: >-
        Provenance for a template installed from the OFL method-specs registry.
        Null for admin-authored templates.
      properties:
        spec_id:
          type: string
        spec_version:
          type: string
        registry:
          type: string
        install_hash:
          type: string
          description: sha256 of the canonicalized chain_config as installed
        installed_at:
          type: string
          format: date-time
        installed_by:
          type: string
          nullable: true
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Invalid or missing API key
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: |
        API key authentication. Pass your key as a Bearer token.
        Keys use the format `hm_live_<32 hex chars>`.
        Generate keys from your Harmonica dashboard settings.

````