Skip to main content
The WSAPI Python SDK provides a typed client (Pydantic v2) for sending WhatsApp messages, managing groups and chats, and receiving real-time events via webhooks or Server-Sent Events (SSE).

Installation

Importing request models from wsapi_client.models needs wsapi-client 3.1.0 or later. On 3.0.x, import them from their module, e.g. wsapi_client.models.requests.messages.

Requirements

  • Python 3.9 or later
  • Valid WSAPI API key and instance ID

Quick start

Always call client.close() when done, or use the client as a context manager.

Error handling

The SDK provides two patterns for every operation:
Standard methods raise ApiException on failure:

Available resources

Receiving events via SSE

Handling webhooks

Available event types

Current request and response fields

Use SendMediaRequest(to=..., url=...) or data=..., and SendDocumentRequest(filename=...) from wsapi_client.models. Legacy MessageSend*Request imports remain accepted and serialize to the same REST fields. Invite links expose invite_link (also link); joining via link returns an object with id, while joining via invite returns None (HTTP 204). Privacy updates and history flushes return their response objects. Message events, including history messages, retain optional ad_referral; persist event.ad_referral.ctwa_clid when present. Account management and SSE are Cloud features. To create a named Cloud instance, use client.account.create_subscription_instance(subscription_id, name="Support").

GitHub

github.com/wsapi-chat/wsapi-python