sendword 0.8.7

Simple HTTP webhook to command runner sidecar. Frontend for managing hooks, JSON state for config portability, SQLite for execution history and logs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# sendword

HTTP webhook receiver that runs commands. Define hooks in TOML, trigger them with HTTP requests, see results in a web dashboard.

[Documentation]https://sendword.online | [Install]https://sendword.online/docs/installation

## What it does

sendword sits next to your application as a sidecar. It listens for incoming webhooks and executes shell commands, scripts, or HTTP calls in response. Configuration lives in a single TOML file. Execution history and logs are stored in SQLite.

```
GitHub/CI/Monitoring ──HTTP POST──▶ sendword ──▶ shell command
                                                  script
                                                  JavaScript
                                                  Python
                                                  HTTP request
```

## Features

- **Webhook authentication** --- Bearer tokens, HMAC-SHA256 signature verification, or open access. Constant-time comparison prevents timing attacks.
- **Payload validation** --- JSON schema per hook. Malformed payloads are rejected before your command runs.
- **Trigger rules** --- Filter by payload fields, restrict to time windows, enforce cooldowns, and apply rate limits before execution.
- **Script runtime executors** --- Shell commands with payload interpolation, executable scripts, JavaScript, Python, or HTTP forwarding. Per-hook timeouts and working directories.
- **Retries with backoff** --- None, linear, or exponential. Configurable per hook or globally, with max delay caps.
- **Execution barriers** --- Mutex or queue-based concurrency control. Approval workflows gate hooks behind human review with optional timeouts.
- **Secret masking** --- Redact env var values and regex patterns from dashboard output and log files.
- **Backup and restore** --- Snapshot database and config to S3-compatible storage on a cron schedule. Restore with one command. Retention policies handle cleanup.
- **Web dashboard** --- View hooks, executions, trigger attempts, and stream logs in real time via SSE.
- **Config portability** --- Export/import configuration as JSON. Environment variable overrides for every setting.

## Quick start

### Install

Install from crates.io if you already have a Rust toolchain:

```sh
cargo install sendword
```

Prebuilt release artifacts are also published for Linux x86_64 and Windows
x86_64. The installers put `sendword` in `$HOME/.cargo/bin` by default.

Linux x86_64:

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://releases.sendword.online/latest/sendword-installer.sh | sh
```

Windows PowerShell:

```powershell
powershell -ExecutionPolicy Bypass -c "irm https://releases.sendword.online/latest/sendword-installer.ps1 | iex"
```

The installers default to `latest`. To pin a release, set `SENDWORD_VERSION`
to a version tag:

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://releases.sendword.online/latest/sendword-installer.sh | SENDWORD_VERSION=v0.8.7 sh
```

Use Docker when you want sendword and its script runtimes packaged together:

```sh
mkdir -p data
docker run --rm -p 8080:8080 -v "$PWD/data:/data" ghcr.io/wavefunk/sendword:latest
```

Manual archives and checksums are available under
`https://releases.sendword.online/latest/`. Replace `latest` with a version tag
such as `v0.8.7` to download a specific release.

### Build from source

Source builds require Rust nightly. The project pins `nightly-2026-01-05` via
`rust-toolchain.toml`.

