SDK CLI commands

View as Markdown

The Postman CLI enables you to generate, download, sync, list, and configure SDKs directly from your Postman entities. To use the commands, install the command-line companion for Postman. You can use it from your command line or Postman terminal.

postman sdk init

The postman sdk init command creates or updates the .postman/config.json file with your SDK configuration. For more information, see Create and manage the Postman SDK config file.

Usage

$postman sdk init [options]

Options

-y, --yes

Skip prompts and overwrite the existing Postman SDK config file.

-h, --help

Display help for the command.

postman sdk generate

The postman sdk generate command generates SDKs and CLIs from a Postman collection or specification. This action downloads the generated SDKs and CLIs and unzips them into the output directory or GitHub repo, if connected. If you encounter errors, see Generate commands errors and warnings.

The postman sdk generate command can also be used to regenerate an SDK. When you generate an SDK, the file hashes are written to a manifest file as change tracking is on by default. You can edit the generated files per your requirements—add, delete, or make changes to existing files—and then run the postman sdk generate command again. The CLI compares file hashes against the manifest to detect the changes and merges them to the regenerated SDK.

To use this command, sign in to Postman with the postman login command. Learn more about common authentication and authorization errors.

Usage

$postman sdk generate <id or path> [options]
<id or path>

One of the following:

  • A Postman Collection ID or Specification ID (UUID format).
  • A file path to a collection (.json) or specification (.json, .yaml, .yml) file.
  • A URL to a publicly accessible collection or specification file.

When using an ID, the SDK generation updates the version in Postman Cloud. The command automatically detects whether the ID is a collection or specification. Only UUIDs are supported (for example, 12345-abcde-67890 or 12345678-1234-1234-1234-123456789012). To get the collection or specification ID, in Postman, click Info icon Info in the right sidebar and copy the ID.

When using a file path or URL, the command creates a one-off build that doesn’t update the Postman Cloud version.

Options

-l, --language <languages...>
typescript, python, java, kotlin, csharp, go, php, ruby, rust, or cli

Target output(s) for SDK and CLI generation. Specify one or more outputs: typescript, python, java, kotlin, csharp, go, php, ruby, rust, or cli.

--all

Generate SDKs in all supported languages.

-o, --output-dir <path>
Defaults to ./sdks

Select the directory to save the downloaded SDKs.

--name <name>

Select the name for the generated SDK package.

--sdk-version <version>
Defaults to 1.0.0

Select the version number for the generated SDK.

--config <path>
Defaults to .postman/config.json

Path to the SDK generation config file (JSON).

-y, --yes

Skip prompts and overwrite the existing Postman SDK config file.

--verbose

Show detailed generation progress and logs.

--pr

Create a pull request to the GitHub SDK output repo with the generated SDK.

--no-track-changes

Turn off change tracking.

--no-merge

Skip merge even if edits are detected and force a clean regeneration of the SDK that overwrites all files.

--conflict-strategy <strategy>
mark, ours, or theirs

Control how the generator handles merge conflicts when you and the generator change the same lines in a file with one of these choices: mark adds conflict markers to the file, ours keeps your changes and discards the generator’s changes, and theirs keeps the generator’s changes and discards yours.

-h, --help

Display help for the command.

Examples

Generate a TypeScript SDK from a collection ID

$postman sdk generate 12345-abcde-67890 --language typescript --output-dir ./my-sdk

Generate a TypeScript SDK from a specification ID

$postman sdk generate 67890-fghij-12345 --language typescript --output-dir ./my-sdk

Generate a one-off SDK build from a collection file

$postman sdk generate ./my-collection.json -l typescript -o ./my-sdk

Generate a one-off SDK build from a specification file

$postman sdk generate ./openapi.yaml -l typescript -o ./my-sdk

Generate a one-off SDK build from a publicly accessible URL

$postman sdk generate https://petstore.swagger.io/v2/swagger.json -l typescript -o ./my-sdk

Generate SDKs in TypeScript and Python

$postman sdk generate 12345-abcde-67890 -l typescript python -o ./sdks

Generate SDKs in all supported languages

$postman sdk generate 12345-abcde-67890 --all -o ./sdks

Generate and auto-overwrite the existing SDKs

$postman sdk generate 12345-abcde-67890 -l typescript --yes -o ./sdks

Verbose generation

$postman sdk generate 12345-abcde-67890 -l java --verbose

Show detailed generation progress and logs

$postman sdk generate 12345-abcde-67890 -l java --verbose

Generate and push an SDK build to your repo

$postman sdk generate 12345-abcde-67890 -l python --pr

You must connect your GitHub repo to be able to push your SDK builds to it.

Generate a CLI from a collection ID

$postman sdk generate 12345-abcde-67890 --language cli --output-dir ./my-cli

Generate a CLI from a specification ID

