> ## Documentation Index
> Fetch the complete documentation index at: https://kapso-1adbad2d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a WhatsApp template

> Updates an existing draft template. Only draft templates can be updated.



## OpenAPI

````yaml api/legacy/openapi-whatsapp.yaml patch /whatsapp_templates/{template_id}
openapi: 3.0.3
info:
  title: Kapso External API - WhatsApp API
  description: >-
    API for programmatically interacting with Kapso agents, executions, and
    WhatsApp conversations. This specification includes only WhatsApp API
    endpoints.
  version: 1.0.0
  contact:
    name: Kapso Support
servers:
  - url: https://app.kapso.ai/api/v1
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /whatsapp_templates/{template_id}:
    patch:
      tags:
        - WhatsApp Templates
      summary: Update a WhatsApp template
      description: Updates an existing draft template. Only draft templates can be updated.
      operationId: updateWhatsappTemplate
      parameters:
        - name: template_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - template
              properties:
                template:
                  type: object
                  properties:
                    name:
                      type: string
                      description: Template name (must be unique per language)
                      example: appointment_reminder_updated
                    language_code:
                      type: string
                      description: Language code (e.g., 'en_US')
                      example: en_US
                    category:
                      type: string
                      description: Template category
                      enum:
                        - MARKETING
                        - UTILITY
                        - AUTHENTICATION
                      example: UTILITY
                    parameter_format:
                      type: string
                      description: >-
                        Parameter format - NAMED for named parameters like
                        {{customer_name}}, POSITIONAL for {{1}}, {{2}}
                      enum:
                        - NAMED
                        - POSITIONAL
                      default: POSITIONAL
                      example: NAMED
                    components:
                      type: array
                      description: >-
                        Template components structure (array of component
                        objects)
                      items:
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - HEADER
                              - BODY
                              - FOOTER
                              - BUTTONS
                            description: Component type
                          format:
                            type: string
                            enum:
                              - TEXT
                              - IMAGE
                              - VIDEO
                              - DOCUMENT
                              - LOCATION
                            description: Format for HEADER components
                          text:
                            type: string
                            description: Text content of the component
                          example:
                            type: object
                            description: Example media for HEADER components
                            properties:
                              header_handle:
                                type: array
                                items:
                                  type: string
                          buttons:
                            type: array
                            description: Array of buttons for BUTTONS component
                            items:
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - QUICK_REPLY
                                    - URL
                                    - PHONE_NUMBER
                                text:
                                  type: string
                                url:
                                  type: string
                                  description: URL for URL type buttons
                                phone_number:
                                  type: string
                                  description: Phone number for PHONE_NUMBER type buttons
            examples:
              update_body_text:
                summary: Update body text with named parameters
                description: Updates the body component to use named parameters
                value:
                  template:
                    parameter_format: NAMED
                    components:
                      - type: BODY
                        text: >-
                          Hello {{customer_name}}, your appointment has been
                          rescheduled to {{new_date}} at {{new_time}}. Please
                          confirm your attendance.
                        example:
                          body_text_named_params:
                            - param_name: customer_name
                              example: John
                            - param_name: new_date
                              example: December 20th
                            - param_name: new_time
                              example: 3:00 PM
              add_footer:
                summary: Add a footer to existing template
                description: Adds a footer component to a template that didn't have one
                value:
                  template:
                    components:
                      - type: BODY
                        text: 'Your order #{{1}} is ready for pickup!'
                        example:
                          body_text:
                            - - ORD-2024-456
                      - type: FOOTER
                        text: 'Store hours: Mon-Fri 9AM-6PM'
              change_to_marketing:
                summary: Change category and add buttons with named parameters
                description: >-
                  Updates template category to MARKETING with named parameters
                  and adds quick reply buttons
                value:
                  template:
                    category: MARKETING
                    parameter_format: NAMED
                    components:
                      - type: HEADER
                        format: IMAGE
                        example:
                          header_handle:
                            - 4::aW...
                      - type: BODY
                        text: >-
                          🎁 Special offer just for you, {{customer_name}}! Get
                          {{discount}} off your next purchase.
                        example:
                          body_text_named_params:
                            - param_name: customer_name
                              example: Sarah
                            - param_name: discount
                              example: 20%
                      - type: BUTTONS
                        buttons:
                          - type: QUICK_REPLY
                            text: Shop Now
                          - type: QUICK_REPLY
                            text: View Details
              update_complete_template:
                summary: Complete template update
                description: >-
                  Updates all aspects of a template including name, category,
                  and components
                value:
                  template:
                    name: summer_sale_2024
                    category: MARKETING
                    components:
                      - type: HEADER
                        format: VIDEO
                        example:
                          header_handle:
                            - 4::aW...
                      - type: BODY
                        text: >-
                          ☀️ Summer Sale Extended! Hi {{1}}, enjoy {{2}} off
                          everything until {{3}}. Use code: SUMMER24
                        example:
                          body_text:
                            - - Customer
                              - 40%
                              - August 31st
                      - type: FOOTER
                        text: Terms and conditions apply
                      - type: BUTTONS
                        buttons:
                          - type: URL
                            text: Shop Collection
                            url: https://example.com/summer-sale
                          - type: PHONE_NUMBER
                            text: Call Us
                            phone_number: '+1234567890'
      responses:
        '200':
          description: Template updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/WhatsappTemplate'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Template not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation error (e.g., template not in draft status)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Only draft templates can be updated
                  errors:
                    type: array
                    items:
                      type: string
                    example:
                      - Name can't be blank
                      - Language code is not valid
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: error
                  message:
                    type: string
                    example: 'Failed to update template: Internal Error'
components:
  schemas:
    WhatsappTemplate:
      type: object
      properties:
        id:
          type: string
          format: uuid
          example: template-123abc
        name:
          type: string
          example: appointment_reminder
        language_code:
          type: string
          example: en_US
        category:
          type: string
          enum:
            - MARKETING
            - UTILITY
            - AUTHENTICATION
          example: UTILITY
        status:
          type: string
          enum:
            - draft
            - submitted
            - approved
            - rejected
            - disabled
            - removed
          example: approved
        content:
          type: string
          example: Hello {{1}}, your appointment is confirmed for {{2}}.
        parameter_count:
          type: integer
          example: 2
        business_account_id:
          type: string
          nullable: true
          example: '123456789012345'
          description: WhatsApp Business Account ID this template belongs to
        whatsapp_config_ids:
          type: array
          items:
            type: string
            format: uuid
          example:
            - config-123abc
            - config-456def
          description: Array of WhatsApp config IDs this template is associated with
        components:
          type: array
          description: Raw WhatsApp template components structure
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - HEADER
                  - BODY
                  - FOOTER
                  - BUTTONS
              format:
                type: string
                enum:
                  - TEXT
                  - IMAGE
                  - VIDEO
                  - DOCUMENT
                  - LOCATION
              text:
                type: string
              example:
                type: object
              buttons:
                type: array
                items:
                  type: object
        metadata:
          type: object
          description: Additional metadata about the template
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        error:
          type: string
          example: Resource not found
        status:
          type: integer
          example: 404
        message:
          type: string
          example: The requested resource could not be found
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key required for all endpoints

````