> This page is for Postman Docs, version Latest (v12) (default).
> For other versions, use one of these documentation indexes:
> - Latest (v12) (default): https://learning.postman.com/latest-v-12/llms.txt
> - v11: https://learning.postman.com/v11/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Postman CLI dependency commands `(postman dependency)`

> Add, list, install, update, and remove package dependencies for your collections using dependency commands.

This topic covers dependency commands for the [Postman CLI](/docs/postman-cli/postman-cli-overview/).

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. When you add a collection, the command also adds the environments pinned to it.

The command prints progress messages, such as the element it's resolving, to stderr. Only the result goes to stdout.

### Usage

```bash
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

```bash
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

```bash
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

```bash
postman dependency list

postman dependency list --type collection
```

## `postman dependency get`

Shows a workspace dependency declared in your `.postman/resources.yaml` file. Identify the dependency by its cloud ID, display name, or on-disk name, as shown by `postman dependency list`.

### Usage

```bash
postman dependency get <nameOrId> [options]
```

**`<nameOrId>`**

The dependency to show, 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`.

---

**`--json`**

Prints the result as JSON for machine-readable output.

---

### Examples

```bash
postman dependency get Payments

postman dependency get 844951-51ea04bb-8d1a-439e-aa70-fe91852efcda

postman dependency get Prod --type environment --json
```

## `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

```bash
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

```bash
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

```bash
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

```bash
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

```bash
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

```bash
postman dependency remove "My Collection"

postman dependency remove Prod --type environment
```