SMS Gateway API

SMS Gateway API with
Direct Carrier Routing

SMSPM routes your messages through direct connections to mobile carriers in 190+ countries. One REST API endpoint. Under 200ms API response. 99.9% uptime SLA.

✓ 99.9% Uptime SLA ✓ < 200ms API Response ✓ 190+ Countries ✓ Direct Carrier Routes ✓ No SDK Required

How an SMS Gateway API Works

An SMS gateway is a service that accepts message requests from your application and delivers them to mobile carrier networks worldwide. Instead of integrating with hundreds of individual carrier APIs (which is not practical), you integrate once with the gateway and it handles routing.

1

Your App Sends

Your backend calls https://api.smspm.com with the message, recipient number, and credentials.

2

SMSPM Routes

SMSPM selects the optimal route to the recipient's carrier based on country, cost, and reliability.

3

Carrier Delivers

The local mobile carrier delivers the SMS to the recipient's handset.

4

DLR Callback

SMSPM sends a delivery report (delivered/failed) to your webhook URL.

API Examples in Every Language

The SMSPM API is a simple GET or POST to one endpoint. No SDK required — works from any language that can make HTTP requests.

JavaScript
const params = new URLSearchParams({
  hash:       process.env.SMSPM_HASH,
  token:      process.env.SMSPM_TOKEN,
  toNumber:   '+37256789045', // E.164
  fromNumber: 'MyApp',        // Sender ID
  text:       'Hello from SMSPM Gateway!'
});
const res = await fetch(`https://api.smspm.com?${params}`);
const { status, messageId } = await res.json();
Python
import os, requests

result = requests.get('https://api.smspm.com', params={
    'hash':       os.environ['SMSPM_HASH'],
    'token':      os.environ['SMSPM_TOKEN'],
    'toNumber':   '+37256789045',
    'fromNumber': 'MyApp',
    'text':       'Hello from SMSPM Gateway!',
}, timeout=10).json()

print(result['status'], result['messageId'])
PHP
$params = http_build_query([
    'hash'       => getenv('SMSPM_HASH'),
    'token'      => getenv('SMSPM_TOKEN'),
    'toNumber'   => '+37256789045',
    'fromNumber' => 'MyApp',
    'text'       => 'Hello from SMSPM Gateway!',
]);
$ch = curl_init('https://api.smspm.com?' . $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch), true);
echo $result['status'];
cURL
curl "https://api.smspm.com?\
  hash=YOUR_HASH&\
  token=YOUR_TOKEN&\
  toNumber=%2B37256789045&\
  fromNumber=MyApp&\
  text=Hello+from+SMSPM+Gateway"

All examples assume credentials are in environment variables. Replace YOUR_HASH and YOUR_TOKEN from your API dashboard.

API Quick Reference

Parameter Required Description
hash Yes Your account hash (from API dashboard)
token Yes Your account token (from API dashboard)
toNumber Yes Recipient phone in E.164 format (+37256789045)
fromNumber Yes Sender ID — alphanumeric (MyApp) or numeric
text Yes Message body — UTF-8 encoded, max 160 chars per GSM-7 part
callbackUrl No Webhook URL to receive delivery reports (DLR)

Example success response

{
  "status":    "success",
  "messageId": "msg_abc123xyz",
  "parts":     1,
  "cost":      0.042,
  "currency":  "EUR"
}

Full API reference → — all parameters, error codes, DLR payload schema, and rate limit documentation.

Gateway Features

🔀

Automatic Routing

SMSPM selects the best carrier route per destination automatically — you don't manage per-country providers.

📊

Delivery Reports

Per-message DLR callbacks to your webhook. Know exactly which messages delivered, failed, or are pending.

⏱️

< 200ms API Response

The API acknowledges your send request in under 200ms. No blocking wait — fire and forget or async.

📋

Message ID Tracking

Every send returns a unique message ID. Query status later or correlate with DLR callbacks for full audit trail.

🌐

E.164 Number Handling

Send to any valid E.164 international number. Use our Phone Formatter tool to normalize numbers before sending.

💳

Per-Use Pricing

No subscription. Credits top up on demand and never expire. Pay only for what you send.

HTTP Status Codes & Error Reference

Understanding API responses helps you handle errors gracefully.

HTTP Code Status Field Meaning & Action
200 success Message accepted and queued for delivery. messageId returned — use for tracking.
200 invalid_phone Phone number format invalid (not E.164). Use Phone Formatter tool to normalize.
200 low_balance Account balance insufficient. Top up credits at smspm.com/billing before retry.
200 destination_blocked This destination country is blocked for your account or temporarily unavailable.
200 invalid_sender Sender ID (fromNumber) not valid for destination. Use numeric sender ID or request alphanumeric support.
400 invalid_params Missing or malformed required parameter (hash, token, toNumber, text). Check parameter names and encoding.
401 auth_failed Hash or token invalid. Verify credentials in your dashboard. Do not commit credentials to version control.
429 rate_limit Too many requests per second from your IP. Backoff exponentially (1s, 2s, 4s...) before retry.
500 server_error SMSPM server error (rare). Retry after 5–10 seconds with exponential backoff.

Best practice: Always check the `status` field in the JSON response, not just the HTTP code. A 200 OK doesn't mean the message sent — it means the API processed your request. `status: "success"` means the message is queued.

Rate Limits & Scalability

SMSPM's API is designed for high-volume throughput. Here are the limits and best practices.

Rate Limits

Per-IP Limit

100 requests/second per unique IP address

Per-Account Limit

1,000 requests/second (contact support for higher)

Burst Allowance

Up to 10,000 requests in a 1-second window (then throttled)

Timeout

30-second request timeout. Use async/webhooks for batch sending.

Best Practices

Async/Non-Blocking

Don't wait for API response in your request handler. Fire off the SMS request and handle it asynchronously.

Batch Sending

For 1,000+ messages, use a queue (Celery, RabbitMQ, SQS) to spread sends over time, not all at once.

Exponential Backoff

On 429 (rate limit), retry with backoff: 1s, 2s, 4s, 8s. Don't hammer the API immediately.

Webhook for DLR

Use delivery report webhooks instead of polling for status. Lower latency, lower cost.

💡 Example: Async Batch Sending (Python)

import asyncio
import aiohttp

async def send_sms_batch(phone_list):
    async with aiohttp.ClientSession() as session:
        tasks = [
            send_sms_async(session, phone)
            for phone in phone_list
        ]
        # Send up to 10 at a time (respects rate limit)
        results = await asyncio.gather(*tasks)
    return results

async def send_sms_async(session, phone):
    params = {'hash': ..., 'toNumber': phone, ...}
    async with session.get(
        'https://api.smspm.com',
        params=params,
        timeout=10
    ) as resp:
        return await resp.json()

Start Using the SMS Gateway API

Free account with test credits. API credentials available immediately after signup.