← Back to Overview

CLI

CLI Overview

Install and use the openpost CLI to run collections, manage environments, import/export, and integrate with CI/CD pipelines.

Installation

Install globally via npm (recommended):

npm install -g openpost

Or run without installing via npx:

npx openpost --help
Requires Node.js 18+
Verify installation: openpost --version

How It Works

The CLI reads the same .openpost/ files as the VS Code extension. No separate setup — if the extension works, the CLI works.

Operates on the current directory (or --workspace path)
Supports both local and global scopes
All operations are fully offline — no cloud dependency

Global Options

These flags can be used with any command:

OptionDescription
--workspace <path>Project directory (defaults to current directory)
--env <name>Active environment to use for variable resolution
--jsonForce JSON output (machine-readable)
--verboseFull request/response details in output
--dry-runValidate without sending (check config and interpolation)
--filter <pattern>Glob filter for requests (e.g. 'GET*', '*users*')
--retry <n>Retry failed requests n times
--output-file <path>Save results to a file
--ssl-offDisable SSL verification
--proxy <name>Use a named proxy profile

Commands Summary

All available CLI commands:

CommandDescription
openpost run <collection>Run all requests in a collection
openpost list collections|requests|environmentsList resources
openpost import curl|openapi <input>Import from cURL or OpenAPI spec
openpost export curl|openapi <collection> [request]Export to formats
openpost env set|addManage environments
openpost vault create|unlock|add-secret|list-secretsVault operations
openpost proxy add|set-defaultProxy management
openpost serveStart MCP server headlessly
openpost license activate|statusLicense management

Exit Codes

Use exit codes to integrate with CI/CD pipelines:

CodeMeaning
0Success — all requests passed, all tests passed
1Failure — one or more requests or tests failed
2Error — bad arguments, resource not found, or config error
CI/CD tip: Exit code 1 fails the build pipeline on test failures — use openpost run "My API" --env prod as a pipeline step.

Programmatic API (Node.js)

Use the openpost package directly in Node.js scripts, test frameworks (Jest, Mocha), or custom automation:

import { OpenPost } from 'openpost';

const op = new OpenPost({ workspace: '/path' });

// Run all requests in a collection
await op.runCollection('My API', { env: 'prod', mode: 'sequential' });

// Run a single request
await op.runRequest('My API', 'Get Users', { env: 'prod' });

await op.dispose();

Use in test frameworks (Jest, Mocha) or custom scripts. The programmatic API uses the same execution pipeline as the extension — auth, scripts, cookies, test rules, and variable interpolation all apply.

Next

Ko-fi