Skip to main content

Send a Message

result = client.messages.send(
    to="+14155551234",
    text="Your verification code is 123456",
    channel="sms",  # optional: sms, whatsapp, email
    idempotency_key="unique-key"  # optional: prevent duplicates
)

print(result.message.id)      # msg_xxx
print(result.message.status)  # queued

Send with Sender

Specify which sender profile to use:
result = client.messages.send(
    to="+14155551234",
    text="Hello!",
    zavu_sender="snd_abc123"
)

Send with Template

Send a WhatsApp template message:
result = client.messages.send(
    to="+14155551234",
    message_type="template",
    content={
        "template_id": "tpl_abc123",
        "template_variables": {
            "1": "John",
            "2": "12345"
        }
    }
)

Send WhatsApp Media

Image

result = client.messages.send(
    to="+14155551234",
    message_type="image",
    text="Check out this product!",
    content={
        "media_url": "https://example.com/image.jpg"
    }
)

Document

result = client.messages.send(
    to="+14155551234",
    message_type="document",
    content={
        "media_url": "https://example.com/invoice.pdf",
        "filename": "invoice.pdf"
    }
)

Video

result = client.messages.send(
    to="+14155551234",
    message_type="video",
    text="Watch this!",
    content={
        "media_url": "https://example.com/video.mp4"
    }
)

Send Interactive Messages

Buttons

result = client.messages.send(
    to="+14155551234",
    message_type="buttons",
    text="How would you rate your experience?",
    content={
        "buttons": [
            {"id": "great", "title": "Great!"},
            {"id": "okay", "title": "It was okay"},
            {"id": "poor", "title": "Not good"}
        ]
    }
)

List

result = client.messages.send(
    to="+14155551234",
    message_type="list",
    text="Select an option:",
    content={
        "list_button": "View Options",
        "sections": [
            {
                "title": "Products",
                "rows": [
                    {"id": "prod_1", "title": "Product A", "description": "$10.00"},
                    {"id": "prod_2", "title": "Product B", "description": "$20.00"}
                ]
            }
        ]
    }
)

Send Email

result = client.messages.send(
    to="user@example.com",
    channel="email",
    subject="Your order has shipped",
    text="Hi John, your order #12345 has shipped.",
    html_body="<h1>Order Shipped</h1><p>Your order #12345 has shipped.</p>",
    reply_to="support@example.com"
)

Get Message Status

result = client.messages.get(message_id="msg_abc123")
print(result.message.status)  # queued, sending, delivered, failed

List Messages

# List all messages
result = client.messages.list()
for message in result.items:
    print(message.id)

# With filters
result = client.messages.list(
    status="delivered",
    channel="sms",
    limit=100
)

# Pagination
cursor = None
while True:
    result = client.messages.list(cursor=cursor, limit=50)
    for message in result.items:
        print(message.id)
    cursor = result.next_cursor
    if not cursor:
        break

Send Reaction

React to a WhatsApp message:
result = client.messages.react(
    message_id="msg_abc123",
    emoji="👍"
)

Async Usage

import asyncio
from zavudev import AsyncZavudev

async def main():
    client = AsyncZavudev()

    result = await client.messages.send(
        to="+14155551234",
        text="Hello async!"
    )
    print(result.message.id)

asyncio.run(main())