CLI reference
The hookman CLI lets you register deployments, switch active targets, manage conditional routing rules, and manage your projects from the terminal or CI/CD pipelines.
Installation
npm install -g @hookman/clipnpm add -g @hookman/cli# Use directly without installingnpx @hookman/cli <command>The package is published as @hookman/cli; it installs a hookman binary, so all commands below are run as hookman ….
Authentication
API key resolution
The CLI resolves your API key in this priority order:
--key <key>flag (explicit, highest priority)HOOKMAN_API_KEYenvironment variable~/.hookman/config.json(written byhookman login).hookmanfile in the current working directory
If no key is found, the CLI exits with a clear error and instructions.
hookman login
Opens your browser to the Hookman dashboard to authenticate. Saves the resulting API key to ~/.hookman/config.json.
hookman loginAfter authenticating in the browser, return to your terminal. The key is saved automatically.
hookman whoami
Prints the current authenticated user and org(s).
hookman whoami# → Authenticated as [email protected]# → Orgs: acme (owner), darren-workspace (owner)Commands
hookman register
Register a deployment, or update it if the label already exists.
hookman register \ --org <orgSlug> \ --project <projectSlug> \ --branch <label> \ --url <targetUrl> \ [--key <apiKey>] \ [--json]Flags
| Flag | Required | Description |
|---|---|---|
--org | Yes | Your org slug |
--project | Yes | Your project slug |
--branch | Yes | Branch label — used as the routing key and display name |
--url | Yes | Full target URL including webhook path |
--key | No | API key (overrides env/config) |
--json | No | Output result as JSON |
Behaviour
- If no deployment with this
--branchlabel exists, it is created. - If a deployment with this label already exists, its URL is updated.
- The command is idempotent — safe to call on every deploy from CI.
Example
hookman register \ --org acme \ --project payments \ --branch feature/checkout \ --url https://pr-42.myapp.com/api/webhooks/stripe✓ Registered: feature/checkout → https://pr-42.myapp.com/api/webhooks/stripe Hookman endpoint: https://hookman.dev/w/acme/paymentshookman remove
Remove a deployment by label.
hookman remove \ --org <orgSlug> \ --project <projectSlug> \ --branch <label> \ [--key <apiKey>] \ [--json]Returns exit code 0 whether or not the deployment existed (idempotent — safe for CI cleanup jobs).
Example
hookman remove \ --org acme \ --project payments \ --branch feature/checkout✓ Removed: feature/checkouthookman switch
Set the active deployment for manual-switch routing.
hookman switch \ --org <orgSlug> \ --project <projectSlug> \ --branch <label> \ [--key <apiKey>]After this command, all incoming webhooks to the project’s endpoint are forwarded to the named deployment — until you switch again or configure automatic routing.
Example
hookman switch \ --org acme \ --project payments \ --branch feature/checkout
# → ✓ Active deployment set to: feature/checkout# → Webhooks now routing to: https://pr-42.myapp.com/api/webhooks/stripehookman rule
Manage CLI/CI-driven conditional routing rules. See Routing strategies overview for how dynamic rules relate to manual (dashboard) rules, evaluation tiers, and priority — this section covers the CLI flags only.
hookman rule set
Create or update a dynamic routing rule.
hookman rule set \ --name <ruleName> \ --source <source> \ --path <path> \ --op <op> \ [--value <value>] \ --target <branchLabel> \ [--priority <n>] \ [--org <orgSlug>] \ [--project <projectSlug>] \ [--key <apiKey>]Flags
| Flag | Required | Description |
|---|---|---|
--name | Yes | Rule name — identifies the rule for later set/remove calls |
--source | Yes | Where to read the condition from: header, query, body, or body_raw |
--path | Yes | Header/query name, or dot-path into the JSON body (ignored for body_raw) |
--op | Yes | Comparison operator: eq, neq, contains, not_contains, starts_with, ends_with, exists, not_exists, regex |
--value | Only for ops other than exists/not_exists | Value to compare against |
--target | Yes | Branch label of a deployment already registered via hookman register — resolved to that deployment’s target URL |
--priority | No | Lower runs first among dynamic rules (default: appended after existing dynamic rules). Run hookman rule ls to see priorities already in use — a colliding value is rejected with a 400. |
--org | No | Org slug |
--project | No | Project slug |
--key | No | API key (overrides env/config) |
Behaviour
--targetis a branch label, not a URL — it’s looked up against the project’s registered deployments (the same labelshookman register/switchuse) and resolved to that deployment’s stored target URL.- The rule is created if
--namedoesn’t already exist, or updated in place if it does. - Publishes immediately — there’s no separate publish step, unlike manual rules created in the dashboard (see Routing strategies overview).
Example
hookman rule set \ --org acme \ --project payments \ --name staging-header \ --source header --path x-env --op eq --value staging \ --target feature/checkout✓ Created rule "staging-header" → feature/checkout (published v7)hookman rule remove
Remove a dynamic routing rule by name, and publish the change immediately.
hookman rule remove \ --name <ruleName> \ [--org <orgSlug>] \ [--project <projectSlug>] \ [--key <apiKey>]Exits 0 whether or not the rule existed (idempotent — safe for CI cleanup jobs).
Example
hookman rule remove --org acme --project payments --name staging-header✓ Removed rule: staging-headerhookman rule ls
List dynamic routing rules for a project, including each rule’s priority — useful for picking a free slot before calling rule set --priority.
hookman rule ls [--org <orgSlug>] [--project <projectSlug>] [--key <apiKey>] [--json]Example
hookman rule ls --org acme --project paymentsManaged rules in acme/payments ● 5 staging-header header[x-env] eq "staging" → https://pr-42.myapp.com/api/webhooks/stripehookman ls
List orgs, an org’s projects, or a project’s deployments — drill down by adding --org, then --project.
hookman ls [--org <orgSlug>] [--project <projectSlug>] [--key <apiKey>] [--json]Flags
| Flag | Required | Description |
|---|---|---|
--org | No | Org slug — list its projects instead of all orgs |
--project | No | Project slug (with --org) — list its deployments instead of projects |
--key | No | API key (overrides env/config) |
--json | No | Output as JSON |
Behaviour
- Bare
hookman lslists every org you belong to. hookman ls --org <orgSlug>lists that org’s projects.hookman ls --org <orgSlug> --project <projectSlug>lists that project’s deployments.
Example
hookman lsOrganisations · acme (owner, pro)hookman ls --org acmeProjects in acme · payments (Payments)hookman ls --org acme --project paymentsDeployments in acme/payments ● main https://myapp.com/api/webhooks/stripe ○ feature/checkout https://pr-42.myapp.com/api/webhooks/stripehookman listen
Forward a deployment’s webhook traffic to your local machine (mirrors stripe listen). Useful for developing against real webhooks — Stripe, Paddle, etc. — without deploying first.
hookman listen \ --forward-to <url> \ --branch <label> \ [--org <orgSlug>] \ [--project <projectSlug>] \ [--key <apiKey>]Flags
| Flag | Required | Description |
|---|---|---|
--forward-to | Yes | Local URL to deliver webhooks to, e.g. localhost:4242/webhook |
--branch | Yes | Deployment label to attach to |
--org | No | Org slug |
--project | No | Project slug |
--key | No | API key (overrides env/config) |
Behaviour
- Enables local mode for the deployment, then opens a persistent connection and streams matching webhooks to
--forward-toas they arrive — your local server sees the same request the upstream provider sent. - The dashboard’s routing tools show the deployment as “local mode” while
hookman listenis running, and “listening” once the connection is live. Ctrl+Cdisables local mode and closes the connection. Only one listener can be active per deployment at a time.
Example
hookman listen \ --org acme \ --project payments \ --branch feature/checkout \ --forward-to localhost:4242/webhook✓ Local mode enabled for feature/checkoutReady! Forwarding feature/checkout webhooks to http://localhost:4242/webhook Ctrl+C to stop POST → 200Environment variables
| Variable | Description |
|---|---|
HOOKMAN_API_KEY | API key used for all commands. Takes precedence over ~/.hookman/config.json. |
HOOKMAN_ORG | Default org slug — used when --org is omitted. |
HOOKMAN_PROJECT | Default project slug — used when --project is omitted. |
HOOKMAN_API_URL | API host the CLI talks to. Defaults to https://api.hookman.dev — set this to point at a self-hosted instance. |
HOOKMAN_APP_URL | Dashboard host hookman login opens in the browser. Defaults to https://app.hookman.dev — set alongside HOOKMAN_API_URL for a self-hosted instance. |
Setting HOOKMAN_ORG and HOOKMAN_PROJECT lets you shorten commands in a single-project CI environment:
# In your CI environment:# HOOKMAN_API_KEY=hm_live_xxx# HOOKMAN_ORG=acme# HOOKMAN_PROJECT=payments
hookman register --branch feature/checkout --url https://pr-42.myapp.com/api/webhooks/stripehookman remove --branch feature/checkoutExit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Any failure — auth, not found, quota, network, etc. (see stderr for details) |
hookman remove is the one exception: it exits 0 even if the deployment
didn’t exist, since removing something already gone is not a failure (see
above).
Using in CI/CD
GitHub Actions
- name: Register deployment env: HOOKMAN_API_KEY: ${{ secrets.HOOKMAN_API_KEY }} run: | npx hookman register \ --org acme \ --project payments \ --branch ${{ github.head_ref }} \ --url ${{ steps.deploy.outputs.preview-url }}/api/webhooks/stripeGitLab CI
register-hookman: stage: deploy script: - npx hookman register --org $HOOKMAN_ORG --project payments --branch $CI_COMMIT_REF_NAME --url $CI_ENVIRONMENT_URL/api/webhooks/stripe variables: HOOKMAN_API_KEY: $HOOKMAN_API_KEY