Skip to content

About

Turn a spare Android phone into a self-hosted SMS gateway: send and receive SMS over a simple HTTP API, with signed webhooks, delivery reports and dual-SIM support. No cloud, no subscription.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SMS Gateway icon

SMS Gateway for Android

Turn a spare Android phone into an SMS gateway. Send and receive text messages from your own apps over a simple HTTP API, get webhooks for incoming SMS and delivery reports, and choose which SIM sends each message. Everything runs on the phone: no cloud service, no subscription.

CI Latest release Android 9+ License

Features

  • 📤 Send SMS with one HTTP call. Long messages are split and joined automatically
  • 📥 Receive SMS as webhooks, signed with HMAC-SHA256 and retried for up to 3 days while your server is down
  • 📡 Optional live event stream (Server-Sent Events) with replay after a dropped connection, for client apps
  • 💬 Companion app for another phone: the gateway's texts as conversations, with contact names and replies on the right SIM. See Companion app
  • 📶 Dual-SIM and multi-SIM: pick the SIM per message, and see which SIM received each one
  • ✅ Delivery tracking: queued → sent → delivered (or failed, with the reason)
  • 🔑 Named API keys: one per app, each with only the permissions it needs, shown once, stored hashed, and recorded on every message
  • 🛡️ Local network only by default: connections over mobile data or from public addresses are refused before the key is even checked
  • 🔒 Secrets encrypted with the Android Keystore. Extra webhook headers (e.g. Authorization) are supported
  • 💾 Local database with a retention policy and automatic compaction
  • 🔐 Optional HTTPS, with a self-signed certificate, your own PEM files, or a PKCS#12 file
  • 🌍 Optional public access through the built-in Cloudflare Tunnel: a fixed HTTPS address that works on mobile data, with no port forwarding
  • 🔋 Runs as a foreground service, survives reboots, works on Android 9 and newer
  • ❓ Help built in: the ? on every screen opens the matching page of the user guide

How it works

Your app sends SMS through the phone's HTTP API. The phone sends and receives SMS on its SIMs, forwards events to your server as webhooks, and streams them live to the companion app.

Your app talks to the phone over HTTP, and the phone does the texting on its own SIM cards. Incoming SMS and status changes go back to you as webhooks, or live over the event stream. Sending a message looks like this:

sequenceDiagram
    participant A as Your app
    participant G as SMS Gateway
    participant R as Recipient
    A->>G: POST /api/v1/messages {to, body, simSlot}
    G-->>A: 202 Accepted {id, status: queued}
    G->>R: SMS via chosen SIM
    G-->>A: webhook sms:sent
    R-->>G: delivery report
    G-->>A: webhook sms:delivered
Loading

Download

Every release has two APKs:

File Install it on What it is
sms-gateway-<version>.apk The phone with the SIM cards SMS Gateway, the gateway itself
gateway-sms-companion-<version>.apk Another phone (optional) Gateway SMS, a messaging app for the gateway's texts. See Companion app

To check a download, compare the output of sha256sum sms-gateway-*.apk (macOS: shasum -a 256 sms-gateway-*.apk) with the release's SHA256SUMS.txt. Updates install over the previous version and keep your settings and data.

Quick start

  1. Install sms-gateway-<version>.apk on the phone. If Play Protect complains, see Troubleshooting.
  2. Open the app, Grant permissions, tap Allow running in background, then Start server.
  3. In Settings → API keys, tap New key and copy the key.
  4. Send a message:
curl -X POST http://PHONE_IP:8080/api/v1/messages \
  -H "X-API-Key: sgw_your_key" -H "Content-Type: application/json" \
  -d '{"to": "+15551234567", "body": "Hello!", "simSlot": 0}'

Full walkthrough: Getting started.

Documentation

The user guide covers everything. The app's ? buttons open it at the right page.

Good to know

  • Distributed as an APK, not on the Play Store. Google limits SMS permissions on Play to default SMS apps.

  • The phone must be reachable from your systems: the same network, a VPN such as Tailscale, or the built-in Cloudflare Tunnel for a public HTTPS URL. By default it only accepts connections from the local network; see Who can connect.

    Three ways to reach the gateway: the same Wi-Fi or LAN, a VPN such as Tailscale or WireGuard, or the Cloudflare Tunnel.
  • A spare phone on a charger works best, with a SIM plan that includes SMS and the app allowed to run in the background.

  • The API is plain HTTP on your network unless you turn on HTTPS. Read Security before exposing it.

  • SMS costs whatever your carrier charges. Check your plan before sending in bulk.

Roadmap

  • Cloud relay: the phone connects out to a server over WebSocket/SSE, so it doesn't need to be reachable directly

Contributing

Pull requests are welcome. See CONTRIBUTING.md for the setup, code layout and release process.

License

BSD 3-Clause © Joseph Baking

About

Turn a spare Android phone into a self-hosted SMS gateway: send and receive SMS over a simple HTTP API, with signed webhooks, delivery reports and dual-SIM support. No cloud, no subscription.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages