Local development
Webhook connectors need a public HTTPS URL. During development, test your handler with signed deliveries your tests create offline, with a test event sent from the portal through a tunnel, or with the calmlens CLI, which reads your project's events with your API key and forwards each one to a local URL with the same body, headers and signature as a real webhook delivery. The CLI is a standalone executable that works with every SDK.
Test without the CLI
Unit tests and CI need neither the CLI nor a CalmLens connection. Each SDK's testing helpers build a delivery body from an event and sign it with your webhook secret the way CalmLens does, so your handler's verification runs unchanged: see the webhook handlers section of the JavaScript, Python, Go, Ruby, PHP, Java or Rust testing guide.
To try a running handler with a real delivery, expose your local port through any HTTPS tunnel, create a webhook connector for the tunnel's URL and send a test event. The delivery and your handler's response appear in the connector's deliveries. Test events are attempted once; real events sent to the connector use the retry schedule.
Install the CLI
On macOS and Linux, the install script downloads the executable for your system from the CLI releases , checks it against the release's SHA256SUMS and installs it to ~/.local/bin, without sudo:
curl -fsSL https://calmlens.com/install.sh | shOn Windows, run the PowerShell script, which installs calmlens.exe to %LOCALAPPDATA%\CalmLens\bin and adds it to your user PATH:
irm https://calmlens.com/install.ps1 | iexBoth scripts install the latest release. Set CALMLENS_VERSION (such as 0.21.0) to install another, or CALMLENS_INSTALL_DIR to choose the directory. The Linux executables need glibc; on Alpine and other musl systems, install the CLI with npm.
Homebrew
brew tap calmlens/sdks https://github.com/CalmLens/sdks
brew install calmlens/sdks/calmlensDownload a release
Each release has an archive for darwin-arm64, darwin-x64, linux-arm64, linux-x64 and windows-x64, and a SHA256SUMS file. Download your platform's archive with SHA256SUMS, check it, then put calmlens on your PATH:
VERSION=0.21.0 PLATFORM=linux-x64
curl -fsSLO "https://github.com/CalmLens/sdks/releases/download/cli-v$VERSION/calmlens-$VERSION-$PLATFORM.tar.gz"
curl -fsSLO "https://github.com/CalmLens/sdks/releases/download/cli-v$VERSION/SHA256SUMS"
sha256sum --check --ignore-missing SHA256SUMS
tar -xzf "calmlens-$VERSION-$PLATFORM.tar.gz"On macOS, use shasum -a 256 --check --ignore-missing SHA256SUMS. On Windows, compare (Get-FileHash calmlens-$VERSION-windows-x64.zip).Hash with the archive's line in SHA256SUMS.
npm
The JavaScript SDK's calmlens package includes the same CLI, which needs Node.js 22 or later. Run it without installing, with npx calmlens, or install it globally:
npm install -g calmlensIn a project that depends on the SDK, npx calmlens runs the CLI that comes with the installed SDK, at the same version.
Sign in
calmlens loginlogin shows a code and opens CalmLens in your browser, where you enter the code and choose a project. Only enter a code shown in your own terminal. The CLI keeps the key it receives in your user configuration directory, so later commands need no API key or project ID. Add --read-only to let it only read; trigger needs read and change access. calmlens logout revokes the key and forgets it. You can also disconnect it from your Portal › Profile.
To keep logins for several projects, sign in to each under a profile name: calmlens login --profile staging. Pass --profile staging, or set CALMLENS_PROFILE=staging, to use it with any command, and calmlens logout --profile staging to revoke it.
Forward events locally
calmlens listen --forward-to http://localhost:3000/api/webhooks/calmlens --env-file .env.localInstead of login, you can set CALMLENS_API_KEY and CALMLENS_PROJECT_ID in the environment or in the --env-file file. When either is set, the CLI uses them and ignores your login. It reads CALMLENS_WEBHOOK_SECRET the same way; without one it prints a generated secret to put in your app. Use --events asset.allowed,asset.blocked to forward only some event types. The CLI receives only the events its key has permission to see, and warns at start-up about any requested type the key can't receive, such as asset.review-requested for a Viewer key; see Roles.
A login's key can read asset, usage and review events only. To forward team, API key, connector or upload preset events, use a project API key that holds the permission each type needs.
To create events without uploading your own content, run calmlens trigger [category]. It moderates a harmless test input that CalmLens classifies in the category you name, such as calmlens trigger hate, or as harassment by default; calmlens trigger clean sends text that should be allowed. For every category except clean, pass your project's test input key with --test-key or set CALMLENS_TEST_INPUT_KEY; a code signed with another key is moderated as ordinary text. Each trigger counts as one upload.
With --json, listen prints a JSON line on standard output for each delivery attempt (type, eventId, eventType, deliveryId, attempt, attempts, ok, status, error, durationMs and retryInMs), after a first ready line, and its readable lines on standard error; trigger --json prints the asset it created. --log-level info logs the CLI's retried and failed CalmLens requests to standard error, and --log-level debug every request; CALMLENS_LOG sets the same.
The CLI only forwards events created after it starts, and its deliveries don't appear in the portal. It retries a failed delivery like a real one: network errors, timeouts, 408, 425, 429 and 5xx responses are retried, up to 7 attempts with the same delivery ID, but after 1, 2, 4, 8, 15 and 30 seconds instead of the connector retry schedule, or longer when a Retry-After header asks, up to 60 seconds. Later events wait until the delivery succeeds or gives up. It reads GET /, which you can also call from your own tools with client.events.list().
Read the events feed
Prefer webhook connectors in production. The events feed suits local development, scripts and backfills, and powers calmlens listen. See Reading the feed for cursor handling.
let { nextCursor: cursor } = await client.events.list();
setInterval(async () => {
const page = await client.events.list({ cursor });
for (const event of page.items) console.log(event.type, event.assetId);
cursor = page.nextCursor;
}, 2000);