Skip to main content

SMSFlow Python SDK

PyPI version CI License: MIT

The SMSFlow Python SDK makes it easy to send SMS messages and check SMS credit balance from backend Python applications, automation scripts, scheduled jobs, CRM integrations, ERP integrations, and operational tooling.

Documentation: https://docs.smsflow.co.za/

Install

pip install smsflow

Configuration

Store credentials in environment variables or your platform's secret manager.

export SMSFLOW_CLIENT_ID="YOUR_CLIENT_ID"
export SMSFLOW_CLIENT_SECRET="YOUR_CLIENT_SECRET"

Do not put SMSFlow Client Secrets in source code, logs, notebooks, screenshots, or public issues.

Usage

import os
from smsflow import SmsFlowClient

client = SmsFlowClient(
    client_id=os.environ["SMSFLOW_CLIENT_ID"],
    client_secret=os.environ["SMSFLOW_CLIENT_SECRET"],
    timeout=30,
)

response = client.send_sms(
    campaign_name="Python SDK example",
    messages=[
        {
            "destination": "27000000000",
            "content": "Your SMSFlow Python test message was sent successfully.",
        }
    ],
)

print(response["sendResponse"]["eventId"])

Bulk send

client.send_sms(
    campaign_name="Order dispatch alerts",
    messages=[
        {"destination": "27000000000", "content": "Order 1001 has shipped."},
        {"destination": "27000000001", "content": "Order 1002 has shipped."},
    ],
)

Check balance

balance = client.get_balance()
print(balance["balance"])

Error handling

from smsflow import SmsFlowAuthenticationError, SmsFlowError, SmsFlowValidationError

try:
    client.send_sms(
        campaign_name="Transactional SMS",
        messages=[{"destination": "27000000000", "content": "Hello from SMSFlow."}],
    )
except SmsFlowAuthenticationError:
    print("Check your SMSFlow Client ID and Client Secret.")
    raise
except SmsFlowValidationError as exc:
    print("Fix the request before retrying.", exc.code, exc.body)
    raise
except SmsFlowError as exc:
    print(exc.status_code, exc.code, exc.retryable, exc.body)
    raise

Timeouts and retries

Set a timeout and opt in to retry handling when your application can safely handle it:

client = SmsFlowClient(
    client_id=os.environ["SMSFLOW_CLIENT_ID"],
    client_secret=os.environ["SMSFLOW_CLIENT_SECRET"],
    timeout=30,
    retry_retries=2,
    retry_base_delay=0.25,
    retry_max_delay=2.0,
)

balance = client.get_balance()  # Safe to retry temporary failures.

client.send_sms(
    campaign_name="Transactional SMS",
    retry=True,  # Use only with your own idempotency or duplicate-send guard.
    messages=[{"destination": "27000000000", "content": "Hello from SMSFlow."}],
)

Retry only temporary network failures, 408, 429, and 5xx responses. Do not retry validation errors, authentication failures, or insufficient-balance responses until the underlying issue has been fixed. Store the returned eventId against your own transaction or notification record.

Delivery status

The public HTTPS API currently exposes authentication, send, and balance endpoints. Delivery-status helper methods will be added when a public delivery-status endpoint is available.

Features

  • Get and cache SMSFlow login tokens.
  • Send one or more SMS messages.
  • Schedule SMS messages using UTC delivery time.
  • Respect opt-out checks by default.
  • Check account balance.
  • Raise typed structured exceptions when the API returns an error.
  • Configure timeouts and opt-in retries for temporary failures.

Local test send

This command sends a real SMS and may consume test credits:

export SMSFLOW_CLIENT_ID="YOUR_CLIENT_ID"
export SMSFLOW_CLIENT_SECRET="YOUR_CLIENT_SECRET"
export SMSFLOW_DESTINATION="27000000000"
PYTHONPATH=src python examples/send_sms.py

Security

Never commit real credentials. Use environment variables or a secret manager.

License

MIT

Metadata

Release files for smsflow 0.2.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 smsflow 0.2.0
File Size Uploaded
smsflow-0.2.0.tar.gz 7.0 kB Details

Built distribution (wheel)

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

Total release size: 13.2 kB

Release files / smsflow-0.2.0.tar.gz

Download URL smsflow-0.2.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fa3f976c8a0849e6482232dfc667e65950ea6d208f5f0d1a83235a2695986e84
BLAKE2b-256 checksum
How to use checksums
5fc530d2a98b38d83aa84967589a9a02a29cd714810946a6867f45965eaaa8a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 18, 2026.

Transparency log

Release files / smsflow-0.2.0-py3-none-any.whl

Download URL smsflow-0.2.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c43518ff6aa291a8193b14eb2eb3137862a6c899128ed48ac5c9244187d9027c
BLAKE2b-256 checksum
How to use checksums
996fa79a364fd10c5508221f99330c626130e5859cf0c85ce6e76ab70eeedae9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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