The VS Code extension runs the same command from the editor, so a local run matches CI.
Exit codes
| Code | Meaning |
|---|---|
| 0 | every request and check passed |
| 1 | a check, a script or an MCP tool call failed, or the run was interrupted |
| 2 | the command or the input is wrong |
| 3 | a request got no response: it could not be sent, the connection failed or timed out |
A run with both kinds of failure exits 3.
A 4xx or 5xx status alone is not a failure. Add a check such as res.status equals 200 to the request.

Secrets
Keep secrets out of the collection. Map them to variables from the job environment:
gostman run api --env CI --var-from-env API_TOKEN --redact--redact replaces the secret values in the report with {{name}}: variables marked secret or with a sensitive name (such as token, password or api_key), values from a secret manager, --var-from-env and --env-file, OAuth 2 tokens, credentials and cookies. Ordinary values such as baseUrl stay readable, so the URL each request was sent to shows in every report. A value passed with --var is not treated as secret. HTML reports include each request and response body, and so does a JSON report written in the same run as an HTML one, so redact before sharing them, and remember that a body can hold other private data that is not a variable.
Passing a value between commands
Requests that depend on each other belong in one gostman run, where a login's token reaches the next request without ever being printed. When a script needs the value itself, gostman send prints it only with --reveal:
TOKEN=$(gostman send --workspace api Login --select '$.token' --var-from-env PASSWORD --reveal)
echo "::add-mask::$TOKEN"--reveal prints secrets in plain text, so mask the value in the job log (as above on GitHub Actions) and never echo it. Without --reveal the output shows {{token}}.
Reports
| Flag | Result |
|---|---|
--reporter text |
readable summary on stdout (default) |
--reporter junit --output report.xml |
JUnit XML for test dashboards; each request is a test suite whose system-out starts with the method and the URL as sent |
--reporter json --output report.json |
machine-readable results; each result has the URL as written (url) and as sent (resolvedUrl, secrets shown as {{name}}) |
--reporter html --output report.html |
one self-contained page, with a filter for failures |
--reporter markdown --output summary.md |
the counts and every failed check as Markdown, for a job summary or a pull request comment |
With --output, the report goes to the file and the text summary is still printed.
To write several reports in one run, repeat --reporter as format:file:
gostman run api --reporter text --reporter junit:report.xml --reporter html:report.htmlAt most one reporter can go without a file, and it prints to stdout. When every report goes to a file, the text summary is printed.

