The mantis CLI is the primary way to work with a Mantis server (and with the stateless edge worker). This page documents every command and flag in the CLI, transcribed from the v0.2.0 source. For the conceptual map — diagrams, mental model, common workflows — see cli/COMMAND_MAP.md in the app repo. New to the CLI? Run mantis init for guided, interactive setup, or mantis with no arguments for a context-aware welcome screen.
This reference covers CLI v0.2.0. Check yours with mantis --version, and run mantis doctor after upgrading the server to confirm compatibility.

Global flags

These can be combined with most commands. They’re owned by the root mantis program, so they work the same everywhere.

Environment-only settings

Three settings have no flag — they only exist as environment variables.

How a command picks its server

Resolution happens when the command runs, in this order:
  1. Ad-hoc--base-url + --key together talk to a one-off server, ignoring profiles.
  2. --profile <name> — use that named profile.
  3. MANTIS_PROFILE — same, from the environment.
  4. Stored current profile — the default when nothing else is set.
The base URL comes from local config; the API key comes from the OS keychain. Generated artifacts (files, Home Assistant YAML, NFC URLs, host installers) embed a literal trigger URL at creation time — they don’t consult CLI profiles when they later fire.
Any <id> argument accepts a full UUID, a unique prefix of at least four hex characters, or the literal last (the most-recently-created key). Example: mantis hits last --follow.

Setup & authentication

mantis init

Guided first-time setup — walks you through a server or edge configuration, interactive. No flags.

mantis login

Store an API key for a profile, creating one if needed.

mantis logout

Clear stored credentials for a profile (default: current).

mantis whoami

Show the current profile: server, key prefix, Cloudflare Access state, and edge worker. No flags.

mantis doctor

Check CLI config, server health, auth, and split public/private hosts.

mantis detect

Scan this machine for Mantis-style installer artifacts — a defensive, offline self-audit.

Profiles

mantis profile <subcommand> — manage CLI profiles (multiple Mantis servers + edge workers). profile set-edge links a default mantis-edge worker URL to a profile, which mantis edge mint then uses as its fallback worker.

Cloudflare Access

mantis cloudflare <subcommand> — manage Cloudflare Access auth for the Mantis API. See Cloudflare deployment for context. set-service-auth configures a Service-Auth client-id + client-secret pair for headless CLI usage.

Keys

mantis new [memo]

Create a new key, and optionally generate bait artifacts and an installer in one shot. [memo] is a human-readable label. Bait-file artifacts (each writes a file containing the canary): Installer chaining (template a host snippet right after creation): Run mantis new with no arguments on a TTY to launch the interactive wizard.

mantis bulk-create (alias import-csv)

Bulk-create keys from a CSV and write an output CSV with the generated URLs. The input CSV is capped at 64 MiB. Raise it with MANTIS_BULK_CREATE_MAX_BYTES if you trust the file. Per-row CSV columns. The flags above set one value for every row. To vary a row from the rest, add these columns to the input CSV. response_kind, response_payload, and expires_at override the matching flag for that row only; the notify / notify_<channel> columns add their destinations on top of the --notify flags rather than replacing them: Output columns. The output CSV is your input with six columns appended (reused in place if a same-named column already exists, matched case-insensitively): mantis_memo, mantis_id, mantis_public_id, mantis_url, mantis_created_at, and mantis_error (populated per row on failure, so a partial run tells you exactly which rows didn’t create).

mantis list (alias ls)

List keys.

mantis show <id>

Show one key.

mantis last

Print the id of the most-recently-created key. (Or pass last as the <id> argument on any command.) No flags.

mantis open [id]

Open a key’s dashboard page in the browser (or the dashboard root).

mantis disable <id...>

Disable one or more keys (preserves hit history). Accepts multiple ids. No flags.

mantis enable <id...>

Re-enable one or more disabled keys. Accepts multiple ids. No flags.

mantis rm <id...> (alias delete)

Delete one or more keys and cascade their hits. Accepts multiple ids.

Artifacts & installers

mantis download <id>

Download generated bait files for an existing key. Each flag writes one file. The last eight are the credential/config-store bait formats: unlike the document formats above (--rtf included, which beacons on open like .docx), they fire when the URL inside is used, not when the file is opened. Save each under the name the real thing has (cookies.txt, .netrc, ~/.aws/credentials, …) — see file keys.

