You already have an AI coding agent open. It edits your files, runs your tests, and reads your terminal output. So why install a command-line tool manually by copying npm commands from a browser tab one at a time?
You don’t have to. The Apidog CLI is an npm package named apidog-cli that runs the API test scenarios you built in Apidog directly from your terminal. Installing it is a short sequence: check Node/npm, install the package, authenticate, and run a scenario.
That is exactly the kind of mechanical work an agent like Claude Code, Cursor, Windsurf, or GitHub Copilot in agent mode can handle well. You describe the goal, the agent runs the real commands, and you verify the output.
This guide shows the workflow end to end. You’ll get the prompts to give your agent, the commands it should run, and the checks you should perform at each step. By the end, your agent can run Apidog tests inside its own edit-test-fix loop or in CI and use the exit code as a pass/fail signal.
To follow along, you need an Apidog account with at least one project.
Why let an agent install the CLI?
The install command does not change when an agent runs it. It is still:
npm install -g apidog-cli@latest
What changes is who runs the command, reads the output, and reacts to errors.
An agent is useful here because it can:
- Run commands and inspect the actual exit status.
- Read terminal output and decide the next step from real errors.
- Adapt to your machine’s Node version, npm setup, and
PATH. - Verify the install instead of stopping after the npm command.
- Reuse the CLI later to run API tests automatically.
The important pattern is: delegate the mechanical work, but verify the result yourself.
What you need before you start
The CLI ships as an npm package, so the only required system dependency is Node.js.
Before starting, make sure you have:
- Node.js and npm installed
The package installs through npm and runs on Node. A current LTS release is the safe default for most developer machines.
- An Apidog account with project access
The CLI does not store tests locally. It runs scenarios from your Apidog project, so your account needs access to at least one project.
- A test scenario to run
The runner executes scenarios, not loose requests. In Apidog, create a scenario by chaining requests, adding assertions, and saving it. If you are new to response checks, see API assertions: a practical guide.
- An AI coding agent that can run shell commands
Claude Code, Cursor Agent, Windsurf Cascade, and GitHub Copilot agent mode can all work. Confirm that your agent can execute terminal commands, not only suggest them.
If your agent can only print commands, you can still follow this workflow. You will just run the commands manually.
Step 1: Have the agent check the environment
Start by asking the agent to confirm that Node.js and npm are available.
Use this prompt:
Check whether Node.js and npm are installed on this machine. Run
node -vandnpm -vand tell me the versions. If either is missing, tell me, don’t try to install Node yourself.
The agent should run:
node -v
npm -v
You should see two version numbers.
Example output:
v22.11.0
10.9.0
Verify this step
Do not accept “Node is installed” without raw version output.
If the agent does not show the command output, ask:
Paste the raw output from
node -vandnpm -v.
The prompt tells the agent not to install Node because runtime installation is machine-specific. If Node is missing, install it from nodejs.org, then continue.
Step 2: Have the agent install the CLI
Once Node and npm are confirmed, ask the agent to follow the official install instructions.
Use this prompt:
Read https://apidog.com/apidog-cli-installation-guide.md?utm_source=dev.to&utm_medium=wanda&utm_content=n8n-post-automation and follow instructions.
The core install command is:
npm install -g apidog-cli@latest
The -g flag installs the package globally so the apidog binary is available on your PATH.
The @latest tag installs the latest published version.
After installation, the executable is named:
apidog
Next, the agent should verify the install:
apidog --version
apidog --help
Verify this step
This is the most important check in the setup.
Make sure:
-
apidog --versionprints an actual version number. -
apidog --helpprints CLI usage information. - The help output includes
apidog runand its options.
If you want one command that verifies both Node and Apidog resolve correctly, ask the agent to run:
node -v && apidog --version && which node && which apidog
Expected result:
v22.11.0
<apidog-cli-version>
/path/to/node
/path/to/apidog
If apidog is not found, the most likely issue is that npm’s global binary directory is not on your PATH.
Optional: use npx instead of a global install
If you do not want the agent to modify global npm packages, use npx:
npx apidog-cli --version
This fetches and runs the package without installing a persistent global binary.
Use npx for:
- Shared machines
- Ephemeral CI runners
- One-off checks
Use a global install for:
- Your daily development machine
- Repeated local test runs
- Faster agent workflows
Step 3: Authenticate, but keep the token out of the agent chat
The CLI needs an access token to run scenarios from your Apidog account.
This is the one step you should not fully delegate. Treat the token like a password. Do not paste it into an agent prompt, chat transcript, or log.
Generate the token yourself:
- Open the Apidog app or web console.
- Click your user avatar.
- Go to Account Settings.
- Open API Access Token.
- Generate a new token.
- Copy it somewhere secure.
Then prompt the agent without including the token:
I’ll authenticate the Apidog CLI myself so the token stays out of this chat. Tell me the exact
apidog logincommand to run, then after I confirm I’ve run it, runapidog whoamito verify the CLI is authenticated and show me the result.
Run the login command yourself:
apidog login --with-token YOUR_ACCESS_TOKEN
Then let the agent verify authentication:
apidog whoami
Verify this step
apidog whoami should print your account information.
If it does, authentication is configured locally and the agent can run future CLI commands without seeing the raw token.
Keeping the token out of the agent context is basic operational hygiene. A token pasted into chat can end up in transcripts, logs, or future context. The CLI only needs the token stored locally; the agent does not need to read it.
Step 4: Have the agent run a test scenario
Now run an actual Apidog test scenario.
The core command is:
apidog run
You need to point it at a scenario ID.
The easiest way to get a correct command is to let Apidog generate it:
- Open your test scenario in Apidog.
- Go to the CI/CD tab.
- Choose the command-line option.
- Copy the generated
apidog runcommand.
It may look like this:
apidog run --access-token YOUR_ACCESS_TOKEN -t 605067 -e 1629989 -n 1 -r cli
Breakdown:
-
--access-token YOUR_ACCESS_TOKENauthenticates the run. -
-t 605067selects the test scenario ID. -
-e 1629989selects the environment ID. -
-n 1runs the scenario once. -
-r cliprints a readable CLI report.
Because you already authenticated with apidog login, you can omit the token and give the agent only the non-secret command.
Use this prompt:
Run my Apidog test scenario with the CLI. I’m already authenticated, so don’t pass an access token. Use:
apidog run -t 605067 -e 1629989 -n 1 -r cli. Show me the full output and tell me the exit code.
The agent should run:
apidog run -t 605067 -e 1629989 -n 1 -r cli
Verify this step
Ask for the exit code explicitly.
apidog run exits with:
-
0when all assertions pass - Non-zero when something fails
That exit code is what makes the command useful in automation.
If the agent says “tests passed” but the exit code is non-zero, trust the exit code, not the summary.
To inspect available run options, ask the agent to run:
apidog run --help
For the full flag reference and CI examples, see the complete Apidog CLI guide.
The payoff: your agent can now test on its own
Once the CLI is installed and authenticated, running your API scenario is a single shell command.
That means your coding agent can use Apidog tests as part of its normal loop:
- Modify code.
- Run unit tests.
- Run the relevant Apidog scenario.
- Read the CLI report.
- Check the exit code.
- Fix failures or move on.
For example, if the agent edits a handler that affects an API endpoint, it can run:
apidog run -t 605067 -e 1629989 -n 1 -r cli
Then it can react to the result:
- Exit code
0: continue. - Non-zero exit code: inspect the failing assertion and make a fix.
That turns API testing into the same kind of feedback loop agents already use for unit tests.
For a broader look at this pattern, see how to use AI agents for API testing.
Use the same command in CI
After you verify the command locally, the same command can run in CI.
The difference is token handling. In CI, do not hard-code the token in your workflow file. Store it as a secret and inject it at runtime.
A typical CI command looks like this:
apidog run --access-token "$APIDOG_ACCESS_TOKEN" -t 605067 -e 1629989 -n 1 -r cli
The pass/fail behavior remains the same:
- Exit code
0: pipeline passes. - Non-zero exit code: pipeline fails.
For GitHub Actions setup, secrets, reporters, and exit-code gating, see Apidog CLI in GitHub Actions.
Go deeper with agent integrations
If you want more than shell-command execution, Apidog also supports deeper agent workflows.
The Apidog MCP server exposes your API specifications to AI coding tools through the Model Context Protocol. That lets an agent read your API schema while it writes or updates code.
Apidog CLI with Claude Skills packages the CLI workflow into a reusable Claude skill, so test-running becomes something Claude can trigger as part of its workflow.
Both options build on the same apidog-cli setup from this guide.
From delegated install to a tested loop
The workflow is straightforward:
- Ask the agent to check Node and npm.
- Let the agent install
apidog-cli. - Verify with
apidog --version. - Generate an Apidog access token yourself.
- Authenticate without exposing the token to the agent.
- Run a first
apidog run. - Check the CLI output and exit code.
The result is more useful than a local install alone. Your API scenarios are no longer trapped behind a GUI. They can run from a terminal, in CI, or inside an agent’s edit-test-fix loop.
You still author and maintain scenarios visually in Apidog, but your agent and your pipeline can execute them automatically.
Next, wire the same command into CI with Apidog CLI in GitHub Actions, or read the full flag reference in the complete Apidog CLI guide.



Top comments (0)