Metadata-Version: 2.5
Name: wavesenda
Version: 1.0.0
Summary: WaveSenda — WhatsApp API and AI agents. Official Python SDK.
Project-URL: Homepage, https://wavesenda.com
Project-URL: Documentation, https://wavesenda.com/docs
License: MIT
Keywords: api,messaging,wavesenda,whatsapp
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# WaveSenda Python SDK

WhatsApp messaging, AI agents and deliverability, over one HTTP API.

```bash
pip install wavesenda
```

Requires Python 3.9+. One dependency, `httpx`.

## Sending

```python
from wavesenda import WaveSenda

wa = WaveSenda(os.environ["WAVESENDA_API_KEY"])

message = wa.messages.send(
    session="support",
    to="+237670000000",
    text="Your order is ready for collection.",
    idempotency_key="order-1042-ready",
)
```

Always set `idempotency_key` on anything a retry could re-run. On WhatsApp a
duplicate is not a tidy-up job — the recipient has already been notified twice,
and duplicates are one of the fastest ways to earn a spam report.

The client is a context manager, which closes the underlying connection pool:

```python
with WaveSenda(api_key) as wa:
    wa.messages.send(session="support", to=number, text=body)
```

## Errors

```python
from wavesenda import WaveSendaError

try:
    wa.messages.send(session="support", to=number, text=body)
except WaveSendaError as error:
    if error.code == "recipient_not_on_whatsapp":
        mark_not_reachable(number)      # never retry this one
    elif error.code == "sending_paused":
        # 423, not 429: the health engine stopped sending to protect the
        # number. Retrying through it defeats the only thing protecting you.
        alert_oncall(error.message)
    elif error.retryable:
        queue_for_later()
    else:
        raise
```

Transient failures — 5xx, 429, and a session whose socket dropped — are retried
twice by default with backoff, honouring `Retry-After` when the server sends it.
Pass `max_retries=` to change that.

## Paging

Every list endpoint returns a `Page`, and every one has an iterator that walks
the whole result set without you handling cursors:

```python
for message in wa.messages.iterate(session="support", direction="inbound"):
    index(message)
```

Prefer `iterate` over `list` for anything unbounded. A busy number produces more
messages than fit in memory.

## Webhooks

```python
from wavesenda import verify_webhook

if not verify_webhook(request.body, request.headers.get("X-WaveSenda-Signature"), secret):
    return HttpResponse(status=400)
```

Verify before parsing, not after. The signature covers the raw body, so a JSON
round-trip invalidates it.

## Resources

`wa.sessions`, `wa.messages`, `wa.contacts`, `wa.groups`, `wa.webhooks`.

Full reference: https://wavesenda.com/docs

## A word on what this is

WaveSenda automates a standard WhatsApp account through the multi-device
protocol rather than Meta's official Cloud API. That is contrary to WhatsApp's
terms of service, and a number used this way can be rate-limited or banned —
particularly with unsolicited or bulk sending. For customer-facing messaging at
scale, the official Cloud API is the safe path.
