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

# Delete a WhatsApp template

> Deletes a WhatsApp template from both the local database and WhatsApp's servers.

**Behavior:**
- If template is already marked as removed, returns the template without making API calls
- Otherwise, deletes the template from WhatsApp API first, then marks it as removed locally
- Requires a production WhatsApp configuration associated with the template's Business Account

**Note:** This operation marks the template as removed rather than completely deleting it from the database.




## OpenAPI

````yaml api/legacy/openapi-whatsapp.yaml delete /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}:
    delete:
      tags:
        - WhatsApp Templates
      summary: Delete a WhatsApp template
      description: >
        Deletes a WhatsApp template from both the local database and WhatsApp's
        servers.


        **Behavior:**

        - If template is already marked as removed, returns the template without
        making API calls

        - Otherwise, deletes the template from WhatsApp API first, then marks it
        as removed locally

        - Requires a production WhatsApp configuration associated with the
        template's Business Account


        **Note:** This operation marks the template as removed rather than
        completely deleting it from the database.
      operationId: deleteWhatsappTemplate
      parameters:
        - name: template_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: >-
            Template deleted successfully (returns updated template with removed
            status)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/WhatsappTemplate'
              examples:
                deleted_template:
                  summary: Successfully deleted template
                  value:
                    data:
                      id: template-123abc
                      name: old_promotion
                      language_code: en_US
                      category: MARKETING
                      status: removed
                      business_account_id: '123456789012345'
                      created_at: '2024-01-10T10:00:00Z'
                      updated_at: '2024-01-15T14:30:00Z'
        '401':
          description: Unauthorized - invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Template not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                not_found:
                  summary: Template not found
                  value:
                    error: Template not found
        '422':
          description: Unable to delete template
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Failed to delete template from WhatsApp
                  message:
                    type: string
                    example: Template is currently in use
                  meta:
                    type: object
                    description: Additional error details from WhatsApp API
              examples:
                no_config:
                  summary: No production config found
                  value:
                    error: Production WhatsApp configuration not found for template
                whatsapp_api_error:
                  summary: WhatsApp API error
                  value:
                    error: Failed to delete template from WhatsApp
                    message: Template is currently in use and cannot be deleted
                    meta:
                      error_code: 100
                      error_subcode: 2388090
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

````