SDK CLI commands

View as Markdown

The Postman CLI provides commands for generating client SDKs from Postman Collections and API specifications, and for managing server-side GitHub connections that automatically open or update pull requests on every successful build. 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 client SDK from a Postman Collection or API specification. The source can be a Postman entity ID (runs a server-side build), a local file path, or a URL (one-off builds). If you encounter errors, see Generate commands errors and warnings.

When an entity ID is used and a GitHub connection exists (see postman sdk connect), the server automatically opens or updates a pull request after every successful build.

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]

Arguments

Provide one of the following arguments:

<id>

Postman Collection ID or Specification ID (UUID format).

<path>

File path to a collection (.json) or specification (.json, .yaml, .yml) file.

<url>

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 configuration file (JSON).

-y, --yes

Skip prompts and overwrite the existing Postman SDK configuration file.

--overwrite

Overwrite existing files without confirmation.

--verbose

Show detailed generation progress and logs.

--log-level <level>
warn or infoDefaults to warn

Set the build log detail level. warn shows warnings and errors inline. info expands all log entries.

--no-track-changes

Turn off change tracking. By default, file hashes are written into .manifest.json to enable edit detection on the next regeneration.

--no-merge

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

--conflict-strategy <strategy>
mark, ours, or theirsDefaults to mark

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.

--no-emit

Skip downloading and saving the generated SDK files to the output directory. This is useful in CI when the build only needs to trigger server-side pull requests.

-h, --help

Display help for the command.

Examples

Generate a TypeScript SDK from a collection ID

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

Generate a Python SDK from a specification ID

$postman sdk generate 67890-fghij-12345 -l python --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

Trigger a server-side build and PR without downloading artifacts

$postman sdk generate 12345-abcde-67890 -l typescript --no-emit --yes

You must connect your GitHub repo to trigger server-side builds that automatically open or update pull requests.

Generate a CLI from a collection ID

$postman sdk generate 12345-abcde-67890 -l 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 connects a Postman Collection or API specification to a GitHub repository. Once a connection exists, every successful postman sdk generate build (by ID) automatically opens or updates a pull request in the target repository.

By default, the server pushes through the installed Postman GitHub App (--auth-provider githubapp). If the server returns an auth error, install the GitHub App from your Postman workspace settings.

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 <provider> <id> [options]
<collectionId>

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

Arguments

<provider>
Required

OAuth provider (only github).

<id>
Required

Postman Collection ID or specification ID (UUID).

Options

-l, --language <language>
typescript, python, java, go, csharp, ruby, php, kotlin, or rustRequired

SDK language.

-r, --repo <owner/name>

GitHub repository in <owner>/<name> form (alternative to --repo-owner + --repo-name).

--repo-owner <owner>

GitHub repository owner (user or org).

--repo-name <name>

GitHub repository name.

-b, --branch <branch>
Defaults to main

Target branch for SDK pull requests.

--push-to-base

Push SDK updates directly to the base branch instead of opening a pull request.

--enable-npm-publishing

Inject a GitHub Actions workflow that publishes to npm on merge (TypeScript only).

--auth-provider <provider>
githubapp or githubDefaults to githubapp

OAuth provider used by the server when pushing.

--verbose

Show extra logging.

-h, --help

Display help for the command.

Examples

Connect a collection to a GitHub repo for TypeScript SDK PRs

$postman sdk connect github 12345-abcde-67890 --language typescript --repo my-org/my-sdk

Connect a specification using a non-default branch

$postman sdk connect github 67890-fghij-12345 -l python --repo my-org/python-sdk --branch develop

Push SDK updates to base instead of opening a PR

$postman sdk connect github 12345-abcde-67890 -l java --repo my-org/java-sdk --push-to-base

postman sdk connections list

Use the singular postman sdk connect github command to create a GitHub connection. Use the plural postman sdk connections command group to list or delete existing connections.

The postman sdk connections list command lists all GitHub connections for a given collection or specification. Shows language, target repo, branch, and latest PR status for each connection.

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

Usage

$postman sdk connections list <id> [options]

Arguments

<id>
Required

Collection ID or Specification ID (UUID).

Options

--refresh

Refresh PR statuses from GitHub before listing.

--json

Output raw JSON instead of formatted text.

--verbose

Show extra logging.

-h, --help

Display help for the command.

Examples

List connections for a collection

$postman sdk connections list 12345-abcde-67890

Refresh PR statuses from GitHub before listing

$postman sdk connections list 12345-abcde-67890 --refresh

Output raw JSON for scripting

$postman sdk connections list 12345-abcde-67890 --json

postman sdk connections delete

The postman sdk connections delete command deletes a GitHub connection by its numeric connection ID.

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

Usage

$postman sdk connections delete <id> <connectionId> [options]

Arguments

<id>
Required

Collection ID or Specification ID (UUID).

<connectionId>
Required

Numeric connection ID to delete (shown in connections list output).

Options

-y, --yes

Skip the confirmation prompt.

--verbose

Show extra logging.

-h, --help

Display help for the command.

Examples

Delete connection 42 with a confirmation prompt

$postman sdk connections delete 12345-abcde-67890 42

Delete connection 42 without a confirmation prompt

$postman sdk connections delete 12345-abcde-67890 42 --yes