Skip to main content

Prerequisites

Before you begin, make sure you have:

  • A SpringEdge account with an API key
  • Python 3.6 or higher installed
  • The requests library: pip install requests
  • A DLT-registered sender ID and approved template (for India)

3 Lines of Code

Send your first SMS with just 3 lines of Python

Webhook Support

Receive delivery reports with Flask or Django

pip Install

Uses the popular requests library — nothing proprietary

import requests

API_KEY = "YOUR_API_KEY"
URL = "https://api.springedge.com/v1/sms/send"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_KEY}"
}

payload = {
    "to": "+919876543210",
    "sender_id": "SPREDG",
    "message": "Your OTP is 482910",
    "type": "transactional"
}

response = requests.post(
    URL, json=payload, headers=headers
)

print(f"Status: {response.status_code}")
print(f"Response: {response.json()}")

# Response:
# {
#   "status": "success",
#   "message_id": "msg_a1b2c3d4",
#   "credits_used": 1
# }

SEND SMS

Basic Python Example

This example uses the requests library to send an SMS through the SpringEdge API. Install it with pip install requests if you haven't already.

The API accepts a JSON payload with the recipient number, sender ID, message body, and message type. It returns a JSON response with the message ID and credit usage.

Quick Start:

  1. Install requests: pip install requests
  2. Replace YOUR_API_KEY with your API key
  3. Update the phone number and message
  4. Run: python send_sms.py

WEBHOOKS

Receive Delivery Reports with Flask

Set up a webhook endpoint to receive real-time delivery status updates. SpringEdge sends an HTTP POST to your configured URL whenever a message status changes — delivered, failed, or rejected.

Configure your webhook URL in the SpringEdge dashboard under Account Settings. The payload includes the message ID, status, timestamp, and recipient number.

from flask import Flask, request

app = Flask(__name__)

@app.route("/webhook/dlr", methods=["POST"])
def delivery_report():
    data = request.get_json()

    message_id = data.get("message_id")
    status = data.get("status")
    recipient = data.get("to")

    print(f"Message {message_id} to "
          f"{recipient}: {status}")

    # Update your database here
    # db.update_sms_status(
    #     message_id, status
    # )

    return {"ok": True}, 200

if __name__ == "__main__":
    app.run(port=5000)

What You Can Build

OTP Verification

Add phone number verification to Django or Flask sign-up flows with one-time passwords delivered in under 3 seconds.

Scheduled Campaigns

Build bulk SMS campaign scripts with Python's scheduling libraries. Send promotions to thousands of recipients at the optimal time.

Automated Alerts

Trigger SMS notifications from Python scripts monitoring servers, databases, or business metrics. Get alerted before issues escalate.

Data Pipeline Alerts

Send SMS notifications from ETL pipelines, Airflow DAGs, or Celery tasks when jobs complete, fail, or need attention.