Skip to main content

SMS & SMPP

Msghub supports SMS messaging via two protocols: HTTP API (for standard messaging) and SMPP (for high-volume, time-sensitive messaging). Choose the right protocol based on your use case.

SMS via HTTP API

HTTP API is the standard way to send SMS. It's simple, reliable, and suitable for most use cases.

Sending an SMS

curl -X POST \
https://your-msghub.com/api/v1/messages/send \
-H "X-API-Key: mk_live_..." \
-H "Content-Type: application/json" \
-d '{
"channel": "sms",
"to": "+919876543210",
"body": "Hi Rahul, your order ORD-4821 has shipped!"
}'

Response

{
"messageId": "msg_abc123",
"channel": "sms",
"to": "+919876543210",
"status": "queued",
"createdAt": "2024-04-08T10:30:00Z"
}

Message Parameters

ParameterTypeRequiredDescription
channelstringYesMust be "sms"
tostringYesRecipient phone number (E.164 format, e.g., +919876543210)
bodystringYesMessage text (up to 160 characters for single SMS, 1000+ with concatenation)
senderIdstringNoSender ID (if supported by your SMS gateway)
scheduleAtISO 8601NoSchedule message for future delivery
tagsarrayNoTags for tracking (e.g., ["order_confirmation", "vip"])

Character Limits

  • Single SMS: 160 characters (GSM-7 encoding) or 70 characters (Unicode)
  • Concatenated SMS: Multiple SMS concatenated automatically. Each segment is 153 characters (GSM-7) or 67 characters (Unicode)

Example: A 300-character message will be sent as 2 SMS (153 + 147 characters).

Delivery Status

After sending, you'll receive webhook events for delivery status:

{
"event": "message.delivered",
"messageId": "msg_abc123",
"channel": "sms",
"status": "delivered",
"deliveredAt": "2024-04-08T10:30:05Z",
"dlr": {
"operator": "Airtel",
"code": "DELIVRD"
}
}

Possible statuses:

  • delivered — Message successfully delivered to recipient
  • failed — Message delivery failed
  • bounced — Invalid phone number or carrier rejection
  • read — Message read (if supported by carrier)

SMS via SMPP

SMPP (Short Message Peer-to-Peer) is a telecom-grade protocol used by carriers internally. Use SMPP for high-volume, time-sensitive messaging.

Why Use SMPP?

MetricHTTP APISMPP
Throughput30-50 messages/second1,000+ messages/second
Latency5-30 secondsUnder 3 seconds
Best forStandard campaignsOTPs, flash sales, alerts
SetupSimpleRequires SMPP credentials

SMPP Setup

  1. Go to Settings → Channels → SMS
  2. Select SMPP
  3. Enter your SMPP gateway credentials:
    • Host — SMPP server hostname or IP
    • Port — SMPP port (usually 2775)
    • Username — SMPP username
    • Password — SMPP password
    • System ID — Optional system identifier
  4. Click Test Connection
  5. Once verified, click Save

Sending via SMPP

The API is identical to HTTP API. Msghub automatically routes to SMPP if configured:

curl -X POST \
https://your-msghub.com/api/v1/messages/send \
-H "X-API-Key: mk_live_..." \
-H "Content-Type: application/json" \
-d '{
"channel": "sms",
"to": "+919876543210",
"body": "Your OTP is 482910. Expires in 5 minutes."
}'

Msghub will automatically use SMPP if:

  1. SMPP is configured in Settings
  2. The message is marked as high-priority (OTP, alert)
  3. Or you explicitly request SMPP routing

SMPP Delivery Reports (DLR)

SMPP provides real-time delivery reports per contact, per operator, per second:

{
"event": "message.delivered",
"messageId": "msg_abc123",
"channel": "sms",
"status": "delivered",
"deliveredAt": "2024-04-08T10:30:02Z",
"dlr": {
"operator": "Jio",
"code": "DELIVRD",
"timestamp": "2024-04-08T10:30:02Z"
}
}

SMPP Throughput Example

Sending 50,000 SMS via SMPP:

# Using n8n or your automation tool
for i in {1..50000}; do
curl -X POST https://your-msghub.com/api/v1/messages/send \
-H "X-API-Key: mk_live_..." \
-d "{\"channel\": \"sms\", \"to\": \"+91${phone[$i]}\", \"body\": \"Flash sale! 50% off. Ends tonight.\"}"
done

Result: 50,000 messages delivered in ~50 seconds (1,000 TPS).

Bulk SMS Campaigns

Send SMS to multiple contacts at once using the Campaigns API.

Create a Campaign

curl -X POST \
https://your-msghub.com/api/v1/campaigns \
-H "X-API-Key: mk_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Flash Sale",
"channel": "sms",
"message": "Flash sale! 50% off everything. Shop now: https://example.com/sale",
"recipients": {
"segment": "vip_customers"
},
"sendAt": "2024-04-08T18:00:00Z"
}'

Response

{
"campaignId": "camp_xyz789",
"name": "Flash Sale",
"channel": "sms",
"status": "scheduled",
"recipientCount": 50000,
"scheduledAt": "2024-04-08T18:00:00Z"
}

Monitor Campaign

