Zindua
Back to blog
Python·July 17, 2026·10 min read

Python and FastAPI: send email and WhatsApp OTP with the Zindua SDK

Async httpx client, env-first keys, and one send() for email or WhatsApp. A practical FastAPI route pattern for login verification.

Python and FastAPI: send email and WhatsApp OTP with the Zindua SDK

Install and configure

Install zindua from PyPI and keep ZINDUA_API_KEY in your process environment or secrets manager. Use znd_test_ in staging and znd_live_ only in production.

The Python client validates key format and channel destinations locally so common mistakes fail before the network call.

example
pip install zindua

# .env
ZINDUA_API_KEY=znd_test_xxxxxxxxxxxxxxxxxxxxxxxx

FastAPI send route

Expose a server-only endpoint that accepts email or phone, then calls client.send with your template slug. Never ship the project key to the browser.

example
from fastapi import FastAPI
from zindua import Zindua
import os

app = FastAPI()
client = Zindua(api_key=os.environ["ZINDUA_API_KEY"])

@app.post("/auth/otp")
async def send_otp(email: str):
    await client.send(
        to=email,
        template="otp-verification",
        channel="email",
        variables={"code": "123456", "appName": "Acme"},
    )
    return {"ok": True}

WhatsApp and email parity

Switch channel without a second SDK. Keep template slugs shared across stacks so Node, Python, and .NET apps render the same OTP copy.

Before go-live, run CLI doctor and confirm the email connector or WhatsApp number is ready on the project.

  • Server-only API key
  • Stable template slug per intent
  • Lang fallback via project default
  • Doctor green before deploy

Quick start from this article

Open FastAPI docs

Full Python snippets and error codes.

Open guide

Install the SDK

Official package from PyPI.

terminal
pip install zindua

Run doctor

Confirm key and channels.

terminal
npx @zindua/cli@latest doctor

Related articles

WhatsApp

WhatsApp OTP: why Zindua enforces a 3-second gap (and how to integrate it)

Burst sends look like spam and can ban your linked number. Space WhatsApp POST /api/v1/send calls by at least 3 seconds, with Node, PHP, Python, and C# patterns.

MCP

Beginner guide: Zindua MCP 1.1 for Cursor and Claude (start here)

Never used MCP? Add one JSON file, reload your editor, then type one sentence. Closed-loop OTP: workflow → scaffold → validate → send → watch log.

Cursor

Ship OTP from Cursor: the Zindua plugin for Marketplace

Rules, slash commands, and @zindua/mcp in one install. Diagnose your project with /zindua-doctor without pasting API keys into chat.

Try it in your stack

Docs and MCP tools to validate keys, templates, and OTP delivery.