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

# Send message

> Send individual WhatsApp Business template messages

## Description

This endpoint allows you to send a WhatsApp template to an individual recipient. It implements a **fire-and-forget pattern**: when sending the message, it returns a `message_id` (Meta's wamid) that you can use to check the message status.

The API validates the template, resolves the variables, and sends the message through the Meta API synchronously.

## Authentication header

<ParamField header="X-API-Key" type="string" required>
  Your Mindo API Key. Format: `mindo_xxxxxxxxxxxxxxxxxxxxxxxx`
</ParamField>

## Body parameters

<ParamField body="phone_number_id" type="string" required>
  Meta's WhatsApp phone number ID from which the message will be sent. You can get it from the [Get business accounts](/en/api-reference/cuentas-negocio/obtener-cuentas) endpoint.
</ParamField>

<ParamField body="template_name" type="string" required>
  Name of the approved template to send. Must have `APPROVED` status in Meta.
</ParamField>

<ParamField body="language" type="string">
  Template language. Default: `"es"`. Examples: `"es"`, `"en"`, `"pt_BR"`.
</ParamField>

<ParamField body="recipient_phone" type="string" required>
  Recipient's phone number in international format (e.g.: `"+5491112345678"`). No spaces.
</ParamField>

<ParamField body="variables" type="object">
  Custom variables for the template. Keys must match the variables defined in the template.
</ParamField>

<ParamField body="button_variables" type="object">
  Variables for dynamic template buttons. Keys use the format `button_0`, `button_1`, etc., where the number corresponds to the button index (starting at 0). Values are the dynamic suffixes or payloads for each button.

  **Important:** URL buttons only support 1 variable.
</ParamField>

## Response (200 OK)

<ResponseField name="success" type="boolean">
  Whether the message was sent successfully.
</ResponseField>

<ResponseField name="message_id" type="string">
  Message ID assigned by Meta (wamid). Use to check the message status.
</ResponseField>

<ResponseField name="template_name" type="string">
  Name of the template sent.
</ResponseField>

<ResponseField name="recipient_phone" type="string">
  Recipient's phone number.
</ResponseField>

<ResponseField name="status" type="string">
  Initial message status. Always `"sent"` when sent successfully.
</ResponseField>

<ResponseField name="sent_at" type="string (ISO 8601)">
  Date and time when the message was sent.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.mindosoftware.com/api/v1/meta-templates/send/ \
    -H "X-API-Key: mindo_xxxxxxxxxxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "phone_number_id": "813497231850626",
      "template_name": "welcome_message",
      "language": "es",
      "recipient_phone": "+5491112345678",
      "variables": {
        "name": "Juan Perez",
        "code": "ABC123"
      },
      "button_variables": {
        "button_0": "ABC-123"
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.mindosoftware.com/api/v1/meta-templates/send/",
      headers={"X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx"},
      json={
          "phone_number_id": "813497231850626",
          "template_name": "welcome_message",
          "language": "es",
          "recipient_phone": "+5491112345678",
          "variables": {
              "name": "Juan Perez",
              "code": "ABC123"
          },
          "button_variables": {
              "button_0": "ABC-123"
          }
      }
  )

  data = response.json()
  print(f"Message ID: {data['message_id']}")
  print(f"Status: {data['status']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.mindosoftware.com/api/v1/meta-templates/send/",
    {
      method: "POST",
      headers: {
        "X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        phone_number_id: "813497231850626",
        template_name: "welcome_message",
        language: "es",
        recipient_phone: "+5491112345678",
        variables: {
          name: "Juan Perez",
          code: "ABC123"
        },
        button_variables: {
          button_0: "ABC-123"
        }
      })
    }
  );

  const data = await response.json();
  console.log("Message ID:", data.message_id);
  console.log("Status:", data.status);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - OK theme={null}
  {
    "success": true,
    "message_id": "wamid.HBgNNTQ5MTEyMzQ1Njc4FQIAERgSQjVBN0YzRjQ2NzFCNDVBNQA=",
    "template_name": "welcome_message",
    "recipient_phone": "+5491112345678",
    "status": "sent",
    "sent_at": "2025-11-16T21:30:00Z"
  }
  ```

  ```json 400 - Validation theme={null}
  {
    "phone_number_id": ["This field is required."],
    "recipient_phone": ["This field is required."]
  }
  ```

  ```json 400 - Template not approved theme={null}
  {
    "error": "Template 'welcome_message' no tiene estado APPROVED"
  }
  ```

  ```json 404 - Template not found theme={null}
  {
    "error": "Template 'welcome_message' (language: es) no encontrado en este business account"
  }
  ```

  ```json 404 - Number not found theme={null}
  {
    "error": "Numero de WhatsApp con ID '813497231850626' no encontrado"
  }
  ```

  ```json 401 - Not authenticated theme={null}
  {
    "error": "Este endpoint requiere autenticacion con API Key (header X-API-Key)"
  }
  ```
</ResponseExample>

## Message statuses

The message `status` field can have the following values:

| Status      | Description                                 |
| ----------- | ------------------------------------------- |
| `sent`      | Message sent to Meta successfully           |
| `delivered` | Message delivered to the recipient's device |
| `read`      | Message read by the recipient               |
| `failed`    | Message send failed                         |

<Note>
  The individual status lookup endpoint (`GET /api/v1/meta-templates/messages/\{message_id\}/`) will be available soon. In the meantime, you can use the returned `message_id` for internal traceability.
</Note>

## Use cases

<AccordionGroup>
  <Accordion title="Welcome message for a new customer">
    Send a personalized welcome message when a new customer registers.

    ```python Python theme={null}
    import requests

    response = requests.post(
        "https://api.mindosoftware.com/api/v1/meta-templates/send/",
        headers={"X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx"},
        json={
            "phone_number_id": "813497231850626",
            "template_name": "welcome_message",
            "recipient_phone": "+5491112345678",
            "variables": {
                "name": "Juan Perez"
            }
        }
    )

    data = response.json()
    print(f"Welcome sent: {data['message_id']}")
    ```

    ```javascript JavaScript theme={null}
    const response = await fetch(
      "https://api.mindosoftware.com/api/v1/meta-templates/send/",
      {
        method: "POST",
        headers: {
          "X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          phone_number_id: "813497231850626",
          template_name: "welcome_message",
          recipient_phone: "+5491112345678",
          variables: { name: "Juan Perez" }
        })
      }
    );

    const data = await response.json();
    console.log("Welcome sent:", data.message_id);
    ```
  </Accordion>

  <Accordion title="Verification code">
    Send a unique verification code to a user.

    ```python Python theme={null}
    import requests
    import secrets

    code = secrets.token_hex(3).upper()

    response = requests.post(
        "https://api.mindosoftware.com/api/v1/meta-templates/send/",
        headers={"X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx"},
        json={
            "phone_number_id": "813497231850626",
            "template_name": "verification_code",
            "recipient_phone": "+5491112345678",
            "variables": {
                "name": "Juan",
                "code": code
            }
        }
    )

    data = response.json()
    print(f"Code {code} sent: {data['message_id']}")
    ```

    ```javascript JavaScript theme={null}
    const code = Math.random().toString(36).substring(2, 8).toUpperCase();

    const response = await fetch(
      "https://api.mindosoftware.com/api/v1/meta-templates/send/",
      {
        method: "POST",
        headers: {
          "X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          phone_number_id: "813497231850626",
          template_name: "verification_code",
          recipient_phone: "+5491112345678",
          variables: { name: "Juan", code }
        })
      }
    );

    const data = await response.json();
    console.log(`Code ${code} sent:`, data.message_id);
    ```
  </Accordion>

  <Accordion title="Order status notification">
    Notify a customer when their order status changes.

    ```python Python theme={null}
    import requests

    response = requests.post(
        "https://api.mindosoftware.com/api/v1/meta-templates/send/",
        headers={"X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx"},
        json={
            "phone_number_id": "813497231850626",
            "template_name": "order_update",
            "recipient_phone": "+5491112345678",
            "variables": {
                "order_id": "ORD-001",
                "status": "In transit"
            }
        }
    )

    data = response.json()
    print(f"Notification sent: {data['message_id']}")
    ```

    ```javascript JavaScript theme={null}
    const response = await fetch(
      "https://api.mindosoftware.com/api/v1/meta-templates/send/",
      {
        method: "POST",
        headers: {
          "X-API-Key": "mindo_xxxxxxxxxxxxxxxxxxxxxxxx",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          phone_number_id: "813497231850626",
          template_name: "order_update",
          recipient_phone: "+5491112345678",
          variables: { order_id: "ORD-001", status: "In transit" }
        })
      }
    );

    const data = await response.json();
    console.log("Notification sent:", data.message_id);
    ```
  </Accordion>
</AccordionGroup>
