ReachBellDocs

Server SDK (Python)

reachbell is the Python server-side companion to the browser SDK. Use it from your backend to send transactional messages, track events, and manage subscribers — without writing raw HTTP calls. It's the recommended way to do anything server-side; the Server API is the underlying REST layer for endpoints the SDK doesn't wrap yet.

Standard-library only — no dependencies. Python 3.8+.

Install

pip install reachbell

Initialize

import os
from reachbell import ReachBell
 
rb = ReachBell(api_key=os.environ["REACHBELL_API_KEY"])

Keep your API key server-side only — never ship it to the browser. (The browser uses the public key via @reachbell/sdk.)

Transactional push

Send a push to one user, identified by external_id (set via the browser SDK's identify()) or by raw token:

r = rb.transactional.send(
    external_id="user_42",
    title="Order shipped 📦",
    body="Your order arrives tomorrow.",
    url="https://shop.example/orders/4821",
)
 
# A 200 with delivered=False just means the user has no active subscription —
# it's a normal outcome, not an error.
if not r.get("delivered"):
    print("no active subscription")

Pass template_id (plus variables) instead of title/body to send from a saved template.

Transactional email

rb.transactional.email(
    to="user@example.com",
    subject="Your verification code",
    html_content="<p>Your code is <b>123456</b></p>",
)

sender_email / reply_to must be on your verified sending domain.

Transactional SMS & WhatsApp

rb.transactional.sms(external_id="user_42", text="Your code is 123456")
 
rb.transactional.whatsapp(
    external_id="user_42",
    template={"name": "order_update", "params": ["#4821", "shipped"]},
)

WhatsApp business-initiated messages need a pre-approved template (outside WhatsApp's 24-hour customer-service window); inside it you can send free-form text. Both channels must be configured for your project first — see SMS and WhatsApp.

Track events

Events can trigger automations:

rb.events.track(name="order_paid", external_id="user_42", properties={"amount": 4999})
rb.events.track_batch([...])  # up to 25 events

Subscribers

rb.subscribers.identify(token=token, external_id="user_42")  # link a subscription to your user id
rb.subscribers.delete(token)                                 # remove a subscriber

Errors

Non-2xx responses and network/timeout failures raise a ReachBellError with .status (0 for network errors) and .body:

from reachbell import ReachBell, ReachBellError
 
try:
    rb.transactional.send(external_id="u", title="t", body="b")
except ReachBellError as e:
    print(e.status, e.body)

Escape hatch

For any endpoint not yet wrapped by a helper:

rb.request("POST", "/some/endpoint", {"any": "payload"})