Skip to main content

baatzo

Send approved Utility and Authentication WhatsApp templates with the Baatzo API, read their status and verify status webhooks. Python 3.10 or later, no dependencies, typed.

pip install baatzo

Make a key in the Baatzo web app under Settings, Developers. Start with a sandbox key (bz_test_): it is free on every plan and nothing reaches WhatsApp. Keep keys on your server.

Send

from baatzo import Baatzo

baatzo = Baatzo()  # reads BAATZO_KEY

sent = baatzo.messages.send(
    to="+919829012345",
    template={"name": "login_code", "language": "en"},
    variables={"body": {"code": "482913"}},
    reference="login-88213",
    idempotency_key="login-88213-1",
)
# {"id": "0193…", "status": "accepted", …}

Give your own idempotency_key when your code may run the same send again, after a crash for example: the same key never sends twice in 24 hours. Without one, each call makes a new key. The sending number's phone number ID, needed only with more than one number, is from_.

Read

message = baatzo.messages.get(sent["id"])
print(message["status"], message["charge"])

Webhooks

Check the raw body, before any JSON parsing.

from baatzo import BaatzoSignatureError, verify_webhook

@app.post("/baatzo-webhook")  # Flask
def baatzo_webhook():
    try:
        event = verify_webhook(
            request.get_data(), request.headers.get("Baatzo-Signature"), os.environ["BAATZO_WEBHOOK_SECRET"]
        )
    except BaatzoSignatureError:
        return "", 400
    # Drop a repeat by event["id"]; ignore a lower event["data"]["status_rank"] than you have.
    return "", 200  # answer within 5 seconds, then do the work

verify_signature(raw_body, header, secret) answers True or False instead.

Errors and retries

  • BaatzoError: Baatzo refused. It has status, code (the list), details, request_id and retry_after.
  • BaatzoConnectionError: no answer came. The message may have been sent: try again with its idempotency_key.
  • BaatzoSignatureError: a webhook that does not verify.

The client tries again, twice by default and always with the same Idempotency-Key, after a 429, a 5xx, request_in_progress and a connection failure. It does not try retry_later again: send a fresh code.

A send can succeed as a request and still be refused by WhatsApp: check status for failed and withheld.

Options: Baatzo(api_key, base_url=..., timeout=30, max_retries=2).

Licence

MIT. By Aashita Technosoft Private Limited.

Metadata

Release files for baatzo 0.1.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 baatzo 0.1.0
File Size Uploaded Provenance Actions
baatzo-0.1.0.tar.gz 5.9 kB Without provenance Details for baatzo-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 12.5 kB

Release files / baatzo-0.1.0.tar.gz

Download URL baatzo-0.1.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dea68421667c1d4527a3d0fd2088d882f60140f157128644c79c228e19b5eeff
BLAKE2b-256 checksum
How to use checksums
857cdfe2032d4d26f48bab218873402bfcd899986764a4cfbf2ab4127389c409
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / baatzo-0.1.0-py3-none-any.whl

Download URL baatzo-0.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f25ae239c3a509e944ab94896d8c9a4e10622c14a6f54ec263298bea682e1da
BLAKE2b-256 checksum
How to use checksums
399d483c7c0cb41602422dbeb44de28cd331aab8fd6ca8c52da61348dbb5d6bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for baatzo 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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