Skip to content
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Changes

### 1.3.0
- Add multiple Webhooks with prefix-keyword routing: each Inbound SMS is delivered to exactly one enabled Webhook, with an optional catch-all for unmatched messages.
- Add per-Webhook prefix stripping (`none`, keyword only, keyword and separator), sender allowlists, names, and independent signing secrets.
- Keep one enabled Webhook behaving exactly like 1.2.0 (no keyword required); migrate the legacy single `webhook` config, Outbox records, and status file without losing pending deliveries.
- Partition the Outbox into per-Webhook FIFO lanes so a target in backoff cannot delay another target; capacity remains a global drop-oldest limit.
- Extend the remote API: `webhooks` array plus shared `webhook_delivery` policy, server-assigned ids, per-entry secret sentinel, per-Webhook status, id-based test delivery, and a deprecated one-release legacy `webhook` PUT shim.
- Replace the single Webhook Settings block with collapsible Webhook cards (add, delete, test, last delivery), and save the whole list explicitly.

### 1.2.0
- Add a bearer-authenticated remote Settings and control API: `GET /api/health`, `GET /api/status`, `GET/PUT /api/settings`, `POST /api/webhook/test`, and `POST /api/server/restart`, with Revision-based optimistic concurrency and human-readable validation errors.
- Add named API keys with `sms:write` and `settings:write` Scopes, immediate revocation, and phone-key rotation that leaves proxy keys intact.
Expand Down
34 changes: 29 additions & 5 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenSMS

OpenSMS turns a phone or a USB modem into a local SMS gateway: it sends SMS on request and notifies a configured endpoint when SMS arrives.
OpenSMS turns a phone or a USB modem into a local SMS gateway: it sends SMS on request and notifies one or more configured endpoints when SMS arrives.

## Language

Expand All @@ -9,8 +9,12 @@ An SMS received by the device's SIM, as opposed to one sent through the OpenSMS
_Avoid_: incoming message, received text, downlink

**Webhook**:
A notification that OpenSMS delivers over HTTP to announce an event, such as an Inbound SMS.
_Avoid_: callback, post, push
A configured destination and its routing rule. A Webhook has an id, a Webhook target, an optional signing secret, a Route keyword, a prefix stripping mode, and a Sender allowlist.
_Avoid_: callback, endpoint, route

**Webhook delivery**:
One HTTP notification that OpenSMS attempts for a Webhook, with its own delivery id and status.
_Avoid_: callback, post, push, send

**Webhook target**:
The URL that Webhooks are delivered to.
Expand All @@ -20,12 +24,32 @@ _Avoid_: endpoint, destination, webhook URL
One HTTP request made while trying to deliver a Webhook.
_Avoid_: retry, send, try

**Route keyword**:
The case-insensitive prefix that selects a Webhook when two or more are enabled, such as `#sales`. It must be followed by `:` or whitespace.
_Avoid_: tag, prefix, filter

**Catch-all Webhook**:
The single Webhook with an empty Route keyword. It receives Inbound SMS that match no other Route keyword when two or more Webhooks are enabled.
_Avoid_: default webhook, fallback

**Sender allowlist**:
The per-Webhook list of phone numbers or alphanumeric sender IDs whose SMS may be forwarded. An empty list allows every sender.
_Avoid_: whitelist, filter, allowed numbers

**Delivery policy**:
The shared `timeout`, `max_attempts`, `backoff`, and Outbox `capacity` that apply to every Webhook.
_Avoid_: retry settings, webhook config

**Outbox lane**:
The per-Webhook FIFO of pending Webhook deliveries. One lane in backoff does not block another lane.
_Avoid_: queue, partition

**Outbox**:
The persisted queue of Webhooks that are waiting to be delivered.
The persisted queue of Webhook deliveries that are waiting to be delivered.
_Avoid_: queue, buffer, backlog

**Settings**:
The operator-chosen configuration that OpenSMS keeps across restarts: the API port, whether the server starts at launch, and the Webhook configuration.
The operator-chosen configuration that OpenSMS keeps across restarts: the API port, whether the server starts at launch, the Webhooks, and the Delivery policy.
_Avoid_: config, preferences, options

**Revision**:
Expand Down
59 changes: 44 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ An open-source cross-platform solution to host a `SMS` API server locally.

### 🤔 Why would you choose our app? (Features)
👉 Turns your `Android` phone into a SMS API server. <br>
👉 Forward received SMS to your own HTTP endpoint (webhook). <br>
👉 Forward received SMS to one or more of your own HTTP endpoints (webhooks), with prefix-keyword routing. <br>
👉 Also available on `Desktop` platforms via [EC200U](https://www.quectel.com/product/lte-ec200u-series/) or similar USB development boards. <br>
👉 Open-source, No advertisements and privacy focused.

Expand Down Expand Up @@ -176,18 +176,33 @@ curl -sS -X PUT 'http://192.168.1.50:9292/api/settings' \
"revision": 7,
"port": 9292,
"boot": true,
"webhook": {
"enabled": true,
"url": "https://proxy.example.lan/hooks/opensms",
"webhook_delivery": {
"timeout": 10,
"max_attempts": 3,
"backoff": [5, 30],
"capacity": 100
}
},
"webhooks": [
{
"name": "Proxy",
"enabled": true,
"url": "https://proxy.example.lan/hooks/opensms",
"keyword": "#proxy",
"strip_prefix": "keyword_and_separator",
"allowed_senders": ["+14155552671"]
}
]
}'
```

Omit `webhook.secret` to keep the stored secret, send `""` to clear it, or send a new string to replace it. Webhook and retry changes take effect immediately. Changing `boot` is read at the next app launch; it does not start or stop the current service. A port change is two-step: the response sets `restart_required`, then call:
The `webhooks` array is a full replacement. Entries with an `id` update that
Webhook, entries without one are created with a server-assigned id, and omitted
entries are deleted. Omit `webhooks[].secret` to keep the stored secret for that
id, send `""` to clear it, or send a new string to replace it. The legacy
single-`webhook` body still works for one release (deprecated). Webhook and
retry changes take effect immediately. Changing `boot` is read at the next app
launch; it does not start or stop the current service. A port change is
two-step: the response sets `restart_required`, then call:

```bash
curl -sS -X POST 'http://192.168.1.50:9292/api/server/restart' \
Expand All @@ -197,32 +212,46 @@ curl -sS -X POST 'http://192.168.1.50:9292/api/server/restart' \
Restart requires the background service loop; the standalone CLI runs the
server directly and refuses Restart with `409`.

