Skip to main content

MultiWA Python SDK

Official Python SDK for MultiWA - WhatsApp Business API Gateway.

Installation

pip install multiwa

To work on the SDK itself, install it from the MultiWA monorepo:

pip install -e "packages/sdk-python[dev]"

Quick Start

from multiwa import MultiWA

# Initialize the client. base_url must include the API prefix /api/v1.
#   Local dev: http://localhost:3000/api/v1
#   Docker:    http://localhost:3333/api/v1
#   Prod:      https://your-multiwa-instance.com/api/v1
client = MultiWA(
    base_url="https://your-multiwa-instance.com/api/v1",
    api_key="your-api-key",
)

# Send a text message
result = client.messages.send_text(
    profile_id="your-profile-id",
    to="6281234567890",
    text="Hello from MultiWA Python SDK!"
)

print(result.status, result.message_id)

A request the API refuses raises httpx.HTTPStatusError (for example 429 when a daily send limit is reached). An argument the API cannot honour raises ValueError before anything is sent.

Features

Messages

# Send text, optionally quoting a message
client.messages.send_text(profile_id, to, text)

# Send image / video (url= or base64=)
client.messages.send_image(profile_id, to, url="https://...", caption="Check this!")
client.messages.send_video(profile_id, to, url="https://...", caption="Watch this!")

# Send audio; ptt=True sends a voice note
client.messages.send_audio(profile_id, to, url="https://...", ptt=True)

# Send document
client.messages.send_document(profile_id, to, filename="report.pdf", url="https://...")

# Send location
client.messages.send_location(profile_id, to, latitude=-6.2088, longitude=106.8456)

# Send contact
client.messages.send_contact(profile_id, to, name="John Doe", phone="+6281234567890")

# Send poll (2 to 12 options)
client.messages.send_poll(
    profile_id, to,
    question="What's your favorite color?",
    options=["Red", "Green", "Blue"]
)

# React to a message: message_id is MultiWA's id (result.message_id), not WhatsApp's
client.messages.send_reaction(profile_id, result.message_id, "👍")

# List stored messages, newest first
messages = client.messages.list(profile_id, limit=50, offset=0)

Every send returns a MessageResult: success, message_id (MultiWA's id), conversation_id, status (queued, sent or failed), wa_message_id (WhatsApp's id, once sent) and error.

Broadcasts

# Create a draft broadcast
broadcast = client.broadcasts.create(
    profile_id="...",
    name="Promo Campaign",
    recipients={"type": "tags", "value": ["customer", "vip"]},
    message="Hello! Our promo starts today.",
)

# recipients can also be {"type": "contacts", "value": [contact ids or phone numbers]},
# {"type": "all", "value": []}, or a plain list of phone numbers.
# message can also be a message object, e.g. {"type": "image", "url": "https://...", "text": "Caption"}.
# settings sets the pacing, e.g. settings={"delayMin": 3000, "delayMax": 10000, "batchSize": 50}.

# Start now, or schedule a draft for later (an ISO 8601 string or a timezone-aware datetime)
client.broadcasts.start(broadcast.id)
client.broadcasts.schedule(broadcast.id, "2026-12-01T09:00:00Z")
# create(..., schedule_at=...) does both steps at once

client.broadcasts.pause(broadcast.id)
client.broadcasts.resume(broadcast.id)
client.broadcasts.cancel(broadcast.id)  # the API marks it "failed"

stats = client.broadcasts.stats(broadcast.id)  # includes successRate and progress (percent)
broadcasts = client.broadcasts.list(profile_id, status="running")

Broadcast reads its counts (total_recipients, sent_count, delivered_count, failed_count) from the API's stats.

Contacts

# Create a contact (an existing phone number is updated, tags merged)
contact = client.contacts.create(
    profile_id="...",
    phone="6281234567890",
    name="John Doe",
    tags=["customer", "vip"],
    metadata={"email": "john@example.com"},
)

# List and filter (tags matches contacts with any of them)
contacts = client.contacts.list(profile_id, search="john", tags=["vip"], limit=50)

client.contacts.update(contact.id, name="John D.")
client.contacts.add_tags(contact.id, ["newsletter"])
client.contacts.remove_tags(contact.id, ["vip"])
client.contacts.delete(contact.id)

The API stores no email for a contact: keep it in metadata. Contact.email is always None, and passing email= raises ValueError.

