|
| 1 | +# Receiving Linear Webhooks Locally |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +- Docker Compose |
| 6 | +- A [Linear](https://linear.app) workspace with admin access |
| 7 | +- An [ngrok](https://ngrok.com) account (free tier works) |
| 8 | + |
| 9 | +## 1. Generate a webhook secret |
| 10 | + |
| 11 | +```bash |
| 12 | +openssl rand -hex 32 |
| 13 | +``` |
| 14 | + |
| 15 | +Save the output — you'll use it in both Linear and the local stack. |
| 16 | + |
| 17 | +## 2. Start the stack |
| 18 | + |
| 19 | +```bash |
| 20 | +docker compose --profile dev up |
| 21 | +``` |
| 22 | + |
| 23 | +This starts NATS, the webhook receiver, and ngrok. Find the public tunnel URL |
| 24 | +in the ngrok container logs: |
| 25 | + |
| 26 | +```bash |
| 27 | +docker compose logs ngrok |
| 28 | +``` |
| 29 | + |
| 30 | +Look for the `linear` tunnel URL (e.g. `https://abc123.ngrok-free.app`). |
| 31 | + |
| 32 | +## 3. Configure your Linear webhook |
| 33 | + |
| 34 | +1. Go to **Settings → API → Webhooks** |
| 35 | +2. Click **New webhook** |
| 36 | +3. Set: |
| 37 | + - **URL**: `https://<ngrok-url>/webhook` |
| 38 | + - **Secret**: the secret you generated in step 1 |
| 39 | +4. Select the resource types you want to receive events for |
| 40 | +5. Save |
| 41 | + |
| 42 | +## 4. Verify |
| 43 | + |
| 44 | +Trigger an event in Linear (e.g. create an issue). You should see: |
| 45 | + |
| 46 | +- The webhook receiver log the incoming event |
| 47 | +- The event published to NATS on `linear.{type}.{action}` |
| 48 | + |
| 49 | +You can inspect NATS with: |
| 50 | + |
| 51 | +```bash |
| 52 | +nats sub -s nats://nats.trogonai.orb.local:4222 "linear.>" |
| 53 | +``` |
| 54 | + |
| 55 | +Without `--profile dev`, ngrok is excluded and only the core services start. |
| 56 | + |
| 57 | +## Environment variables |
| 58 | + |
| 59 | +| Variable | Required | Default | Description | |
| 60 | +|---|---|---|---| |
| 61 | +| `LINEAR_WEBHOOK_SECRET` | yes | — | HMAC-SHA256 secret (must match Linear webhook) | |
| 62 | +| `NGROK_AUTHTOKEN` | yes (dev profile) | — | ngrok auth token | |
| 63 | +| `LINEAR_WEBHOOK_PORT` | no | `8080` | HTTP port for the webhook receiver | |
| 64 | +| `LINEAR_SUBJECT_PREFIX` | no | `linear` | NATS subject prefix | |
| 65 | +| `LINEAR_STREAM_NAME` | no | `LINEAR` | JetStream stream name | |
| 66 | +| `LINEAR_STREAM_MAX_AGE_SECS` | no | `604800` | Max message age in seconds (7 days) | |
| 67 | +| `LINEAR_WEBHOOK_TIMESTAMP_TOLERANCE_SECS` | no | `60` | Replay-attack window in seconds (0 to disable) | |
| 68 | +| `LINEAR_NATS_ACK_TIMEOUT_MS` | no | `10000` | JetStream ACK timeout in milliseconds | |
| 69 | +| `LINEAR_NATS_STREAM_OP_TIMEOUT_MS` | no | `10000` | Stream operation timeout in milliseconds | |
| 70 | +| `NATS_URL` | no | `localhost:4222` | NATS server URL(s) | |
| 71 | +| `RUST_LOG` | no | `info` | Log level | |
0 commit comments