Skip to main content

Typed Python SDK for WazzAPI

Project description

WazzAPI Python SDK

Official Python SDK for WazzAPI.

Use it to send messages, inspect WhatsApp devices, manage contacts and templates, and verify incoming webhooks with a simple typed client.

What you can do with this SDK

  • send direct WhatsApp messages
  • list and inspect WhatsApp devices
  • list, create, update, and delete contacts
  • manage message templates and preview rendered content
  • verify and parse incoming WazzAPI webhooks
  • work with typed request and response models

Requirements

  • Python 3.10+
  • a WazzAPI account
  • a WazzAPI API key

Install

From PyPI:

pip install wazzapi

With uv:

uv add wazzapi

Need a WazzAPI account first?

Sign up at https://app.wazzapi.com using your Google organization account. On first sign-in, WazzAPI creates a new workspace for you automatically.

Configuration

For most integrations, you only need your API key:

  • WAZZAPI_API_KEY

If you plan to receive webhooks, also configure:

  • WAZZAPI_WEBHOOK_SECRET

The SDK uses https://api.wazzapi.com by default, so you do not need to set a base URL.

Quick start

Send a message

from wazzapi import SendMessageRequest, WazzapiClient

with WazzapiClient(api_key="your-api-key") as client:
    response = client.messages.send(
        SendMessageRequest(
            phone_number="+6281234567890",
            whatsapp_account_id="your-whatsapp-account-id",
            content="Hello from WazzAPI!",
        )
    )

print(response.model_dump())

Error handling

When the API returns a non-success response, the SDK raises WazzapiAPIError.

from wazzapi import WazzapiAPIError, WazzapiClient

try:
    with WazzapiClient(api_key="your-api-key") as client:
        client.messages.get("missing-message-id")
except WazzapiAPIError as exc:
    print(exc.status_code)
    print(exc.message)

More usage examples

List contacts

from wazzapi import WazzapiClient

with WazzapiClient(api_key="your-api-key") as client:
    response = client.contacts.list(limit=20, search="alice")

for contact in response.contacts:
    print(contact.model_dump())

### List devices

```python
from wazzapi import WazzapiClient

with WazzapiClient(api_key="your-api-key") as client:
    response = client.devices.list(limit=20, status="connected")

for device in response.devices:
    print(device.name, device.session_name, device.status)

### Create a template

```python
from wazzapi import TemplateCreateRequest, WazzapiClient

with WazzapiClient(api_key="your-api-key") as client:
    template = client.templates.create(
        TemplateCreateRequest(
            name="welcome-message",
            category="marketing",
            content="Hi {{name}}, welcome to WazzAPI!",
        )
    )

print(template.model_dump())

Preview a template

from wazzapi import TemplatePreviewRequest, WazzapiClient

with WazzapiClient(api_key="your-api-key") as client:
    preview = client.templates.preview(
        TemplatePreviewRequest(
            content="Hi {{name}}, your code is {{code}}.",
            custom_variables={"name": "Alice", "code": "WZ-1234"},
        )
    )

print(preview.model_dump())

Webhook verification

Use WebhookHandler to verify the raw request body against X-Wazzapi-Signature before parsing JSON.

from wazzapi import WebhookHandler

handler = WebhookHandler("your-webhook-secret")
webhook = handler.verify_and_parse(raw_body, request.headers)

print(webhook.event_type)
print(webhook.data.model_dump())

WazzAPI webhook headers:

  • X-Wazzapi-Signature
  • X-Wazzapi-Event
  • X-Wazzapi-Event-ID

Supported webhook event families:

  • message events: message.received, message.sent, message.delivered, message.read, message.failed
  • device events: device.connected, device.disconnected

Examples

Ready-to-run examples live in examples/:

  • examples/list_devices.py
  • examples/list_contacts.py
  • examples/send_message.py
  • examples/create_template.py
  • examples/preview_template.py
  • examples/verify_webhook.py

Run them with:

uv run python examples/list_contacts.py
uv run python examples/list_devices.py
uv run python examples/send_message.py
uv run python examples/create_template.py
uv run python examples/preview_template.py
uv run python examples/verify_webhook.py

Release automation

This repository includes a GitHub Actions workflow that publishes to PyPI automatically when a tag matching v* is pushed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wazzapi-0.5.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wazzapi-0.5.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file wazzapi-0.5.0.tar.gz.

File metadata

  • Download URL: wazzapi-0.5.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.5

File hashes

Hashes for wazzapi-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d2ac76568a46a628073e1fe4c15ac854f70829cecc3cedc95b591d684d3f8119
MD5 8a069bc2b6758d4fde345181cec7f867
BLAKE2b-256 1eb9acc64c4a6e908757314799be41b153490aeb09deb0f7cc6d10487f9ae9b2

See more details on using hashes here.

File details

Details for the file wazzapi-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: wazzapi-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.5

File hashes

Hashes for wazzapi-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ca895de4c0587f1ea4dfb3fb8b154cc72c85c68d4ad372cacee1e78c0617730
MD5 676bb77f80ada6f22695659253a8dda0
BLAKE2b-256 bbe0c2c8a6a5276b1219b11a0aee239e17a1e561023a1e54486c09f5095f4f41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page