# Templates and webhooks

| Command | Purpose |
|---|---|
| `vatio templates list [--env live] [--json]` | The number's templates, their parameter count and the `template` object to send |
| `vatio templates create NAME --language CODE --body TEXT [--example VALUE]... [--category utility\|marketing] [--footer TEXT] [--json]` | Submit a template for Meta's review |
| `vatio webhooks list` / `create URL [--event NAME]... [--label NAME]` / `test ID` / `deliveries ID` / `enable ID` / `rm ID` | Where Vatio tells your backend what happened |

Your backend sends WhatsApp messages through the [server API](https://vatio.ai/docs/api/messages)
with a [server key](https://vatio.ai/docs/cli/keys); the CLI does not send them. These commands
set up what that backend needs.

## Templates

WhatsApp only delivers an approved template to someone who has not written in
the last 24 hours. Until you connect a number of your own, `templates create`
puts a template on Vatio's test number so you can try it: once Meta approves
it, a preview key sends it to your test phones. When you connect your own
number (`vatio whatsapp` prints where), Vatio moves your templates to it under
the same names, Meta reviews them again there, and they are removed from
Vatio's test number. From then on your backend sends from your number with a
live key, and `templates create` submits straight to it.

```sh
vatio templates create order_shipped --language es \
  --body "Hola {{1}}, tu pedido {{2}} va en camino." --example Ana --example "#1042"
```

- **`NAME`**: lowercase letters, digits and underscores.
- **`--language`**: Meta's code for it, like `es`, `en_US` or `pt_BR`.
- **`--body`**: up to 1024 characters. Placeholders are `{{1}}`, `{{2}}`, … in
  order, and the body cannot start or end with one.
- **`--example`**: one per placeholder, in order. Meta reviews the template with
  them filled in.
- **`--category`**: `utility` (the default) for updates someone expects, like
  a confirmation or a reminder; `marketing` for anything promotional. Meta may
  move a template to the category it thinks fits.

The template starts `PENDING`. Meta usually decides within minutes and at
most in 24 hours. `templates list --env preview` shows where it is on Vatio's
test number and `templates list` on your own, with the reason when it is
`REJECTED`. Each approved template comes with the `template` object to paste
into a request, with as many `params` as its body takes. The inbox's
**Outreach → Templates** shows the same, for whichever number your backend
sends from, with a button to copy that object. A workspace keeps up
to 20 templates on Vatio's test number; a rejected one is not moved to your
own.

## Webhooks

`webhooks create` prints the signing secret once. `webhooks test` sends a
`ping` and shows how your endpoint answered, and `webhooks deliveries` lists
the last 50 deliveries with their status and errors. See
[Messages](https://vatio.ai/docs/api/messages#webhooks) for the events and the signature.