$postman sdk generate 67890-fghij-12345 --language cli --output-dir ./my-cli

Regenerate an SDK with change tracking turned off

$postman sdk generate <id> -l typescript --no-track-changes

Regenerate an SDK with merge skipped

$postman sdk generate <id> -l typescript --no-merge

Regenerate an SDK with a specific conflict strategy

$postman sdk generate <id> -l typescript --conflict-strategy mark

postman sdk track

The postman sdk track command initializes change tracking for an SDK generated before this feature was available. It computes file hashes and writes them into the existing manifest file. After you run this command, the next time you regenerate an SDK, the CLI detects any changes you made in the generated files and merges them to the regenerated SDK. You must run this command before you make any edits or your changes are lost.

To use this command, sign in to Postman with the postman login command. Learn more about common authentication and authorization errors.

Usage

$postman sdk track <languages> [options]

Options

-l, --language <languages...>
typescript, python, java, kotlin, csharp, go, php, ruby, or cliRequired

Target output(s) for SDK and CLI generation. Specify one or more outputs: typescript, python, java, kotlin, csharp, go, php, ruby, or cli.

-o, --output-dir <path>
Defaults to ./sdks

Select the directory to save the downloaded SDKs.

-h, --help

Display help for the command.

Examples

Turn on tracking for a TypeScript SDK

$postman sdk track -l typescript

Turn on tracking for SDKs in multiple languages

$postman sdk track -l typescript python

Turn on tracking for a custom output directory

$postman sdk track -l typescript -o ./my-sdks

postman sdk list

The postman sdk list command lists builds for a specific collection. If you encounter errors, see List commands errors.

To use this command, sign in to Postman with the postman login command. Learn more about common authentication and authorization errors.

Usage

$postman sdk list|ls <collectionId> [options]
<collectionId>

Postman Collection ID in the 12345-abcde-67890 format.

Options

-s, --status <status>
IN_PROGRESS, SUCCESS, or FAILURE

Filter builds by status with one of these choices: IN_PROGRESS, SUCCESS, or FAILURE.

-o, --output <format>
json or tableDefaults to table

Select the output format with one of these choices: json or table.

-h, --help

Display help for the command.

Examples

List all builds for a collection

$postman sdk list 12345-abcde-67890

List only successful builds

$postman sdk list 12345-abcde-67890 --status SUCCESS

List in-progress builds

$postman sdk list 12345-abcde-67890 --status in-progress

List failed builds

$postman sdk list 12345-abcde-67890 --status failure

Output as JSON

$postman sdk list --output json

postman sdk fetch

The postman sdk fetch command lets you download previously generated SDKs from a build by its ID, so that you can retrieve and use them locally. If you encounter errors, see Get/Fetch commands errors.

To use this command, sign in to Postman with the postman login command. Learn more about common authentication and authorization errors.

Usage

$postman sdk fetch|get|download <buildId> [options]

Options

-o, --output-dir <path>
Defaults to ./sdks

Select the directory to save the downloaded SDKs.

-l, --language <languages...>
typescript, python, java, kotlin, csharp, go, php, ruby, or rust

Target language(s) for SDK generation. Specify one or more languages for SDK generation: typescript, python, java, kotlin, csharp, go, php, ruby, or rust.

--overwrite

Overwrite existing files without confirmation.

--verbose

Show detailed generation progress and logs.

-h, --help

Display help for the command.

Examples

Download SDKs from a build

$postman sdk get 12345

Download SDKs to a specific directory

$postman sdk fetch 12345 --output-dir ./my-sdks

Overwrite the existing files

$postman sdk download 12345 --overwrite

Download SDKs in a specific language

$postman sdk fetch 12345 --language typescript

Download SDKs in several languages

$postman sdk fetch 12345 --l java typescript

postman sdk connect github

The postman sdk connect github command creates a Git integration that allows you to sync your generated SDK with your GitHub repo. If you encounter errors, see Connect commands errors.

Learn how to generate an SDK in a specific language and sync it with your GitHub project.

To use this command, sign in to Postman with the postman login command. Learn more about common authentication and authorization errors.

Usage

$postman sdk connect github <collectionId> [options]
<collectionId>

Postman Collection ID in the 12345-abcde-67890 format.

Options

-l, --language <languages...>
typescript, python, java, kotlin, csharp, go, php, ruby, or rust

Target language(s) for SDK generation. Specify one or more languages for SDK generation: typescript, python, java, kotlin, csharp, go, php, ruby, or rust.

-w, --workspace <workspaceId>

If the system is unable to identify the workspace the collection is tied to, pass a workspace ID.

-h, --help

Display help for the command.

Examples

Connect a collection with a TypeScript SDK output

$postman sdk connect github 12345-abcde-67890 --language typescript

Connect with a specific workspace

$postman sdk connect github 12345-abcde-67890 -l python -w my-workspace-id