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

# Inicio rápido

> Crea una clave, elige un canal y manda tu primer mensaje.

**1. Crea una clave de API**

En Gluu, ve a **Configuración → Desarrolladores** y crea una clave con permiso `full`. Necesitas ser
administrador del workspace.

La clave completa se muestra una sola vez: guárdala en un lugar seguro, por ejemplo en la variable de
entorno `GLUU_API_KEY` de tu servidor.

**2. Busca el id de tu canal**

Lista los canales del workspace y copia el `id` de un canal de WhatsApp con estado `connected`.

```bash theme={null}
curl https://api.wegluu.com/v1/channels \
  -H "Authorization: Bearer $GLUU_API_KEY"
```

```json theme={null}
{
  "data": [
    {
      "id": "0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10",
      "name": "Ventas",
      "type": "whatsapp",
      "status": "connected"
    }
  ]
}
```

**3. Manda un mensaje**

Si el contacto no te escribió en las últimas 24 horas, WhatsApp solo deja mandar una
[plantilla aprobada](https://docs.wegluu.com/guides/templates.md). Lista las tuyas con `GET /templates` y manda una:

```bash cURL theme={null}
curl https://api.wegluu.com/v1/messages \
  -H "Authorization: Bearer $GLUU_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: pedido-4821-confirmacion" \
  -d '{
    "channel_id": "0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10",
    "to": "+5215512345678",
    "type": "template",
    "template": {
      "name": "confirmacion_pedido",
      "language": "es_MX",
      "variables": { "1": "Ana", "2": "#4821" }
    }
  }'
```

```javascript Node.js theme={null}
const response = await fetch("https://api.wegluu.com/v1/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GLUU_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "pedido-4821-confirmacion",
  },
  body: JSON.stringify({
    channel_id: "0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10",
    to: "+5215512345678",
    type: "template",
    template: {
      name: "confirmacion_pedido",
      language: "es_MX",
      variables: { 1: "Ana", 2: "#4821" },
    },
  }),
});
const { data: message } = await response.json();
```

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

response = requests.post(
    "https://api.wegluu.com/v1/messages",
    headers={
        "Authorization": f"Bearer {os.environ['GLUU_API_KEY']}",
        "Idempotency-Key": "pedido-4821-confirmacion",
    },
    json={
        "channel_id": "0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10",
        "to": "+5215512345678",
        "type": "template",
        "template": {
            "name": "confirmacion_pedido",
            "language": "es_MX",
            "variables": {"1": "Ana", "2": "#4821"},
        },
    },
)
message = response.json()["data"]
```

Gluu responde `202` con el mensaje en estado `pending`. Si el número es nuevo, Gluu crea el contacto y la
conversación.

Si el contacto sí te escribió en las últimas 24 horas, puedes mandar un texto libre:

```json theme={null}
{
  "channel_id": "0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10",
  "to": "+5215512345678",
  "type": "text",
  "text": { "body": "Hola Ana, tu pedido ya salió." }
}
```

**4. Revisa si se entregó**

Consulta el mensaje con su `id`, o configura un [webhook](https://docs.wegluu.com/guides/webhooks.md) para enterarte sin preguntar.

```bash theme={null}
curl https://api.wegluu.com/v1/messages/0193a1c8-0e2f-7a55-b1d3-9c4e7f2a6b08 \
  -H "Authorization: Bearer $GLUU_API_KEY"
```

El campo `status` pasa por `pending`, `processing`, `sent`, `delivered` y `read`, o termina en `failed` con
el motivo en `error`.

## Siguientes pasos

> [card] [Todos los tipos de mensaje](https://docs.wegluu.com/guides/message-types.md)
>
> Archivos, botones, listas, ubicación, contactos, reacciones y respuestas citadas.

> [card] [Arma tu propio inbox](https://docs.wegluu.com/guides/inbox.md)
>
> Conversaciones, historial, respuestas y lectura.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.