`GET /api/status` reports the bound and configured port, network addresses, Outbox depth, the last Delivery attempt, and warnings (for example when forwarding is disabled or the Outbox is near capacity). `POST /api/webhook/test` tests a Webhook target without saving it. The full contract, error codes, and persisted schema are in [docs/remote-api.md](./docs/remote-api.md).
`GET /api/status` reports the bound and configured port, network addresses, per-Webhook last Delivery and pending count, global Outbox depth, and warnings (for example when forwarding is disabled, an enabled target is invalid, routing has no catch-all, or the Outbox is near capacity). `POST /api/webhook/test` tests a saved Webhook by `id`, or a target without saving it. The full contract, error codes, and persisted schema are in [docs/remote-api.md](./docs/remote-api.md).

## 📥 Receiving SMS (Android)

OpenSMS can forward every SMS received by the phone to your own HTTP endpoint as a webhook. Receiving works independently of the API server: it runs in the same background service, so the API can be stopped while webhooks keep flowing.
OpenSMS can forward every SMS received by the phone to one or more of your own HTTP endpoints as Webhooks. Receiving works independently of the API server: it runs in the same background service, so the API can be stopped while Webhooks keep flowing.

### Configure it

1. Open `Settings` and find the **Webhook (Inbound SMS)** section.
2. Enter the **Webhook target** (`http://` or `https://`) without `username:password@` userinfo.
1. Open `Settings` and find the **Webhooks (Inbound SMS)** section.
2. Tap **Add Webhook** and enter the **Webhook target** (`http://` or `https://`) without `username:password@` userinfo.
3. Optionally set a **Signing Secret** to sign every request.
4. Enable the switch and tap **Save**.
5. Tap **Send Test Webhook** to check the endpoint. This sends `event: "webhook.test"`.
5. Tap the send icon on the card to test that endpoint. This sends `event: "webhook.test"`.

Settings take effect immediately; no restart is needed. The last delivery result is shown under the webhook settings and in the `Logs` screen.
With one enabled Webhook, every Inbound SMS is delivered to it exactly as in
1.2.0. With two or more, each SMS is delivered to **exactly one** Webhook:

- The SMS may start with a **Route keyword**, for example `#sales: hello`.
Matching is case-insensitive and requires `:` or whitespace after the keyword.
- Otherwise the single **catch-all** Webhook (an empty keyword) receives it. If
no catch-all exists, the SMS is dropped and logged.
- Each Webhook chooses whether to remove the keyword only or the keyword and
separator before forwarding.
- Each Webhook can have an **Allowed senders** list. Empty means all; when set,
only those numbers or alphanumeric sender IDs are forwarded to that Webhook.

Settings take effect immediately; no restart is needed. Each card shows its own
last delivery result, and the `Logs` screen records every attempt.

### Request format

Every Inbound SMS produces one `POST` with a JSON body:
Every Inbound SMS produces one `POST` per delivered Webhook with a JSON body:

```http
POST /your-hook HTTP/1.1
Content-Type: application/json
User-Agent: OpenSMS/1.2.0
User-Agent: OpenSMS/1.3.0
X-OpenSMS-Event: sms.received
X-OpenSMS-Delivery: 6f1c2f5e-0d7a-4c55-9f0e-2b1c8b7f0a11
X-OpenSMS-Webhook-Id: wh_5b581975
X-OpenSMS-Signature: sha256=...
```

Expand All @@ -244,7 +273,7 @@ X-OpenSMS-Signature: sha256=...
- A multipart SMS is delivered as **one** webhook with the parts joined in `text` and counted in `parts`.
- `sim` is included only when the subscription can be determined.

A `2xx` response means delivered. Anything else (or a timeout after 10 seconds) is retried twice (after 5s and 30s); after three failed attempts the delivery is logged as failed. Redirects are not followed and count as failures. Pending webhooks are kept on disk and survive restarts. At most 100 are queued; when full, the oldest is dropped. Delivery is at-least-once: a crash immediately after persisting a delivery can produce a duplicate, but never a silent loss.
A `2xx` response means delivered. Anything else (or a timeout after 10 seconds) is retried twice (after 5s and 30s); after three failed attempts the delivery is logged as failed. Redirects are not followed and count as failures. Pending deliveries are kept on disk and survive restarts. Each Webhook has its own FIFO lane, so one target in backoff does not delay the others; the shared Outbox holds at most 100 deliveries by default, and when full the oldest is dropped. Delivery is at-least-once: a crash immediately after persisting a delivery can produce a duplicate, but never a silent loss.

### Verify the signature

Expand Down
Loading
Loading