# Página prévia do link: completa ou mínima

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

Antes de abrir a janela da Meta, o link de cadastro mostra uma página prévia. São duas:

**`full` (a de sempre, mais curta).** Três passos numerados —ter o telefone à mão, o número no WhatsApp Business e não em outra API, esperar a janela fechar sozinha—, o botão logo abaixo e o resto em «Mais detalhes».

**`minimal`.** Um único botão grande, «Conectar WhatsApp», e uma linha: «Abre-se a janela oficial da Meta. No final, espere ela fechar sozinha.» É para quando você já explicou tudo ao seu cliente antes de mandar o link. O botão não pode ser pulado: o navegador só deixa abrir a janela da Meta com um toque da pessoa.

**Onde se escolhe.** Por link, com `intro` em `POST /v1/onboarding-links` (e `PATCH /v1/onboarding-links/{id}` num link ativo; `null` = a da conta). Para todos os seus links, `linkIntro` em `PUT /v1/branding` ou no painel: **Configurações › Marca › Cadastro por link → Página prévia**. Vale o link; se não disser nada, a conta; senão, `full`.

**O que medimos.** `GET /v1/onboarding-links/{id}` traz `introEffective` e `introClick`: em qual página o seu cliente tocou «Conectar» pela primeira vez e quanto demorou desde que a página apareceu (`timeToClickMs`).

## Exemplos

### 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

- Na Convivência, se você não mandar `historyDelivery`, a página ainda pergunta primeiro se quer receber o histórico: é o consentimento do seu cliente. Mande e em `minimal` fica só o botão.
- Os avisos que aparecem só quando precisam continuam nas duas: o navegador do Facebook ou do Instagram (abrir no Chrome ou no Safari) e o de várias tentativas iguais.
- Um valor que não seja `full`, `minimal` ou `null` dá `400 ONBOARDING_INTRO_INVALID`; um link usado, vencido ou revogado não se edita (`410`).
