> ## 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.

# Edit a WhatsApp template on Meta

> Edits a WhatsApp template via Meta's Graph API and updates the local record.

- Allowed statuses: approved, rejected, or disabled
- Editable fields: category, components, time_to_live
- Category cannot be changed for approved templates

Returns the updated template on success.




## OpenAPI

````yaml api/legacy/openapi-whatsapp.yaml patch /whatsapp_templates/{template_id}/meta
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}/meta:
    patch:
      tags:
        - WhatsApp Templates
      summary: Edit a WhatsApp template on Meta
      description: >
        Edits a WhatsApp template via Meta's Graph API and updates the local
        record.


        - Allowed statuses: approved, rejected, or disabled

        - Editable fields: category, components, time_to_live

        - Category cannot be changed for approved templates


        Returns the updated template on success.
      operationId: editWhatsappTemplateMeta
      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:
                    category:
                      type: string
                      enum:
                        - MARKETING
                        - UTILITY
                        - AUTHENTICATION
                      description: >-
                        New template category. Cannot be changed when status is
                        approved.
                    time_to_live:
                      type: integer
                      description: Optional TTL to apply in Meta (seconds).
                    components:
                      type: array
                      description: >
                        New template components to replace on Meta. If provided
                        as an array,

                        the API will normalize it to Meta's canonical 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
            examples:
              edit_components:
                summary: Replace BODY component text
                value:
                  template:
                    components:
                      - type: BODY
                        text: Updated body text with {{1}} value
                        example:
                          body_text:
                            - - Example
              edit_category_rejected:
                summary: Change category on rejected template
                value:
                  template:
                    category: UTILITY
      responses:
        '200':
          description: Template edited 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., cannot change category on approved template,
            invalid components)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Cannot edit the category of an approved template
                  errors:
                    type: array
                    items:
                      type: string
                    example:
                      - Invalid template component structure
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: error
                  message:
                    type: string
                    example: 'Failed to edit 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

````