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

# Send a WhatsApp template message

> Sends a WhatsApp template message to a specified phone number



## OpenAPI

````yaml api/legacy/openapi-whatsapp.yaml post /whatsapp_templates/{template_id}/send_template
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}/send_template:
    post:
      tags:
        - WhatsApp Templates
      summary: Send a WhatsApp template message
      description: Sends a WhatsApp template message to a specified phone number
      operationId: sendWhatsappTemplate
      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
                  required:
                    - phone_number
                  properties:
                    phone_number:
                      type: string
                      description: Phone number to send the template message to
                      example: '+123456789012'
                    template_parameters:
                      oneOf:
                        - type: array
                          description: >-
                            Array of values for positional parameters (e.g.,
                            {{1}}, {{2}})
                          items:
                            type: string
                          example:
                            - John Smith
                            - Tomorrow at 2 PM
                        - type: object
                          description: >-
                            Object with named parameters (e.g., {{name}},
                            {{email}})
                          additionalProperties:
                            type: string
                          example:
                            name: John Smith
                            email: john@example.com
                      description: >
                        Parameters to fill in the template placeholders. 

                        Use array format for templates with positional
                        parameters ({{1}}, {{2}}).

                        Use object format for templates with named parameters
                        ({{name}}, {{email}}).

                        The system automatically detects which format to use
                        based on the template configuration.
                    header_type:
                      type: string
                      description: Type of header for the template
                      enum:
                        - text
                        - image
                        - video
                        - document
                      example: image
                    header_params:
                      type: string
                      description: >-
                        Content for the template header (URL for media, text for
                        text headers)
                      example: https://example.com/header-image.jpg
                    header_filename:
                      type: string
                      description: >-
                        Filename for document headers (only used when
                        header_type is document)
                      example: invoice.pdf
                    whatsapp_config_id:
                      type: string
                      format: uuid
                      description: >
                        Optional: Specific WhatsApp phone number configuration
                        to use for sending.

                        Templates can be associated with multiple phone numbers
                        (WhatsApp configs).

                        Priority for phone number selection:

                        1. If whatsapp_config_id provided: uses that specific
                        phone number

                        2. If customer_id provided: uses first customer config
                        with template access

                        3. If neither provided: uses first available project
                        config with template access
                    customer_id:
                      type: string
                      format: uuid
                      description: >
                        Optional: Customer ID whose WhatsApp configs to search.

                        The system will use the first production config of this
                        customer that has access to the template.

                        Use this when you want to send from a customer's phone
                        number without specifying which one.
                    button_url_params:
                      type: object
                      description: >-
                        Parameters for URL buttons with dynamic content ({{1}}
                        placeholders)
                      additionalProperties:
                        type: string
                      example:
                        '0': track123
                      nullable: true
            examples:
              basic_template:
                summary: Basic template without URL button
                value:
                  template:
                    phone_number: '+123456789012'
                    template_parameters:
                      - John Smith
                      - Tomorrow at 2 PM
              template_with_button_url:
                summary: Template with URL button parameter
                description: >-
                  Use button_url_params when template has URL buttons with {{1}}
                  placeholders
                value:
                  template:
                    phone_number: '+123456789012'
                    template_parameters: []
                    button_url_params:
                      '0': track123
              template_with_header_and_button:
                summary: Template with image header and URL button
                value:
                  template:
                    phone_number: '+123456789012'
                    template_parameters:
                      - John Smith
                    header_type: image
                    header_params: https://example.com/order-image.jpg
                    button_url_params:
                      '0': order456
              template_with_named_parameters:
                summary: Template with named parameters
                description: >-
                  Use object format for templates with named parameters like
                  {{email}}, {{name}}
                value:
                  template:
                    phone_number: '+123456789012'
                    template_parameters:
                      email: john@example.com
                      name: John Smith
              template_named_with_header:
                summary: Named parameters template with text header
                description: Template with named parameters in both header and body
                value:
                  template:
                    phone_number: '+123456789012'
                    template_parameters:
                      name: John Smith
                    header_type: text
                    header_params: Welcome Message
      responses:
        '200':
          description: Template message sent successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                    example: Template message sent successfully
                  template_id:
                    type: string
                    format: uuid
                  template_name:
                    type: string
                  response:
                    type: object
                    description: WhatsApp API response
        '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
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Template requires 2 parameters, but 1 were provided
        '500':
          description: WhatsApp service error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: error
                  message:
                    type: string
                    example: 'Failed to send template message: API Error'
components:
  schemas:
    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

````