Skip to main content

Generated commands

Most of what you can do with the apimetrics CLI is not hard-coded into the binary. At startup, the CLI loads the APIContext OpenAPI description from its configured server and turns each API operation into its own CLI command.

That is why you can run commands like:

apimetrics list-monitors
apimetrics create-api-monitor name: "Check payments API", method: GET, url: https://api.example.com/v1/health
apimetrics get-result <result-id>

even though none of those are written into the binary's source. Each one corresponds to an operation in the OpenAPI description.

How generation works​

  1. On startup the CLI fetches (and caches) the OpenAPI description from the configured endpoint.
  2. For every operation in that description, it registers a command, deriving the command name, flags, and input and response schemas from the operation.
  3. Those generated commands sit alongside the always-present built-in commands (login, project select, bulk).

The description is cached locally (in the cache directory described in the CLI overview), so subsequent runs are fast.

Auto-authentication​

Generated commands talk to the live API, so they need credentials. You do not have to log in first. When a command needs authentication and none is cached, the CLI automatically starts the login flow (OAuth 2.0 authorization-code + PKCE by default). After that it remembers your credentials and active project.

The command set varies​

Because the commands come from the loaded OpenAPI description, the available set is not fixed. It depends on:

  • the configured endpoint the CLI points at,
  • the version of the API description served there, and
  • your account tier / role, which can gate which operations are exposed.

A list of commands copied from these docs, a script, or another machine is therefore a snapshot of one moment. It is not a permanent contract.

Discovering what is available​

For your setup, the binary is the only authoritative list. Use --help:

# List every command available to you, grouped by category
apimetrics --help

# Inspect a single generated command: its flags and request/response schema
apimetrics list-monitors --help

Combine with the global flags, for example -o json for machine-readable output:

apimetrics list-monitors -o json

See also​