snag-cli
v0.0.4
Published
Open-source webhook inspector CLI for Snag: create public capture URLs, stream live requests, forward them to localhost, inspect payloads, and replay webhooks.
Maintainers
Readme
snag-cli
snag-cli is the terminal client for Snag. It lets you watch captured requests, inspect a request by ID, replay requests to another target, and authenticate with magic links.
listen is the real-time capture stream. Use replay when you want to forward a captured request to a specific destination.
Install
npm install -g snag-cliThen run:
snag --helpRequirements
- Node.js 20+
- A reachable Snag server (local or hosted)
By default the CLI uses the hosted API at https://snag-server.fly.dev.
Override with --server <url> or set SNAG_SERVER_URL when running a local or
self-hosted server.
Quick start
- Start the CLI listener:
snag listen 3000- Send a webhook to the printed public URL (
.../h/<token>). - Copy the
requestIdfrom output and inspect it:
snag inspect <requestId>- Replay it to another target:
snag replay <requestId> --target https://httpbin.org/postCommands
snag listen <port>
Listen for real-time captured requests for a token.
Options:
-t, --token <token>reuse a specific endpoint token-s, --server <url>server base URL--method <method>filter method in terminal UI mode--search <text>filter path/body in terminal UI mode--jsonprint machine-readable JSON lines--silentsuppress output
Example:
snag listen 3000 --token my-dev-token --jsonsnag inspect <requestId>
Fetch and print one captured request by ID.
Options:
-s, --server <url>--json--silent
Example:
snag inspect req_abc123 --jsonsnag replay <requestId> --target <url>
Replay a captured request to a target URL.
Options:
--target <url>(required)-s, --server <url>--json--silent
Example:
snag replay req_abc123 --target https://httpbin.org/post --jsonsnag login --email <email>
Starts the magic-link login flow. The CLI requests a magic link, extracts the token, verifies it, and saves the session token locally.
Options:
-e, --email <email>(required)-s, --server <url>--token <magicToken>verify directly with a known magic token
Example:
snag login --email [email protected]Output modes
- Default: human-readable terminal output
--json: machine-readable output for scripts--silent: no output (useful in automation)
Local config
The CLI stores state in:
~/.snag/config.jsonFields:
token: default endpoint tokenserverUrl: default server URLauthToken: session token fromsnag login
Troubleshooting
HTTP 401on authenticated operations: runsnag loginfirst.HTTP 404for inspect/replay: confirm the request ID exists and is accessible.- Connection errors: verify
--serverorSNAG_SERVER_URLpoints to a live Snag server.
npm README behavior
This README.md is in the package root (packages/cli), which is required for npm package pages.
README changes appear on npm only after publishing a new package version.