curl -X GET \
https://your-msghub.com/api/v1/campaigns/camp_xyz789 \
-H "X-API-Key: mk_live_..."

Response

{
"campaignId": "camp_xyz789",
"name": "Flash Sale",
"status": "sent",
"totalRecipients": 50000,
"delivered": 49500,
"failed": 500,
"deliveryRate": 99.0,
"sentAt": "2024-04-08T18:00:05Z"
}

DLT Compliance

DLT (Distributed Ledger Technology) compliance is mandatory in India (TRAI) and other regions. Msghub handles DLT compliance automatically.

What is DLT?

DLT is a registry of approved SMS templates and sender IDs. Before sending SMS, you must:

  1. Register your sender ID
  2. Register your message templates
  3. Get approval from the telecom authority

DLT Setup in Msghub

  1. Go to Settings → Compliance → DLT
  2. Enter your DLT credentials:
    • Entity ID — Your registered entity ID
    • Sender ID — Your registered sender ID
  3. Add your approved templates:
    • Template ID — DLT template ID
    • Template Text — The approved message text
  4. Click Save

Sending DLT-Compliant SMS

When you send an SMS, Msghub automatically:

  1. Matches your message to an approved template
  2. Includes the template ID in the SMPP request
  3. Validates the sender ID
curl -X POST \
https://your-msghub.com/api/v1/messages/send \
-H "X-API-Key: mk_live_..." \
-d '{
"channel": "sms",
"to": "+919876543210",
"templateId": "1007161234567890123",
"parameters": {
"orderId": "ORD-4821"
}
}'

DLT Template Variables

Templates can include variables (placeholders) that are filled at send time:

Template (registered with DLT):

Hi {name}, your order {orderId} has shipped. Track it here: {trackingUrl}

Send request:

{
"channel": "sms",
"to": "+919876543210",
"templateId": "1007161234567890123",
"parameters": {
"name": "Rahul",
"orderId": "ORD-4821",
"trackingUrl": "https://track.example.com/ORD-4821"
}
}

DND (Do Not Disturb) Handling

DND compliance is mandatory. Msghub automatically:

  1. Checks if a number is on the DND list
  2. Blocks messages to DND numbers
  3. Logs DND violations for compliance

DND Status

When you send to a DND number, you'll receive:

{
"event": "message.failed",
"messageId": "msg_abc123",
"status": "failed",
"reason": "dnd_violation",
"message": "Number is on DND list"
}

Opt-In/Opt-Out Management

Msghub tracks customer consent:

# Mark a contact as opted-in
curl -X POST \
https://your-msghub.com/api/v1/contacts/contact_123/consent \
-H "X-API-Key: mk_live_..." \
-d '{
"channel": "sms",
"status": "opted_in",
"timestamp": "2024-04-08T10:00:00Z"
}'
# Mark a contact as opted-out
curl -X POST \
https://your-msghub.com/api/v1/contacts/contact_123/consent \
-H "X-API-Key: mk_live_..." \
-d '{
"channel": "sms",
"status": "opted_out",
"timestamp": "2024-04-08T10:00:00Z"
}'

Bring Your Own SMS Gateway

Connect your existing SMS gateway (MSG91, Kaleyra, Gupshup, etc.) to Msghub.

Supported Gateways

  • MSG91 — HTTP API
  • Kaleyra — SMPP
  • Gupshup — HTTP API
  • Twilio — HTTP API
  • Any SMPP provider — Raw SMPP protocol

Setup

  1. Go to Settings → Channels → SMS
  2. Select Custom Gateway
  3. Choose your gateway type (HTTP or SMPP)
  4. Enter your credentials:
    • API Endpoint (for HTTP)
    • SMPP Host/Port/Username/Password (for SMPP)
  5. Click Test Connection
  6. Click Save

Cost

You pay your SMS gateway directly. Msghub doesn't mark up the cost—you only pay for the platform subscription and the actual messages sent.

Best Practices

Message Content

  • Keep it short — Aim for under 160 characters to avoid concatenation
  • Include a call-to-action — "Click here", "Reply YES", "Call 1800-XXXX"
  • Personalize — Use customer name and order details
  • Avoid spam words — Don't use ALL CAPS, excessive punctuation, or spam triggers

Timing

  • Send during business hours — 9 AM - 9 PM for best engagement
  • Avoid weekends — Unless it's a time-sensitive alert
  • Consider time zones — Schedule for recipient's local time

Compliance

  • Always get consent — Before sending promotional SMS
  • Include opt-out — "Reply STOP to unsubscribe"
  • Respect DND — Never send to DND numbers
  • Keep records — Log all consent and opt-outs

Troubleshooting

Messages not delivering

  1. Check phone number format — Must be E.164 format (+919876543210)
  2. Check DND status — Is the number on the DND list?
  3. Check DLT compliance — Is the template approved?
  4. Check gateway status — Is your SMS gateway connected?

High failure rate

  1. Check message content — Does it match an approved DLT template?
  2. Check sender ID — Is it registered and approved?
  3. Check gateway logs — Contact your SMS gateway for error details

Slow delivery

  1. Use SMPP — HTTP API is slower than SMPP
  2. Check gateway load — Is your gateway overloaded?
  3. Check network — Is there a connectivity issue?

See Also