Python SDK

The official Python client sends an SMS with one line of Python. No dependencies, fully typed, for Python 3.10 or later.

Install

pip install curl-sms

Send an SMS

from curl_sms import CurlSMS

client = CurlSMS("cs_test_example")  # or set CURLSMS_API_KEY

message = client.send("+4915123456789", "Hello from Python")
print(message["id"], message["status"])  # 01JDQ8M3V6R1T5ZK2X9N4C7B0A queued

Test keys (cs_test_…) run all checks, send nothing and cost nothing. Their status changes are simulated (sent, then delivered). Switch to a live key (cs_live_…) when you are ready; your code stays the same.

Up to 100 receivers at once and scheduled sending work the same way:

client.send(receivers=["+4915123456789"], body="Server backup finished.")
client.send("+4915123456789", "Good morning", send_at="2026-12-01T08:00:00+01:00")

Configuration

Keep the key out of your code: without an argument the client reads it from the environment variable CURLSMS_API_KEY.

export CURLSMS_API_KEY=cs_test_…
client = CurlSMS(
    timeout=30,  # seconds per attempt
    max_retries=2,  # retries on network errors, 429 and 5xx
    language="en",  # language of error messages: "en" or "de"
)

If no key is passed and none is set, the constructor raises ValueError.

Error handling

Every failure raises CurlSMSError with the HTTP status and the error code:

from curl_sms import CurlSMS, CurlSMSError

try:
    client.send("12345", "Hello")
except CurlSMSError as err:
    print(err.status, err.code, err.message)  # 422 invalid_receiver Invalid receiver number.

Network errors, timeouts, 429 and 5xx are retried automatically. Every send carries an idempotency key, so a retry never sends an SMS twice.

More

The client also covers estimate, get, cancel, list and account, and verifies webhooks with parse_webhook. All methods with examples are in the README on GitHub; every field is in the API reference.