mantis install <id>

Generate a host-install or web-embed snippet for a key (built-in or plugin-provided type). See Host events.

Installer types

Plugins can register additional types; mantis install validates against the union of built-ins plus installed plugins.

Device suites

mantis device <subcommand> — mint and install the full set of host alarms for one machine in a single step. Where mantis new --install templates one alarm, a device suite mints one key per vector (shell login, sudo, wake, boot, network) for a named machine, so a hit tells you which alarm fired rather than just “something happened on web01”. Each key is keyed idempotently by device-name + vector, so re-running for a rebuilt machine reuses its keys instead of minting a second set.

mantis device profiles

List the vectors each OS profile would mint (and which need extra setup). No flags.

mantis device new

Mint one key per host alarm for a machine. --bundle is the reversible option — you read the script before running it; --install is the apply-now shortcut for the machine you’re on.

Hits & monitoring

mantis hits <id>

Show recent hits for a key (filterable; --follow for a live tail).

mantis watch [id]

Poll for new hits and print them as they arrive — across all keys, or one. Omit [id] to watch all keys.

mantis status [id]

Show monitor state across keys, or details for one (window mode: hits + expiry; latch mode: hits since reset). Omit [id] for a summary across all monitored keys.

mantis monitor <id>

Configure the Uptime Kuma status endpoint for a key.

mantis reset <id>

Reset a key’s tripped monitor state (latch mode). No flags.

Notifications

mantis destinations <subcommand> (alias dest) — incrementally manage notification destinations on a key. Channels: webhook, email, slack, discord, teams, home_assistant.
  • add fires an activation ping when the destination is created.
  • test fires a synthetic hit on the key URL and reports which destinations succeeded.
  • rotate-secret rotates the HMAC signing secret on a webhook destination; the new secret is shown once.
These subcommands manage destinations on one key. To route every key’s hits to a shared destination without re-entering it each time, set an instance-wide destination in the dashboard at /settings/notifications (admin only) — see global destinations. There is no CLI subcommand for the global set.

Audit log

mantis audit log — list audit events, most recent first (admin keys only).

Edge worker

mantis edge <subcommand> — manage the stateless mantis-edge (Cloudflare Worker) key flow. See Edge deployment.

mantis edge keygen

Generate a 32-byte AES key for an edge worker (prints to stdout). No flags.

mantis edge deploy

Deploy the mantis-edge Worker (wraps wrangler deploy) and capture its URL. Runs the worker’s own wrangler via npx, so no global install is needed.

mantis edge set-key [worker] [key]

Store an edge AES key in the OS keychain for a given worker URL. [worker] is an alternative to --worker; [key] is a base64url-encoded 32-byte key (prompts for paste if omitted). There is intentionally no --key flag here — it would collide with the global --key. Use the positional argument, --key-stdin, or the prompt.

mantis edge delete-key

Remove a stored edge key for a worker URL.

mantis edge mint

Mint a stateless edge URL — no server round-trip, pure local crypto. Run it bare on a TTY to launch the interactive wizard. --edge-key is named separately from the global --key to avoid a collision.

mantis edge device

The stateless counterpart to mantis device new: mint one edge URL per host alarm for a machine and write an install bundle directory, with no server and no database. Same vector model as mantis device, plus the edge minting flags.

mantis edge install <url>

Generate an installer snippet for a stateless edge URL — the same snippets mantis install produces server-side, but for a minted edge URL. <url> is the URL printed by mantis edge mint.

Backup & restore

mantis backup and mantis restore export and re-import your CLI profiles + plugin manifest as a passphrase-encrypted file. These have a dedicated guide with format details and automation examples — see CLI backup & restore.

mantis backup

mantis restore <file>

<file> is a bundle produced by mantis backup.

Plugins

mantis plugin <subcommand> — manage CLI plugins (third-party installer types + file formats; installed locally, never on the server).

Machine-wide config

mantis config <subcommand> — get/set machine-wide CLI defaults (output mode, color). Stored defaults are applied below explicit flags.

Shell completion

mantis completion <shell> — print a shell completion script. <shell> is bash, zsh, or fish.