Contract checks
--contract checks every response against an OpenAPI spec, so a changed status code, a new content type or a field that became null fails the job even when no assertion covers it:
gostman run api --env CI --contract openapi.yaml --reporter junit:report.xmlContract checks appear with the other checks in every report format; in JUnit XML each check is a test case. See Contract checks for what is compared.
Proxies and certificates
Behind a corporate proxy or in front of an API that needs a client certificate, pass the files to run, send or load:
gostman run api --cacert corp-ca.pem --client-cert client.pem --client-key client-key.pem \
--proxy http://proxy.corp.example:3128 --noproxy localhost,*.internal.example.com| Flag | Effect |
|---|---|
--cacert <file> |
trusts the PEM or DER certificates in the file as well as the system's (repeatable) |
--client-cert <file> --client-key <file> |
presents this PEM certificate to every host |
--client-cert <file> |
presents a PFX/P12 file, or a PEM file that holds the key, to every host |
--client-cert <host>=<cert>,<key> or <host>=<file.p12> |
presents it to that host only; *.example.com covers subdomains (repeatable) |
--client-cert-pass-env <NAME> |
reads the passphrase of encrypted keys and PFX/P12 files from this environment variable |
--proxy <url> |
sends through this http, https or socks5 proxy |
--noproxy <hosts> |
comma-separated hosts that skip --proxy |
Without --proxy, the HTTPS_PROXY, HTTP_PROXY and NO_PROXY variables of the job are used. gRPC, OAuth 2 token requests and sendRequest in scripts go through the same proxy and certificates. A workspace's network section in gostman.yaml applies too, and the flags win over it. Write certificates from CI secrets to files at the start of the job, keep the passphrase in a secret variable, and pass its name: --client-cert client.p12 --client-cert-pass-env CLIENT_CERT_PASSPHRASE. A missing file, a file that is not a certificate, or a wrong or missing passphrase exits 2 before anything is sent.
GitHub Actions
The composite action at the root of this repository installs the CLI and runs a collection.
name: API tests
on: [push, pull_request]
jobs:
api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: kunalgoesbyken/gostman@main
with:
collection: api
environment: CI
reporter: junit
output: report.xml
extra-args: --var-from-env API_TOKEN
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: gostman-report
path: report.xmlPin the action to a release tag or a commit once you depend on it. Inputs: collection, version, environment, folder, data, reporter, output, redact, bail, extra-args, summary, comment, github-token. Outputs: exit-code, report. The step fails when the exit code is not 0, so use if: always() on steps that publish the report.
Job summary and pull request comment
The action adds the counts and every failed check to the job summary, so a failure can be read on the run page without opening the log. Set summary: false to leave it out.
With comment: true, a run on a pull request posts the same results as one comment, with a link to the job log. Later runs edit that comment instead of adding new ones; each combination of workflow, job, collection, environment and folder keeps its own. The job needs permission to write to pull requests:
on: pull_request
permissions:
contents: read
pull-requests: write
jobs:
api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: kunalgoesbyken/gostman@main
with:
collection: api
environment: CI
comment: truePull requests from forks get a read-only token, so the comment is skipped with a warning and the job summary still shows the results. Both need gostman 1.14.0 or later; with version set to an older release they are skipped. Names, statuses and check messages appear as written, so keep redact on, which is the default.
Without the action:
- run: |
curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
tar -xzf gostman.tar.gz
./gostman run api --env CI --var-from-env API_TOKEN --reporter junit --output report.xml
env:
API_TOKEN: ${{ secrets.API_TOKEN }}Run against the mock server
To run the collection without reaching the real API, serve its saved examples with gostman mock and point an environment at it. examples/todo-api has an example for every request and a Mock environment whose baseUrl is http://127.0.0.1:4010:
- run: |
curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
tar -xzf gostman.tar.gz
./gostman mock examples/todo-api --port 4010 > mock.log 2>&1 &
curl --silent --fail --retry 20 --retry-connrefused --retry-delay 1 -o /dev/null http://127.0.0.1:4010/todos/1
./gostman run examples/todo-api --env Mock --reporter junit --output report.xmlgostman mockruns until it is stopped, so&starts it in the background. The runner stops it when the job ends.- The
curlline waits until the mock answers one of its routes. Without it, the first requests can fail while the mock is still starting. - The action runs the collection as soon as it has installed the CLI, so this recipe downloads the CLI itself.
- The mock listens on
127.0.0.1only and refuses otherHostheaders. Start it in the same job asgostman run, not in a service container. mock.loglists every request the mock answered. Upload it with the report when a run fails.
An example can echo what the request sent, as Create a todo does with {{request.body.json.title}}, so checks that compare against variables and runs with --data pass against the mock too. A run against the mock tests the collection, its scripts and its checks, not the API. To test your own service without its dependencies, mock the API it calls, start the service pointed at the mock, then run the collection against the service. Templating and the other mock options are in Folders, mock server and capture.
Scheduled runs and cron
A monitor is a run that repeats, and there are two ways to schedule it.
- A CI schedule or cron starts a new
gostman runeach time: ascheduletrigger in GitHub Actions, a scheduled pipeline in GitLab, or a crontab line. Each run is a clean process, the CI system keeps the logs and shows failures, and nothing has to stay running. This suits checks every 5 to 60 minutes and anything that must run when your own machine is off. --everykeeps one process running and repeats the run, with a one-line result each time, a run history and an optional webhook message. It suits a server, a container or a terminal on a machine that stays on, and intervals down to a second.
gostman run orders-api --env Production --every 5m --notify-env SLACK_WEBHOOKThe desktop and web apps have a Monitors dialog that does the same while the app or tab is open, with a chart of the history; it is meant for watching a collection during the day, not for checks that must run when your computer is off.
Run it under whatever restarts it, such as a systemd unit or docker run --restart unless-stopped. For cron, a crontab line such as */15 * * * * gostman run /srv/orders-api --env Production --var-from-env API_TOKEN --record --notify-env SLACK_WEBHOOK runs it every fifteen minutes and saves each run to the history; with cron, --notify sends a message for every failing run, because each run is a new process that does not know the last result. In a CI job, --record writes into the checkout of that job, which is discarded unless you upload .gostman/runs/.
GitLab CI
api-tests:
image: alpine:3.20
before_script:
- apk add --no-cache curl
- curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
- tar -xzf gostman.tar.gz
script:
- ./gostman run api --env CI --var-from-env API_TOKEN --reporter junit --output report.xml
artifacts:
when: always
reports:
junit: report.xmlSet API_TOKEN as a masked CI/CD variable.
Catching breaking API changes
gostman diff exits 1 on a breaking change when --fail-on breaking is set, so a pull request check can compare the spec against the one on the main branch:
git show origin/main:openapi.yaml > old.yaml
gostman diff old.yaml openapi.yaml --fail-on breakingSee Comparing two OpenAPI specs.
Azure Pipelines
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- script: |
curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
tar -xzf gostman.tar.gz
displayName: Install Gostman
- script: ./gostman run api --env CI --var-from-env API_TOKEN --reporter junit --output report.xml
displayName: Run collection
env:
API_TOKEN: $(API_TOKEN)
- task: PublishTestResults@2
condition: always()
inputs:
testResultsFormat: JUnit
testResultsFiles: report.xmlDefine API_TOKEN as a secret pipeline variable and map it in env, since Azure does not expose secret variables to scripts otherwise.
CircleCI
version: 2.1
jobs:
gostman:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: Install Gostman
command: |
curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
tar -xzf gostman.tar.gz
- run:
name: Run collection
command: ./gostman run api --env CI --var-from-env API_TOKEN --reporter junit --output test-results/gostman/report.xml
- store_test_results:
path: test-results
workflows:
api:
jobs:
- gostmanAdd API_TOKEN to the project's environment variables.
Bitbucket Pipelines
image: alpine:3.20
pipelines:
default:
- step:
name: Gostman
script:
- apk add --no-cache curl
- curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
- tar -xzf gostman.tar.gz
- ./gostman run api --env CI --var-from-env API_TOKEN --reporter junit --output test-results/report.xmlAdd API_TOKEN as a secured repository variable. Bitbucket reads JUnit files under test-results as test reports.
Makefile
GOSTMAN ?= ./gostman
gostman:
curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
tar -xzf gostman.tar.gz
api-test: gostman
$(GOSTMAN) run api --env CI --var-from-env API_TOKEN --reporter junit --output report.xml
api-lint:
$(GOSTMAN) lint openapi.yaml
api-scan:
$(GOSTMAN) scan apiStarter pipelines and pre-commit
gostman init api --ci github|gitlab|azure|circleci|bitbucket creates the workspace (as gostman init does) and writes a starter pipeline for that service in the current folder, running the workspace with a JUnit report; the GitHub one also comments on pull requests. The files are .github/workflows/gostman.yml, .gitlab-ci.yml, azure-pipelines.yml, .circleci/config.yml and bitbucket-pipelines.yml. A file that already exists is left as it is and the command says so.
The repository root has a pre-commit configuration for the hooks gostman-lint, gostman-scan and gostman-run. They call the gostman binary on your PATH, so install the CLI first.
repos:
- repo: https://github.com/kunalgoesbyken/gostman
rev: main
hooks:
- id: gostman-lint
- id: gostman-scan
args: [api]Pin rev to a release tag. gostman-lint runs on files named like openapi.yaml or swagger.json, gostman-scan and gostman-run take the workspace folder in args, and gostman-run sends real requests, so use it on a pre-push stage rather than at every commit.
Jenkins
pipeline {
agent any
environment {
API_TOKEN = credentials('api-token')
}
stages {
stage('API tests') {
steps {
sh '''
curl -fsSL -o gostman.tar.gz https://github.com/kunalgoesbyken/gostman/releases/latest/download/gostman-cli-linux-amd64.tar.gz
tar -xzf gostman.tar.gz
./gostman run api --env CI --var-from-env API_TOKEN --reporter junit --output report.xml
'''
}
}
}
post {
always {
junit 'report.xml'
}
}
}A non-zero exit code fails the stage, and post { always } still publishes the results.
Docker
New releases publish ghcr.io/kunalgoesbyken/gostman for linux/amd64 and linux/arm64, tagged with the version and latest; pin the version tag in pipelines. It holds a static gostman in a distroless image that runs as a non-root user. No secrets are baked in.
docker run --rm -v "$PWD:/workspace" -e API_TOKEN ghcr.io/kunalgoesbyken/gostman run api --env CI --var-from-env API_TOKENThe Dockerfile at the root of the repository builds the same image with docker build -t gostman .. gostman version then prints dev; add --build-arg VERSION=<version> to set it.
The container works in /workspace. The mounted folder must be readable by the image user (uid 65532), and writable if reports are written there. The image has no shell, so pass the arguments to gostman directly, as docker run does above. It cannot be the job image of a GitLab CI job, because GitLab runs script: lines in a shell; use the GitLab CI recipe there.