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 --versionHow 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:
| Option | Description |
|---|---|
| --workspace <path> | Project directory (defaults to current directory) |
| --env <name> | Active environment to use for variable resolution |
| --json | Force JSON output (machine-readable) |
| --verbose | Full request/response details in output |
| --dry-run | Validate 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-off | Disable SSL verification |
| --proxy <name> | Use a named proxy profile |
Commands Summary
All available CLI commands:
| Command | Description |
|---|---|
| openpost run <collection> | Run all requests in a collection |
| openpost list collections|requests|environments | List resources |
| openpost import curl|openapi <input> | Import from cURL or OpenAPI spec |
| openpost export curl|openapi <collection> [request] | Export to formats |
| openpost env set|add | Manage environments |
| openpost vault create|unlock|add-secret|list-secrets | Vault operations |
| openpost proxy add|set-default | Proxy management |
| openpost serve | Start MCP server headlessly |
| openpost license activate|status | License management |
Exit Codes
Use exit codes to integrate with CI/CD pipelines:
| Code | Meaning |
|---|---|
| 0 | Success — all requests passed, all tests passed |
| 1 | Failure — one or more requests or tests failed |
| 2 | Error — 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.