Python SDK

Install seed-messages and send SMS, OTP, and email with one client.

SMS · OTP · Email · package seed-messages

Install

1pip install seed-messages

Client

Base URL defaults to https://api-messages.seed.tg/v1. Pass sandbox URL for tests.

1from seed_messages import SeedMessages
2
3# Production
4client = SeedMessages(api_key="lks_live_xxx")
5
6# Sandbox (optional)
7# client = SeedMessages(
8#     api_key="lks_test_xxx",
9#     base_url="https://sandbox-api.seed.tg/v1",
10# )

Recommended API key scopes

sms:sendSMS
otp:sendOTP send
otp:verifyOTP verify
email:sendTransactional email
whatsapp:sendWhatsApp messages (optional)

SMS

Approved Sender ID + E.164 recipient. Maps to POST /v1/messages.

1sms = client.sms.send(
2    to="+22890000000",
3    sender="SEED",
4    text="Hello from SEED Messages",
5)
6print(sms.id, sms.status)

OTP

Primary flow: POST /v1/otp/send → user enters code → POST /v1/otp/verify. Default delivery_mode=auto tries WhatsApp then SMS.

Send (SEED generates the code)

1# SEED generates a 6-digit code, tries WhatsApp then SMS
2otp = client.otp.send(
3    to="+22890000000",
4    reference="login-1",
5    delivery_mode="auto",          # auto | whatsapp | sms
6    request_messaging_consent=False,
7)
8print(otp.challenge_id, otp.channel, otp.expires_at, otp.fallback_used)
9# Store challenge_id server-side until the user submits the code

Send (you supply the code)

1# You own the code (must be 4-8 digits)
2otp = client.otp.send(
3    to="+22890000000",
4    code="482917",
5    reference="checkout-42",
6    delivery_mode="auto",
7    request_messaging_consent=False,
8)

Verify

1result = client.otp.verify(
2    challenge_id=otp.challenge_id,
3    code="482917",
4)
5print(result.verified, result.status)  # True, "verified"

Poll challenge status

1status = client.otp.get(otp.challenge_id)
2print(status.status, status.attempts, status.channel, status.expires_at)

WhatsApp only (no SMS fallback)

Requires a client-supplied code. Prefer otp.send with delivery_mode=auto for production.

1# No SMS fallback - code is required
2wa = client.whatsapp.otp.send(
3    to="+22890000000",
4    code="482917",
5    reference="login-wa-only",
6)
7print(wa.challenge_id, wa.wamid)

Email

Send from a verified domain (or SEED shared domains). Maps to POST /v1/emails. At least text or html is required.

Send plain text

1email = client.email.send(
2    to=["[email protected]"],
3    from_email="[email protected]",
4    subject="Welcome to SEED",
5    text="Thanks for joining us.",
6    reference="welcome-1",
7)
8print(email.id, email.status)

Send with HTML

1email = client.email.send(
2    to=["[email protected]"],
3    from_email="[email protected]",
4    subject="Your receipt",
5    text="Thanks for your order.",
6    html="<p>Thanks for your <strong>order</strong>.</p>",
7    cc=["[email protected]"],
8)

Bulk send

1bulk = client.email.send_bulk(messages=[
2    {
3        "to": ["[email protected]"],
4        "from_email": "[email protected]",
5        "subject": "Hello A",
6        "text": "Message A",
7    },
8    {
9        "to": ["[email protected]"],
10        "from_email": "[email protected]",
11        "subject": "Hello B",
12        "text": "Message B",
13    },
14])
15for item in bulk.results:
16    print(item.id, item.status)