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

# Send Template Message

> Sends a WhatsApp template message to a recipient.

Use this endpoint to send WhatsApp template messages to your contacts.

### Fetch sample payload dynamically

To easily construct the required payload structure for any type of template message (including those with media headers, dynamic buttons, or carousels), you do not need to manually construct the `variableMapping` object or variables list.

Instead, you can fetch a pre-formatted, ready-to-use sample payload skeleton for any template using the [Fetch Payload Skeleton](/automate-chats/api-reference/templates/get-payload-skeleton) endpoint (`GET /api/templates/{templateId}/payload-skeleton`).

This endpoint returns the exact JSON structure required by this endpoint (`/api/templates/external/message/send`). You can simply copy the returned payload skeleton, replace the sample variables and recipient details with your actual values, and send it directly.


## OpenAPI

````yaml POST /api/templates/external/message/send
openapi: 3.1.0
info:
  title: Automate Chats API
  description: >-
    API for managing WhatsApp template messages, contacts, custom fields, tags,
    and external integrations.
  version: 1.0.0
servers:
  - url: https://api.automatechats.com
security:
  - apiKeyAuth: []
paths:
  /api/templates/external/message/send:
    post:
      summary: Send Template Message
      description: Sends a WhatsApp template message to a recipient.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                templateId:
                  type: string
                  format: uuid
                recipientPhoneNumber:
                  type: string
                countryCode:
                  type: string
                variables:
                  type: array
                  items:
                    type: string
                  description: >-
                    Provide EITHER `variables` OR `variableMapping`. This is for
                    simple sequential variable mapping (Header -> Body ->
                    Buttons).
                variableMapping:
                  type: object
                  description: >-
                    Provide EITHER `variables` OR `variableMapping`. This is for
                    precise variable mapping by sections for complex templates.
              required:
                - templateId
                - recipientPhoneNumber
                - countryCode
            examples:
              simpleVariables:
                summary: Using Simple Variables Array
                description: >-
                  For basic templates, you can send a flat array of variables
                  which maps sequentially to Header -> Body -> Buttons.
                value:
                  templateId: 123e4567-e89b-12d3-a456-426614174000
                  recipientPhoneNumber: '9876543210'
                  countryCode: '+91'
                  variables:
                    - John
                    - 'Order #12345'
              preciseMapping:
                summary: Using Precise Variable Mapping
                description: >-
                  For complex templates (especially with media headers or
                  dynamic buttons), map exactly which variables belong to which
                  section.
                value:
                  templateId: 123e4567-e89b-12d3-a456-426614174000
                  recipientPhoneNumber: '9876543210'
                  countryCode: '+91'
                  variableMapping:
                    header:
                      - https://example.com/receipt.pdf
                    body:
                      - John
                      - 'Order #12345'
                    buttons:
                      - track_12345
              noVariables:
                summary: No Variables Needed
                description: >-
                  If your template has no variables, you only need to provide
                  the template ID and recipient details.
                value:
                  templateId: 123e4567-e89b-12d3-a456-426614174000
                  recipientPhoneNumber: '9876543210'
                  countryCode: '+91'
      responses:
        '200':
          description: Message sent successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
                  data:
                    type: object
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````