# Templates proposed by your customer

`POST /v1/template-links`

Your customer knows best what they need to say — but they never enter the panel. With a **proposal link** they build the template and you approve it. The flow: you generate the link (from **Proposals → Generate link**, or `POST /v1/template-links` with `connectionId`) scoped to **ONE number**; you send it; your customer opens a page with **your brand**, picks a catalog template, edits it with a WhatsApp-style preview and the pre-checker running in plain language, and submits. It arrives as a **draft** in the **Proposals** inbox (and via the `template.draft_submitted` webhook), with a suggested category. You review it, adjust the category if needed, and **Approve** → only then is it created in Meta (`PENDING`).

The **category** has a cost consequence (MARKETING costs more than UTILITY), so we never ask your customer for it: the system suggests it and you decide on approval. You can approve several at once.

There's a per-number switch, **'Require my approval'**, on by default. If you trust a customer, turn it off (Numbers → the number → General) and their proposals go straight to Meta without hitting the inbox.

## Examples

### cURL

```bash
curl -X POST https://api.waiaconnect.com/v1/template-links \
  -H "Authorization: Bearer wc_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"connectionId":"conn_…","suggestedRubro":"salud","resellerMessage":"Proponé el recordatorio de turno","draftLimit":5,"lang":"es"}'
# → { "url": "https://…/ct/<token>", "expiresAt": "…", "publicId": "onb_…" }
# Send url to your customer. They propose a template for THIS number; it arrives in your
# panel (and as template.draft_submitted) for you to approve. They never enter the panel.
```

### Node.js

```javascript
const res = await fetch("https://api.waiaconnect.com/v1/template-links", {
  method: "POST",
  headers: { "Authorization": "Bearer wc_live_YOUR_API_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({
  "connectionId": "conn_…",
  "suggestedRubro": "salud",
  "resellerMessage": "Proponé el recordatorio de turno",
  "draftLimit": 5,
  "lang": "es"
})
});
const { url } = await res.json(); // https://…/ct/<token> — send it to your customer
```

### PHP

```php
<?php
$ch = curl_init("https://api.waiaconnect.com/v1/template-links");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["Authorization: Bearer wc_live_YOUR_API_KEY", "Content-Type: application/json"],
  CURLOPT_POSTFIELDS => json_encode(["connectionId" => "conn_…","suggestedRubro" => "salud","resellerMessage" => "Proponé el recordatorio de turno","draftLimit" => 5,"lang" => "es"]),
]);
$out = json_decode(curl_exec($ch), true);
echo $out["url"]; // https://…/ct/<token> — send it to your customer
```

### Python

```python
import requests
res = requests.post("https://api.waiaconnect.com/v1/template-links",
  headers={"Authorization": "Bearer wc_live_YOUR_API_KEY", "Content-Type": "application/json"},
  json={"connectionId":"conn_…","suggestedRubro":"salud","resellerMessage":"Proponé el recordatorio de turno","draftLimit":5,"lang":"es"})
res.raise_for_status()
print(res.json()["url"])  # https://…/ct/<token> — send it to your customer
```

## Notes

- The link is for a **single number**: your customer can't propose for another of your numbers.
- The customer NEVER enters the panel or sees our brand (PRODUCTO §7). The page is login-less, with your brand.
- The **rejection reason is internal** (for your record): your customer doesn't see it in the product. If you want them to know, tell them through your own channel.
- You can cap how many proposals each link accepts (`draftLimit`) and add a message + a suggested rubro.
- The Meta sync **never** overwrites a draft: until you approve it, it lives only in Connect.
- **Approving or rejecting CLOSES that proposal's alert** (only that one: you can have several open on the same number). Before, the alert stayed open forever and the counter never went down.
- Proposal links also live in the **Links section**, with how many proposals each brought in and whether your customer opened it.
