Skip to content

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

Terminal window
npm install -g @hookman/cli

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:

  1. --key <key> flag (explicit, highest priority)
  2. HOOKMAN_API_KEY environment variable
  3. ~/.hookman/config.json (written by hookman login)
  4. .hookman file 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.

Terminal window
hookman login

After authenticating in the browser, return to your terminal. The key is saved automatically.

hookman whoami

Prints the current authenticated user and org(s).

Terminal window
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.

Terminal window
hookman register \
--org <orgSlug> \
--project <projectSlug> \
--branch <label> \
--url <targetUrl> \
[--key <apiKey>] \
[--json]

Flags

FlagRequiredDescription
--orgYesYour org slug
--projectYesYour project slug
--branchYesBranch label — used as the routing key and display name
--urlYesFull target URL including webhook path
--keyNoAPI key (overrides env/config)
--jsonNoOutput result as JSON

Behaviour

  • If no deployment with this --branch label 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

Terminal window
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/payments

hookman remove

Remove a deployment by label.

Terminal window
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

Terminal window
hookman remove \
--org acme \
--project payments \
--branch feature/checkout
✓ Removed: feature/checkout

hookman switch

Set the active deployment for manual-switch routing.

Terminal window
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

Terminal window
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/stripe

hookman 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.

Terminal window
hookman rule set \
--name <ruleName> \
--source <source> \
--path <path> \
--op <op> \
[--value <value>] \
--target <branchLabel> \
[--priority <n>] \
[--org <orgSlug>] \
[--project <projectSlug>] \
[--key <apiKey>]

Flags

FlagRequiredDescription
--nameYesRule name — identifies the rule for later set/remove calls
--sourceYesWhere to read the condition from: header, query, body, or body_raw
--pathYesHeader/query name, or dot-path into the JSON body (ignored for body_raw)
--opYesComparison operator: eq, neq, contains, not_contains, starts_with, ends_with, exists, not_exists, regex
--valueOnly for ops other than exists/not_existsValue to compare against
--targetYesBranch label of a deployment already registered via hookman register — resolved to that deployment’s target URL
--priorityNoLower 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.
--orgNoOrg slug
--projectNoProject slug
--keyNoAPI key (overrides env/config)

Behaviour

  • --target is a branch label, not a URL — it’s looked up against the project’s registered deployments (the same labels hookman register/switch use) and resolved to that deployment’s stored target URL.
  • The rule is created if --name doesn’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

Terminal window
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.

Terminal window
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

Terminal window
hookman rule remove --org acme --project payments --name staging-header
✓ Removed rule: staging-header

hookman 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.

Terminal window
hookman rule ls [--org <orgSlug>] [--project <projectSlug>] [--key <apiKey>] [--json]

Example

Terminal window
hookman rule ls --org acme --project payments
Managed rules in acme/payments
● 5 staging-header header[x-env] eq "staging" → https://pr-42.myapp.com/api/webhooks/stripe

hookman ls

List orgs, an org’s projects, or a project’s deployments — drill down by adding --org, then --project.

Terminal window
hookman ls [--org <orgSlug>] [--project <projectSlug>] [--key <apiKey>] [--json]

Flags

FlagRequiredDescription
--orgNoOrg slug — list its projects instead of all orgs
--projectNoProject slug (with --org) — list its deployments instead of projects
--keyNoAPI key (overrides env/config)
--jsonNoOutput as JSON

Behaviour

  • Bare hookman ls lists 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

Terminal window
hookman ls
Organisations
· acme (owner, pro)
Terminal window
hookman ls --org acme
Projects in acme
· payments (Payments)
Terminal window
hookman ls --org acme --project payments
Deployments in acme/payments
● main https://myapp.com/api/webhooks/stripe
○ feature/checkout https://pr-42.myapp.com/api/webhooks/stripe

hookman 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.

Terminal window
hookman listen \
--forward-to <url> \
--branch <label> \
[--org <orgSlug>] \
[--project <projectSlug>] \
[--key <apiKey>]

Flags

FlagRequiredDescription
--forward-toYesLocal URL to deliver webhooks to, e.g. localhost:4242/webhook
--branchYesDeployment label to attach to
--orgNoOrg slug
--projectNoProject slug
--keyNoAPI key (overrides env/config)

Behaviour

  • Enables local mode for the deployment, then opens a persistent connection and streams matching webhooks to --forward-to as 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 listen is running, and “listening” once the connection is live.
  • Ctrl+C disables local mode and closes the connection. Only one listener can be active per deployment at a time.

Example

Terminal window
hookman listen \
--org acme \
--project payments \
--branch feature/checkout \
--forward-to localhost:4242/webhook
✓ Local mode enabled for feature/checkout
Ready! Forwarding feature/checkout webhooks to http://localhost:4242/webhook
Ctrl+C to stop
POST → 200

Environment variables

VariableDescription
HOOKMAN_API_KEYAPI key used for all commands. Takes precedence over ~/.hookman/config.json.
HOOKMAN_ORGDefault org slug — used when --org is omitted.
HOOKMAN_PROJECTDefault project slug — used when --project is omitted.
HOOKMAN_API_URLAPI host the CLI talks to. Defaults to https://api.hookman.dev — set this to point at a self-hosted instance.
HOOKMAN_APP_URLDashboard 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:

Terminal window
# 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/stripe
hookman remove --branch feature/checkout

Exit codes

CodeMeaning
0Success
1Any 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/stripe

GitLab 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