Profiles

profile = client.profiles.create(workspace_id="...", name="Sales")
client.profiles.connect(profile.id)
status = client.profiles.status(profile.id)  # status, phone, engineConnected, ...
profiles = client.profiles.list()

The QR code to link a profile is not available over REST: after connect(), take it from the WebSocket qr:update event or a connection.qr webhook. profiles.get_qr() is deprecated and raises NotImplementedError.

Webhooks

# Create webhook; the API generates the signing secret
webhook = client.webhooks.create(
    profile_id="...",
    url="https://your-webhook.com/whatsapp",
    events=["message.received", "message.sent"]
)
print(webhook.secret)

client.webhooks.update(webhook.id, is_active=False)  # disable
client.webhooks.test(webhook.id)

Verify each delivery against the raw request body:

from multiwa import verify_webhook_signature

ok = verify_webhook_signature(raw_body, request.headers["X-MultiWA-Signature"], webhook.secret)

Calls

client.calls is in SDK 1.4.0 and later.

Incoming WhatsApp calls: the follow-up queue, the readiness of answering them in the dashboard, the recordings and the announcement (Calls answered in the dashboard).

page = client.calls.list(profile_id, outcome="answered")   # newest first; page.next_cursor
client.calls.update(call_id, follow_up="done")              # unassign=True removes the assignee
client.calls.reply(call_id, "We will call you back")

# Owners and admins
with open("notice.mp3", "rb") as f:                         # recording needs the announcement first
    client.calls.upload_announcement(profile_id, f)
client.calls.update_settings(profile_id, answer_in_dashboard=True, recording=True)
audio = client.calls.get_recording(call_id)                 # AudioFile: content, content_type
client.calls.delete_recording(call_id)

Every calls method is in the Python SDK guide. An API key acts with its user's role, and a key with a scope list needs the scopes in API keys. The client's timeout is httpx's: it bounds each connect, read and write, not the whole download of a recording. A refused setting raises httpx.HTTPStatusError (409); e.response.json()["reasons"] says why. Answering is for people signed in to the dashboard: follow calls with the call.* webhooks, or the WebSocket call:update event.

Async Support

AsyncMultiWA has the same resources and methods; await each call.

import asyncio
from multiwa import AsyncMultiWA

async def main():
    async with AsyncMultiWA(
        base_url="https://your-multiwa-instance.com/api/v1",
        api_key="your-api-key"
    ) as client:
        result = await client.messages.send_text(
            profile_id="...",
            to="6281234567890",
            text="Hello async!"
        )
        print(result)

asyncio.run(main())

Other endpoints

client.request(method, path, **kwargs) calls any other route, relative to base_url, and returns the decoded JSON:

groups = client.request("GET", f"/groups/profile/{profile_id}")

Both clients take a transport= argument that is passed to httpx, e.g. httpx.HTTPTransport(retries=3) or an httpx.MockTransport in tests.

Development

python3 -m venv .venv && .venv/bin/pip install -e '.[dev]'
.venv/bin/pytest -q
.venv/bin/ruff check . && .venv/bin/mypy multiwa

License

MIT - See LICENSE for details.

Metadata

Release files for multiwa 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multiwa 1.4.0
File Size Uploaded Provenance Actions
multiwa-1.4.0.tar.gz 19.2 kB With provenance Details for multiwa-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multiwa 1.4.0
File Interpreter ABI Platform Actions
multiwa-1.4.0-py3-none-any.whl Python 3 none any Details for multiwa-1.4.0-py3-none-any.whl

Total release size: 43.0 kB

Release files / multiwa-1.4.0.tar.gz

Download URL multiwa-1.4.0.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b6061f3808304e023265fe8be616b8a9569621184e45e6beff114229752c98e1
BLAKE2b-256 checksum
How to use checksums
84dc6be83a2c85fa6cf2ae3457f1f1b669405f44c0edaa547aa2d6ed21c1ce01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / multiwa-1.4.0-py3-none-any.whl

Download URL multiwa-1.4.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d004a26663424bb1744b3c74a7e6d0ccf3a46090a01b3ef4819f7be0b1a472e
BLAKE2b-256 checksum
How to use checksums
5070f36e8beb10df05d75eb40a2c660b8d8ee6da457559253074f3b3739c3a36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for multiwa 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for multiwa-1.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page