With [Nix](https://nixos.org/) and [direnv](https://direnv.net/), dependencies are managed automatically:

```sh
direnv allow
```

```sh
# Build
cargo build --release

# Run (creates data/ directory and SQLite database on first start)
./target/release/sendword serve
```

Or during development:

```sh
cargo run
```

sendword starts on `127.0.0.1:8080` by default. Open it in a browser to access the dashboard.

### Create a user

The dashboard requires authentication. Create your first user:

```sh
sendword user create --email you@example.com
```

You'll be prompted for a password.

## Configuration

sendword loads config from `sendword.toml`, then `sendword.json`, then environment variables (in that priority order). Environment variables use the `SENDWORD_<SECTION>__<KEY>` format.

### Minimal example

```toml
[server]
bind = "127.0.0.1"
port = 8080

[[hooks]]
name = "Deploy App"
slug = "deploy-app"

[hooks.executor]
type = "shell"
command = "cd /opt/app && git pull && make deploy"
```

This creates a hook at `POST /hook/deploy-app` that runs the deploy command.

### Full example

```toml
[server]
bind = "127.0.0.1"
port = 9090

[database]
path = "data/sendword.db"

[logs]
dir = "data/logs"

[auth]
session_lifetime = "24h"
secure_cookie = false

[auth.smtp]
host = "smtp.example.com"
port = 587
username = "sendword@example.com"
password = "your-smtp-password"
from = "sendword@example.com"
starttls = true

[scripts]
dir = "data/scripts"

[defaults]
timeout = "30s"

[defaults.rate_limit]
max_per_minute = 60

[defaults.retries]
count = 0
backoff = "exponential"
initial_delay = "1s"
max_delay = "60s"

[masking]
env_vars = ["DATABASE_URL", "API_KEY", "AWS_SECRET_ACCESS_KEY"]
patterns = ["Bearer [A-Za-z0-9._~+/=-]+", "ghp_[A-Za-z0-9]{36}"]

[[hooks]]
name = "Deploy App"
slug = "deploy-app"
description = "Triggers app deployment"
enabled = true
cwd = "/opt/app"
timeout = "120s"

[hooks.auth]
mode = "bearer"
token = "secret-deploy-token"

[hooks.executor]
type = "shell"
command = "echo 'deploying $APP_ENV'"

[hooks.env]
APP_ENV = "production"

[hooks.retries]
count = 2
backoff = "exponential"
initial_delay = "2s"
max_delay = "30s"

[hooks.rate_limit]
max_per_minute = 5

[hooks.trigger_rules]
cooldown = "30s"
payload_filters = [{ field = "action", operator = "equals", value = "deploy" }]

[hooks.trigger_rules.rate_limit]
max_requests = 10
window = "1h"

[[hooks.trigger_rules.time_windows]]
days = ["Mon", "Tue", "Wed", "Thu", "Fri"]
start_time = "09:00"
end_time = "17:00"

[hooks.concurrency]
mode = "mutex"

[hooks.approval]
required = true
timeout = "30m"

[hooks.notification]
url = "https://hooks.slack.com/services/T00/B00/xxx"
on = ["failure", "timeout"]
body = '{"text": "Hook {{hook_name}} {{outcome}}"}'

[backup]
endpoint = "https://s3.amazonaws.com"
bucket = "sendword-backups"
access_key = "AKIA..."
secret_key = "..."
region = "us-east-1"
prefix = "prod/"
schedule = "0 0 3 * * *"

[backup.retention]
max_count = 30
max_age = "90d"
```

### Executor types

**Shell** --- runs a command in a shell process:

```toml
[hooks.executor]
type = "shell"
command = "deploy.sh --env production"
```

**Script** --- runs an executable script directly. The file needs executable permissions and a shebang:

```toml
[hooks.executor]
type = "script"
path = "data/scripts/deploy.sh"
```

**JavaScript** --- runs a script with `node`:

```toml
[hooks.executor]
type = "javascript"
path = "data/scripts/deploy.js"
```

**Python** --- runs a script with `python3`, falling back to `python`:

```toml
[hooks.executor]
type = "python"
path = "data/scripts/deploy.py"
```

**HTTP** --- forwards to an endpoint:

```toml
[hooks.executor]
type = "http"
method = "POST"
url = "https://api.example.com/deploy"
headers = { Authorization = "Bearer token" }
body = '{"ref": "main"}'
follow_redirects = true
```

The Docker image includes Node.js and Python. Outside Docker, JavaScript hooks require `node` on `PATH`, and Python hooks require `python3` or `python`.

Shell commands receive the raw payload in `SENDWORD_PAYLOAD`. Script, JavaScript, and Python executors also receive `SENDWORD_PAYLOAD`, flattened payload fields as `SENDWORD_FIELD_*`, and a `payload.json` file in the execution log directory. In Node.js, read these through `process.env`; in Python, read them through `os.environ`.

```js
console.log(process.env.SENDWORD_PAYLOAD);
console.log(process.env.SENDWORD_FIELD_ACTION);
```

```python
import os

print(os.environ["SENDWORD_PAYLOAD"])
print(os.environ.get("SENDWORD_FIELD_ACTION", ""))
```

### Webhook authentication

**Bearer token:**

```toml
[hooks.auth]
mode = "bearer"
token = "your-secret-token"
```

Send as: `Authorization: Bearer your-secret-token`

**HMAC-SHA256:**

```toml
[hooks.auth]
mode = "hmac"
header = "X-Hub-Signature-256"
algorithm = "sha256"
secret = "your-hmac-secret"
```

Compatible with GitHub webhook signatures.

### Trigger rules

Control when a hook fires:

```toml
[hooks.trigger_rules]
cooldown = "60s"  # minimum time between executions

# Only fire when payload matches
payload_filters = [
  { field = "action", operator = "equals", value = "deploy" },
  { field = "environment", operator = "contains", value = "prod" },
  { field = "tag", operator = "regex", value = "^v\\d+\\.\\d+\\.\\d+$" },
  { field = "metadata.priority", operator = "gte", value = "5" },
]

# Rate limit triggers
[hooks.trigger_rules.rate_limit]
max_requests = 10
window = "1h"

# Only allow during business hours
[[hooks.trigger_rules.time_windows]]
days = ["Mon", "Tue", "Wed", "Thu", "Fri"]
start_time = "09:00"
end_time = "17:00"
```

Filter operators: `equals`, `not_equals`, `contains`, `regex`, `exists`, `gt`, `lt`, `gte`, `lte`.

### Execution barriers

Prevent conflicting concurrent executions:

```toml
# Mutex: only one execution at a time, others are rejected
[hooks.concurrency]
mode = "mutex"

# Queue: executions wait in line
[hooks.concurrency]
mode = "queue"
queue_depth = 10
```

Gate hooks behind human approval:

```toml
[hooks.approval]
required = true
timeout = "30m"  # optional, auto-reject after timeout
```

### Environment variable overrides

Every config field can be set via environment variables:

```sh
SENDWORD_SERVER__PORT=9090
SENDWORD_DATABASE__PATH=/var/lib/sendword/db.sqlite
SENDWORD_AUTH__SESSION_LIFETIME=48h
SENDWORD_DEFAULTS__TIMEOUT=60s
```

## CLI

```
sendword [COMMAND]

Commands:
  serve     Start the web server (default)
  export    Export current config as JSON to stdout
  import    Import config from a JSON file
  user      User management
  backup    Backup management
  restore   Restore from a backup
```

### Examples

```sh
# Start the server
sendword serve

# Export config for version control or migration
sendword export > config-backup.json

# Import config from JSON
sendword import config.json

# Create a user
sendword user create --email admin@example.com

# Create a backup
sendword backup create

# List backups
sendword backup list

# Restore from backup
sendword restore --from backups/2026-04-30.tar.gz --output restored/
```

## Triggering hooks

Send an HTTP POST to `/hook/<slug>`:

```sh
# Simple trigger
curl -X POST http://localhost:8080/hook/deploy-app

# With payload
curl -X POST http://localhost:8080/hook/deploy-app \
  -H "Content-Type: application/json" \
  -d '{"action": "deploy", "environment": "production"}'

# With bearer auth
curl -X POST http://localhost:8080/hook/deploy-app \
  -H "Authorization: Bearer secret-deploy-token" \
  -d '{"action": "deploy"}'
```

## Development

sendword uses [Nix flakes](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html) for development environment management and [just](https://just.systems/) as a command runner.

```sh
just          # list available commands
just run      # cargo run
just check    # cargo check
just test     # cargo test
just clippy   # cargo clippy -- -D warnings
just fmt      # cargo fmt
just watch    # bacon (file watcher)
just build    # cargo build --release
```

### Database

```sh
just migrate          # run pending migrations
just migrate-new NAME # create a new migration
just sqlx-prepare     # prepare sqlx offline queries
just sqlx-reset       # reset database and re-run migrations
```

### Tech stack

| Layer | Choice |
|-------|--------|
| Language | Rust (nightly) |
| Async runtime | Tokio |
| Web framework | Axum |
| Database | SQLite via SQLx |
| Templating | MiniJinja |
| Frontend | HTMX + Tailwind CSS |
| Config | Figment (TOML + JSON + env) |

## License

See [LICENSE](LICENSE) for details.