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 a new SDK from a Postman collection or specification. This action downloads the generated SDKs and unzips them into the output directory or GitHub repo, if connected. If you encounter errors, see Generate commands errors and warnings.

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, or java

Target language(s) for SDK generation. Specify one or more languages for SDK generation: typescript, python, or java.

--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.

-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.

postman sdk list

The postman sdk list command lists builds for a specific collection. If you encounter errors, see List commands 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.

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, or java

Target language(s) for SDK generation. Specify one or more languages for SDK generation: typescript, python, or java.

--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.

Usage

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

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

Options

-l, --language <languages...>
typescript, python, or java

Target language(s) for SDK generation. Specify one or more languages for SDK generation: typescript, python, or java.

-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