Skip to main content

multi-sms

Multi-provider SMS OTP sending with automatic fallback.

Configure a priority-ordered list of SMS providers. The library tries each one in order — on any failure it automatically moves to the next. First success wins.

pip install multi-sms

Supported providers

Method Free / Cost DLT India Notes
FAST2SMS Rs50 free credits ✅ Built-in Best for India
MSG91 No free tier ✅ Built-in Reliable India SMS
TWILIO $15 trial credit ⚠️ Manual Global, works everywhere
2FACTOR No free tier ✅ Built-in India only

DLT = TRAI registration required for Indian SMS delivery.


Quick start

Option 1 — Environment variable

Set SMS_SEND_METHODS to a JSON array:

export SMS_SEND_METHODS='[
  {"method":"FAST2SMS", "api_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},
  {"method":"MSG91",    "api_key":"xxxxxxxxxx", "sender_id":"MYAPP", "template_id":"1234567890"},
  {"method":"TWILIO",   "account_sid":"ACxxxxxxxx", "auth_token":"xxxxxxxx", "from_number":"+12345678901"},
  {"method":"2FACTOR",  "api_key":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}
]'
from multi_sms import send_sms_otp

ok = send_sms_otp("+919876543210", "482910")

Option 2 — Pass methods directly

from multi_sms import send_sms_otp

methods = [
    {"method": "FAST2SMS", "api_key": "xxx"},
    {"method": "TWILIO",   "account_sid": "ACxxx", "auth_token": "xxx", "from_number": "+12345678901"},
]
ok = send_sms_otp("+919876543210", "482910", methods=methods)

Test mode (no real sends)

send_sms_otp("+919876543210", "482910", test_mode=True)

API

send_sms_otp(to, otp, *, methods=None, test_mode=False) -> bool

Parameter Type Description
to str Recipient phone in E.164 format, e.g. "+919876543210"
otp str The OTP string to deliver, e.g. "482910"
methods list | None Override the env-var provider list for this call
test_mode bool If True, log the OTP and return True without sending

Returns True on first successful send, False only if every provider fails.

load_methods(env_var="SMS_SEND_METHODS") -> list

Re-read and parse the method list from an environment variable.


Provider setup

FAST2SMS (best free option for India)
  1. Sign up at fast2sms.com
  2. Dashboard → Dev API → copy your API key
{"method":"FAST2SMS", "api_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}

Phone numbers must be 10-digit Indian numbers. Pass with or without +91 — the library strips the prefix automatically.

MSG91 (reliable India SMS)
  1. Sign up at msg91.com → get API key
  2. Create a DLT-approved template containing {otp} as the variable
  3. Note your 6-character sender ID and the template ID
{"method":"MSG91", "api_key":"xxxxxxxxxx", "sender_id":"MYAPP", "template_id":"1234567890"}
TWILIO (global SMS)
  1. Sign up at twilio.com → get Account SID and Auth Token
  2. Buy a phone number to use as from_number
  3. For India: complete DLT registration separately via Twilio's India SMS guide
{"method":"TWILIO", "account_sid":"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "auth_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "from_number":"+12345678901"}
2FACTOR (India SMS)
  1. Sign up at 2factor.in → API Keys → copy your key
{"method":"2FACTOR", "api_key":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}

Phone numbers must be 10-digit Indian numbers. Pass with or without +91.


License

MIT

Metadata

Release files for multi-sms 1.0.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 multi-sms 1.0.0
File Size Uploaded Provenance Actions
multi_sms-1.0.0.tar.gz 5.7 kB Without provenance Details for multi_sms-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multi-sms 1.0.0
File Interpreter ABI Platform Actions
multi_sms-1.0.0-py3-none-any.whl Python 3 none any Details for multi_sms-1.0.0-py3-none-any.whl

Total release size: 12.2 kB

Release files / multi_sms-1.0.0.tar.gz

Download URL multi_sms-1.0.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
379cf3b4ed1f7ccdff806cce7a7078c0e1d551175a36d2c67410565d78c7b54c
BLAKE2b-256 checksum
How to use checksums
bf2812226a152c8224fa1a5bcb9b19457d861834721a5be4f3df1b83d1404ef4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release files / multi_sms-1.0.0-py3-none-any.whl

Download URL multi_sms-1.0.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1309600d1bdc19bc2a403f6218386f8421202fef66c8e80d13afd228888c0560
BLAKE2b-256 checksum
How to use checksums
77baba680c9e8b5d3502fdb88d8bbd01233246f2b0251abaab765aad2f76859c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Security for multi-sms 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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