Python client library for the SMSFlow HTTPS API.
Project description
SMSFlow Python SDK
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smsflow-0.2.0.tar.gz.
File metadata
- Download URL: smsflow-0.2.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa3f976c8a0849e6482232dfc667e65950ea6d208f5f0d1a83235a2695986e84
|
|
| MD5 |
f8da24f4021571156d0d7912c6a70d2c
|
|
| BLAKE2b-256 |
5fc530d2a98b38d83aa84967589a9a02a29cd714810946a6867f45965eaaa8a9
|
Provenance
The following attestation bundles were made for smsflow-0.2.0.tar.gz:
Publisher:
publish.yml on SMSFlow-ZA/smsflow-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smsflow-0.2.0.tar.gz -
Subject digest:
fa3f976c8a0849e6482232dfc667e65950ea6d208f5f0d1a83235a2695986e84 - Sigstore transparency entry: 1857191839
- Sigstore integration time:
-
Permalink:
SMSFlow-ZA/smsflow-python@2e64770d6edf9c83152e900f1de91a071d6ee753 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SMSFlow-ZA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e64770d6edf9c83152e900f1de91a071d6ee753 -
Trigger Event:
release
-
Statement type:
File details
Details for the file smsflow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: smsflow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43518ff6aa291a8193b14eb2eb3137862a6c899128ed48ac5c9244187d9027c
|
|
| MD5 |
1bc5e16b1a64be4d0c232161abece27b
|
|
| BLAKE2b-256 |
996fa79a364fd10c5508221f99330c626130e5859cf0c85ce6e76ab70eeedae9
|
Provenance
The following attestation bundles were made for smsflow-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on SMSFlow-ZA/smsflow-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smsflow-0.2.0-py3-none-any.whl -
Subject digest:
c43518ff6aa291a8193b14eb2eb3137862a6c899128ed48ac5c9244187d9027c - Sigstore transparency entry: 1857191965
- Sigstore integration time:
-
Permalink:
SMSFlow-ZA/smsflow-python@2e64770d6edf9c83152e900f1de91a071d6ee753 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SMSFlow-ZA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e64770d6edf9c83152e900f1de91a071d6ee753 -
Trigger Event:
release
-
Statement type: