Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

kapso-python

CI

A Python SDK for Kapso (WhatsApp Business), built from real webhook traffic.

Unofficial, community-built: not affiliated with or endorsed by Kapso. Early and learning-driven (alpha): the API will change.

uv add "kapso-python @ git+https://github.com/Joselier3/kapso-python"   # until the first PyPI release
import kapso

if not kapso.verify(raw_body, headers.get("x-webhook-signature"), secret):
    ...  # reject: 401

for msg in kapso.parse(raw_body, headers.get("x-webhook-event")):
    print(msg.message_id, msg.type, msg.text)

async with kapso.KapsoClient(api_key) as client:
    wamid = await client.messages.send_text(phone_number_id, to="15551234567", body="Hola!")

What works today

  • verify(): checks Kapso's X-Webhook-Signature (HMAC-SHA256 of the raw body) in constant time, without crashing on malformed headers.

  • Typed payloads: Pydantic models for whatsapp.message.* webhooks, single and batched (buffering on), including media.

  • parse(): turns a verified delivery into a flat list[InboundMessage]. Batches are flattened, status events and outbound or imported-history messages are ignored, and media comes back as a reference (URL hidden from repr).

  • KapsoClient: async client (httpx). client.messages.send_text(...) returns the new message's WAMID; API errors raise KapsoError with status_code, code and Kapso's message, never the API key.

Works with any web framework: verify and parse take the raw body bytes and header values.

Design

  • Small core. Runtime dependencies are pydantic and httpx only. Framework integrations will be optional extras.
  • No hidden configuration. The library never reads environment variables or .env files. Your app loads its secrets however it likes and passes them in.
  • Distribution vs import name. The project is kapso-python; you import kapso.
  • Organized by API area. kapso/webhooks/ (receiving), kapso/messages/ (sending), more as they're added; domain types in kapso/types.py. Import everything public from kapso itself: the internal layout may change.

Example: FastAPI receiver

examples/fastapi_receiver.py is a minimal app that verifies, parses and logs deliveries, and replies "Hola, mundo!" to each inbound message (after answering the webhook, via a background task).

uv sync
cp .env.example .env          # fill in WEBHOOK_SECRET and KAPSO_API_KEY
uv run fastapi dev            # http://127.0.0.1:8000
ngrok http 8000               # public URL for Kapso

In Kapso, add a WhatsApp webhook on your phone number pointing at https://<your-ngrok-url>/webhooks/kapso, subscribed to whatsapp.message.received, with the same secret as WEBHOOK_SECRET.

The example saves each verified delivery to tests/fixtures/ (gitignored) so real payloads can be replayed in tests.

Development

uv sync
uv run pytest -q              # tests
uv run ruff check .           # lint
uv run ruff format .          # format

Tests that need real captured payloads skip when those files are missing. Captures contain phone numbers and message text, so they are never committed. CI runs lint and tests on Python 3.11 to 3.14 and checks that the built wheel imports.

Releases: bump version in pyproject.toml, update CHANGELOG.md, then publish a GitHub release tagged v<version>; the release workflow publishes to PyPI.

License

MIT: free to use, modify and ship, including commercially.

Metadata

Release files for kapso-python 0.1.0a1

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

Source distribution (sdist)

Source distribution for kapso-python 0.1.0a1
File Size Uploaded Provenance Actions
kapso_python-0.1.0a1.tar.gz 136.7 kB With provenance Details for kapso_python-0.1.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kapso-python 0.1.0a1
File Interpreter ABI Platform Actions
kapso_python-0.1.0a1-py3-none-any.whl Python 3 none any Details for kapso_python-0.1.0a1-py3-none-any.whl

Total release size: 150.3 kB

Release files / kapso_python-0.1.0a1.tar.gz

Download URL kapso_python-0.1.0a1.tar.gz
Size 136.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bb999c721a62b4c313e6e6696ddea275c0fa3f43af3bd8de1f7c9693f7650a5d
BLAKE2b-256 checksum
How to use checksums
57a68d81b0606fe42266508ce4b922545a51edb8e839f1d05b8e98d2f36ed3a0
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 30, 2026.

Transparency log

Release files / kapso_python-0.1.0a1-py3-none-any.whl

Download URL kapso_python-0.1.0a1-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
367d1745a318e173b5ab0d5f2575cd6f7f9e7012ffdc45aefb4d8b34b3debd6c
BLAKE2b-256 checksum
How to use checksums
a0f180d3ead2e77df231c5941f2dc5848574d31541c034ff6d9bee425230a68e
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 30, 2026.

Transparency log

Security for kapso-python 0.1.0a1

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 kapso_python-0.1.0a1.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 30, 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