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

# WhatsApp

> Send template messages with certified timestamps, managing senders and templates.

The WhatsApp API sends **template messages** through the WhatsApp Cloud API.
Every message can be backed by a certified RFC 3161 timestamp for legal proof.

<Note>
  All WhatsApp endpoints use **HTTP Basic Auth** —
  `username = account e-mail`, `password = securityToken`. See
  [Authentication](/en/authentication).
</Note>

## Concepts

* **Sender** — a WhatsApp Business number you connect (or a system number
  provided by Escrybe). Managed under *Senders*.
* **Template** — a pre-approved message structure (Meta approval required).
  Managed under *Templates*.
* **Message** — an outbound send bound to a template and a recipient.

## Endpoints

| Method   | Path                                           | Description                    |
| -------- | ---------------------------------------------- | ------------------------------ |
| `POST`   | `/api/whatsapp/v1/post`                        | Send a message                 |
| `GET`    | `/api/whatsapp/v1/get`                         | List / fetch messages          |
| `POST`   | `/api/whatsapp/v1/cancel`                      | Cancel a message               |
| `POST`   | `/api/whatsapp/v1/process`                     | Reprocess after adding credits |
| `GET`    | `/api/whatsapp/v1/download_attestation_bundle` | Download attestation bundle    |
| `GET`    | `/api/whatsapp/v1/senders/get`                 | List senders                   |
| `POST`   | `/api/whatsapp/v1/senders/post`                | Create / update a sender       |
| `POST`   | `/api/whatsapp/v1/senders/toggle`              | Change sender status           |
| `POST`   | `/api/whatsapp/v1/senders/sync_templates`      | Sync templates from Meta       |
| `GET`    | `/api/whatsapp/v1/templates/get`               | List templates                 |
| `POST`   | `/api/whatsapp/v1/templates/post`              | Create a template              |
| `PUT`    | `/api/whatsapp/v1/templates/put`               | Update a template              |
| `DELETE` | `/api/whatsapp/v1/templates/delete`            | Delete a template              |

Full request/response schemas live in the **API Reference** tab.

## Sending a message

```bash theme={null}
curl -X POST "https://app.escrybe.com.br/api/whatsapp/v1/post" \
  -u "you@example.com:YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "sender_name": "Acme Ltda",
    "sender_document": "12345678000190",
    "recipient_name": "Maria Silva",
    "recipient_phone": "+5511999998888",
    "recipient_document": "12345678901",
    "template_id": 50,
    "template_variables": {"1": "A1B2C3"},
    "paymentMethod": "escrybe_credits"
  }'
```

The response returns a `message_id`, a public `visual_id` and a `status` of
`processing` until payment is settled and the message is queued.

* The recipient's phone is verified against WhatsApp — numbers not on
  WhatsApp are rejected with `400`.
* If the template's header uses an image or document, one of `media_url`,
  `media_file` or `media_base64` is required.
* If a message stalls with status 2 (insufficient credits), top up your
  balance and `POST /api/whatsapp/v1/process` with the `message_id` to
  re-queue it.

## Certified timestamps

Each message can produce attestation files for the **accepted**, **sent**,
**delivered** and **read** phases. Download them all as a ZIP:

```bash theme={null}
curl "https://app.escrybe.com.br/api/whatsapp/v1/download_attestation_bundle?code=VISUAL_ID" \
  -u "you@example.com:YOUR_TOKEN" -o attestations.zip
```

## Templates

Templates must be approved by Meta before use. Create one, then poll its status
until `approved`:

```bash theme={null}
curl -X POST "https://app.escrybe.com.br/api/whatsapp/v1/templates/post" \
  -u "you@example.com:YOUR_TOKEN" \
  -F "sender_id=5" \
  -F "name=order_confirmation" \
  -F "category=UTILITY" \
  -F "body_text=Your order {{1}} was confirmed."
```

<Note>
  The final template name is normalized and prefixed with your user id (e.g.
  `user42_order_confirmation`) — the response's `name` field is what you use
  when sending; your original text is kept as `display_name`. A
  sender-identification footer is automatically appended to the body, and
  image/document header templates submitted without media use a default
  Escrybe sample file for Meta approval.
</Note>
