# Página previa del enlace: completa o mínima

`PATCH /v1/onboarding-links/{id}`

Antes de abrir la ventana de Meta, el enlace de alta muestra una página previa. Hay dos:

**`full` (la de siempre, más corta).** Tres pasos con número —tener el teléfono a mano, el número en WhatsApp Business y no en otra API, esperar a que la ventana se cierre sola—, el botón justo debajo y el resto en «Más detalles».

**`minimal`.** Un solo botón grande, «Conectar WhatsApp», y una línea: «Se abre la ventana oficial de Meta. Al final, esperá a que se cierre sola.» Es para cuando ya le explicaste todo a tu cliente antes de mandarle el enlace. El botón no se puede saltear: el navegador sólo deja abrir la ventana de Meta con un clic de la persona.

**Dónde se elige.** Por enlace, con `intro` en `POST /v1/onboarding-links` (y `PATCH /v1/onboarding-links/{id}` en un enlace vivo; `null` = la de la cuenta). Para todos tus enlaces, `linkIntro` en `PUT /v1/branding` o en el panel: **Configuración › Marca › Alta por enlace → Página previa**. Gana el enlace; si no dice nada, la cuenta; si tampoco, `full`.

**Lo que medimos.** `GET /v1/onboarding-links/{id}` trae `introEffective` y `introClick`: con qué página tocó «Conectar» tu cliente por primera vez y cuánto tardó desde que se dibujó la página (`timeToClickMs`).

## Ejemplos

### cURL

```bash
# 1) per link: the page before Meta's window is just one button and one line
curl -X POST https://api.waiaconnect.com/v1/onboarding-links \
  -H "Authorization: Bearer wc_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"externalId": "pharmacy-42", "intro": "minimal", "historyDelivery": false}'

# 2) change it on a live link (null = the account's)
curl -X PATCH https://api.waiaconnect.com/v1/onboarding-links/onb_… \
  -H "Authorization: Bearer wc_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"intro": "full"}'

# 3) or for every link of the account that does not say it
curl -X PUT https://api.waiaconnect.com/v1/branding \
  -H "Authorization: Bearer wc_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"linkIntro": "minimal"}'

# 4) how long your customer took to tap «Connect»
curl https://api.waiaconnect.com/v1/onboarding-links/onb_… -H "Authorization: Bearer wc_live_YOUR_API_KEY"
# → { "link": { "intro": null, "introEffective": "minimal",
#       "introClick": { "mode": "minimal", "timeToClickMs": 4200, "at": "…" }, … } }
```

### Node.js

```javascript
const H = { "Authorization": "Bearer wc_live_YOUR_API_KEY", "Content-Type": "application/json" };

// per link
const link = await (await fetch("https://api.waiaconnect.com/v1/onboarding-links", {
  method: "POST", headers: H,
  body: JSON.stringify({ externalId: "pharmacy-42", intro: "minimal", historyDelivery: false })
})).json();

// or the account default (a link that sets "intro" wins)
await fetch("https://api.waiaconnect.com/v1/branding", { method: "PUT", headers: H, body: JSON.stringify({ linkIntro: "minimal" }) });

// later: how long it took to tap «Connect»
const { link: view } = await (await fetch(`https://api.waiaconnect.com/v1/onboarding-links/${link.publicId}`, { headers: H })).json();
console.log(view.introEffective, view.introClick?.timeToClickMs);
```

### PHP

```php
<?php
$h = ["Authorization: Bearer wc_live_YOUR_API_KEY", "Content-Type: application/json"];
$ch = curl_init("https://api.waiaconnect.com/v1/onboarding-links");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => $h,
  CURLOPT_POSTFIELDS => json_encode(["externalId" => "pharmacy-42", "intro" => "minimal", "historyDelivery" => false]),
]);
$link = json_decode(curl_exec($ch), true);
echo $link["url"];
```

### Python

```python
import requests
H = {"Authorization": "Bearer wc_live_YOUR_API_KEY"}

# per link
link = requests.post("https://api.waiaconnect.com/v1/onboarding-links", headers=H,
                     json={"externalId": "pharmacy-42", "intro": "minimal", "historyDelivery": False}).json()

# or the account default (a link that sets "intro" wins)
requests.put("https://api.waiaconnect.com/v1/branding", headers=H, json={"linkIntro": "minimal"})

# later: how long it took to tap «Connect»
view = requests.get(f"https://api.waiaconnect.com/v1/onboarding-links/{link['publicId']}", headers=H).json()["link"]
print(view["introEffective"], (view["introClick"] or {}).get("timeToClickMs"))
```

## Notas

- En Convivencia, si no mandás `historyDelivery`, la página igual pregunta primero si querés recibir el historial: es el consentimiento de tu cliente. Mandalo y en `minimal` queda sólo el botón.
- Los avisos que aparecen sólo cuando hacen falta siguen en las dos: el navegador de Facebook o Instagram (abrir en Chrome o Safari) y el de varios intentos iguales.
- Un valor que no sea `full`, `minimal` o `null` da `400 ONBOARDING_INTRO_INVALID`; un enlace usado, vencido o anulado no se edita (`410`).
