Skip to navigation
Postman CLIWorkspace elements

Postman CLI dependency commands (postman dependency)

View as Markdown

This topic covers dependency commands for the Postman CLI.

Workspace dependencies let you reuse a collection, environment, or mock from another workspace in your local project.

postman dependency add

Adds a collection, environment, or mock from another workspace as a dependency of your local project, so you can reuse it. The command copies the element into your project’s postman/.dependencies/ directory and records it in your .postman/resources.yaml file.

Usage

postman dependency add <type> <nameOrId> [options]
<type>
'collection' | 'environment' | 'mock'

The type of element to add as a dependency: collection, environment, or mock.

<nameOrId>

The name or ID of the element to add.

Options

-w, --workspace <id>

The ID of the workspace the dependency comes from. Defaults to the current workspace.

-y, --yes

Skips all confirmation prompts.

--json

Prints the result as JSON for machine-readable output.

Examples

postman dependency add collection "My Collection" --workspace 12345678-90ab-cdef-1234-567890abcdef
postman dependency add environment 123456-1b4d90f0-b724-4aa2-b1bb-b5d4f6435fc3

postman dependency list

Lists the workspace dependencies declared in your .postman/resources.yaml file.

Usage

postman dependency list [options]

Options

--type <type>
'collection' | 'environment' | 'mock'

Lists only dependencies of the given type. The supported types are collection, environment, and mock.

--json

Prints the result as JSON for machine-readable output.

Examples

postman dependency list
postman dependency list --type collection

postman dependency install

Fetches the dependencies declared in your .postman/resources.yaml file into your local project, so it has the collections, environments, and mocks it depends on. Run it after cloning a project or in CI, much like the npm install step of a Node.js project. Run it with no argument to install every declared dependency, or name one dependency to install only that one.

Usage

postman dependency install [nameOrId] [options]
[nameOrId]

The dependency to install, given as its cloud ID, display name, or on-disk name, as shown by postman dependency list. Omit it to install every declared dependency.

Options

--type <type>
'collection' | 'environment' | 'mock'

Installs only dependencies of the given type. The supported types are collection, environment, and mock.

--json

Prints the result as JSON for machine-readable output.

Examples

postman dependency install
postman dependency install Payments

postman dependency update

Refreshes declared dependencies to the latest content from their source. For each dependency, it fetches the latest version of the cloud entity and overwrites its local files in place. Run it with no argument to update every declared dependency, or name one dependency to update only that one.

Usage

postman dependency update [nameOrId] [options]
[nameOrId]

The dependency to update, given as its cloud ID, display name, or on-disk name, as shown by postman dependency list. Omit it to update every declared dependency.

Options

--type <type>
'collection' | 'environment' | 'mock'

Updates only dependencies of the given type. The supported types are collection, environment, and mock.

--json

Prints the result as JSON for machine-readable output.

Examples

postman dependency update
postman dependency update --type environment

postman dependency remove

Removes a workspace dependency and deletes its local files. Identify the dependency by its cloud ID, display name, or on-disk name, as shown by postman dependency list. Removing a collection also removes the environments pinned to it, unless another collection pins them too. The command prompts for confirmation unless you pass --yes, which is required when you run the command outside an interactive terminal.

Usage

postman dependency remove <nameOrId> [options]
<nameOrId>

The dependency to remove, given as its cloud ID, display name, or on-disk name.

Options

--type <type>
'collection' | 'environment' | 'mock'

Matches only dependencies of the given type. The supported types are collection, environment, and mock.

-y, --yes

Skips the confirmation prompt. Required when you run the command outside an interactive terminal or with --json.

--json

Prints the result as JSON for machine-readable output.

Examples

postman dependency remove "My Collection"
postman dependency remove Prod --type environment