APIContext CLI
The APIContext CLI (apimetrics) lets you manage API monitors, projects, workflows, schedules, and more without opening a browser.
How the CLI works
The apimetrics binary is a fork of Restish. Instead of shipping a fixed set of resource subcommands, it loads the APIContext OpenAPI description from the configured server at startup and turns each API operation into its own CLI command at runtime — for example apimetrics list-monitors or apimetrics create-monitor.
Because of this, the available command set is not fixed: it varies by the configured endpoint, the API-description version, and your account tier. A small set of built-in commands (login, project selection, bulk sync) is always present; everything else is generated. See Generated commands for the full explanation and how to discover what is available to you.
Installation
The CLI is distributed only as a GitHub-release binary archive — there is no package-manager install.
- Open the APImetrics CLI releases page on GitHub.
- Download the archive matching your OS and architecture:
- macOS:
apimetrics-<version>-darwin-amd64or-darwin-arm64 - Linux:
apimetrics-<version>-linux-amd64or-linux-arm64 - Windows:
apimetrics-<version>-windows-amd64.zip
- macOS:
- Verify the download against the published
checksums.txt. - Extract the archive and move the
apimetricsbinary somewhere on yourPATH.
# Example (macOS arm64) — adjust the version/arch to the release you downloaded
tar -xzf apimetrics-1.2.3-darwin-arm64.tar.gz
sudo mv apimetrics /usr/local/bin/
apimetrics --version
Authentication
Authentication uses OAuth 2.0. You do not set an API key in an environment variable, and there is no api configure command — sign in with login instead.
apimetrics login
- The default interactive
loginuses the OAuth 2.0 authorization-code flow with PKCE (code_challenge_method=S256). It opens your browser to sign in. - For machine-to-machine use, the OAuth client-credentials flow is available.
- Most commands auto-trigger login when they need credentials, so running
loginexplicitly is rarely required. apimetrics logoutclears cached credentials and the active project.
See Authentication for OAuth details and named profiles (-p/--rsh-profile).
Configuration and endpoints
The CLI stores its state in a per-user config directory provided by the OS:
| Platform | Default config dir |
|---|---|
| macOS | ~/Library/Application Support/apimetrics |
| Linux | ~/.config/apimetrics |
Override it with the APIMETRICS_CONFIG_DIR environment variable. The active project is recorded in state.json inside that directory. A separate cache directory holds the cached OpenAPI description and tokens; override it with APIMETRICS_CACHE_DIR.
The endpoint the CLI talks to (and where it discovers the OpenAPI description) is compiled into the binary. You can override the server for a single invocation with the global -s/--rsh-server flag.
Selecting a project
Most commands operate on an active project. Set it once and it is remembered:
# Choose interactively from the projects you can access
apimetrics project select
# Or set it directly by ID (no prompt)
apimetrics project select prj_abc123
# Show the active project
apimetrics project show
See Project for details.
Built-in commands
These commands are always available, regardless of the loaded API description:
| Command | What it does |
|---|---|
apimetrics login / logout | Authenticate / clear credentials — see Authentication |
apimetrics project select / show | Manage the active project — see Project |
apimetrics bulk … | Client-side bulk sync of resources — see Bulk |
Output and global flags
Every command accepts the Restish --rsh-* global flags. The most important one to know:
# Get machine-readable JSON — note it is -o json, NOT --json
apimetrics list-monitors -o json
First monitor via the CLI
# 1. Authenticate (or let the next command trigger it for you)
apimetrics login
# 2. Select the project to work in
apimetrics project select
# 3. List your monitors (a generated command from the loaded API description)
apimetrics list-monitors -o json
# 4. Discover any other command and its flags
apimetrics --help
apimetrics list-monitors --help
Command reference
- CLI Command Reference — built-in command groups and global flags
- Generated commands — how runtime OpenAPI commands work and how to discover them
What's next?
- Monitor your first API — end-to-end UI tutorial
- API Reference — full REST API reference