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

# Enviar un template

> Cómo enviar plantillas aprobadas con variables dinámicas.

## ¿Cuándo usar templates?

* Cuando el contacto **no te escribió** en las últimas 24 horas
* Para **campañas** o notificaciones proactivas
* Para **confirmaciones de pedido**, envíos, pagos

***

## 1. Buscar templates disponibles

```bash theme={null}
curl "https://api.waspytech.com/api/v2/templates?status=APPROVED" \
  -H "Authorization: Bearer wspy_tu_key"
```

Elegí un template y anotá su `name` y `language`.

***

## 2. Enviar template sin variables

```bash theme={null}
curl -X POST https://api.waspytech.com/api/v2/messages \
  -H "Authorization: Bearer wspy_tu_key" \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumberId": "TU_PHONE_NUMBER_ID",
    "to": "+5491126032641",
    "type": "template",
    "template": {
      "name": "hello_world",
      "language": { "code": "en_US" }
    }
  }'
```

***

## 3. Enviar template con variables

Si tu template tiene variables (ej: `Hola {{1}}, tu pedido {{2}} fue confirmado`):

```bash theme={null}
curl -X POST https://api.waspytech.com/api/v2/messages \
  -H "Authorization: Bearer wspy_tu_key" \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumberId": "TU_PHONE_NUMBER_ID",
    "to": "+5491126032641",
    "type": "template",
    "template": {
      "name": "confirmacion_pedido",
      "language": { "code": "es_AR" },
      "components": [
        {
          "type": "body",
          "parameters": [
            { "type": "text", "text": "María" },
            { "type": "text", "text": "#1847" }
          ]
        }
      ]
    }
  }'
```

Los parámetros se asignan en orden: `{{1}}` = primer parámetro, `{{2}}` = segundo, etc.

***

## Errores comunes

| Error                  | Causa                                    | Solución                                      |
| ---------------------- | ---------------------------------------- | --------------------------------------------- |
| `TEMPLATE_NOT_FOUND`   | El template no existe o no está aprobado | Verificá nombre, idioma y que esté `APPROVED` |
| Error de Meta `132000` | Parámetros incorrectos                   | Revisá cantidad y tipo de variables           |
