This release is a pre-release and may not be stable for production use.
kapso-python
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 # or: pip install kapso-python
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'sX-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 flatlist[InboundMessage]. Batches are flattened, status events and outbound or imported-history messages are ignored, and media comes back as a reference (URL hidden fromrepr). -
KapsoClient: async client (httpx).client.messages.send_text(...)returns the new message's WAMID; API errors raiseKapsoErrorwithstatus_code,codeand 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
pydanticandhttpxonly. Framework integrations will be optional extras. - No hidden configuration. The library never reads environment variables or
.envfiles. Your app loads its secrets however it likes and passes them in. - Distribution vs import name. The project is
kapso-python; youimport kapso. - Organized by API area.
kapso/webhooks/(receiving),kapso/messages/(sending), more as they're added; domain types inkapso/types.py. Import everything public fromkapsoitself: 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.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kapso_python-0.1.0a2.tar.gz | 14.0 kB | With provenance | Details for kapso_python-0.1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kapso_python-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details for kapso_python-0.1.0a2-py3-none-any.whl |
Total release size: 27.6 kB
Release files / kapso_python-0.1.0a2.tar.gz
| Download URL | kapso_python-0.1.0a2.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e6ecc36d5bee492f1fe981730a12e33cd451286b0287e7f8a1fb4bce4cb5e30
|
|
BLAKE2b-256 checksum How to use checksums |
e9a4e336350e6297e93cadee0a0e2438b1beda83613c496468fb9dab7248756a
|
| 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 logRelease files / kapso_python-0.1.0a2-py3-none-any.whl
| Download URL | kapso_python-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2c49a0fa91e27884810cb1a206c7736ca70e96b7f0e4d748a3080cb2e819dff
|
|
BLAKE2b-256 checksum How to use checksums |
615ac1c08d0042df8c62b49689e4428156eef6bb32569f2a37498ec577996d05
|
| 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 logSecurity for kapso-python 0.1.0a2
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.
Attestation for kapso_python-0.1.0a2.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 logA 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.