Skip to navigation

Postman CLI globals commands (postman globals)

View as Markdown

This topic covers globals commands for the Postman CLI.

Global variables let you access and reuse a set of variables across an entire workspace, regardless of the active environment. You can use globals commands to validate your local global variables file before you push it to a Postman workspace.

postman globals get

Reads workspace globals and prints their variables. By default, it reads the local workspace globals file. Pass --workspace to read a Postman Cloud workspace’s globals instead.

Usage

postman globals get [options]

Options

-w, --workspace <workspaceId>

The ID of the Postman Cloud workspace to read globals from.

--workspace-path <path>
Defaults to current directory

The path to a local Postman workspace.

--json

Prints the result as JSON for machine-readable output.

--verbose

Prints more request and debug details.

Examples

postman globals get
postman globals get --workspace 12345678-90ab-cdef-1234-567890abcdef --json

postman globals var get

Reads the value of a single variable from workspace globals.

Usage

postman globals var get <key> [options]
<key>

The name of the variable to read.

Options

-w, --workspace <workspaceId>

The ID of the Postman Cloud workspace whose globals to read from.

--workspace-path <path>
Defaults to current directory

The path to a local Postman workspace.

--json

Prints the result as JSON for machine-readable output.

--verbose

Prints more request and debug details.

Examples

postman globals var get baseUrl
postman globals var get token --workspace 12345678-90ab-cdef-1234-567890abcdef

postman globals var set

Sets a variable in workspace globals, creating it if it doesn’t already exist.

Usage

postman globals var set <key> [value] [options]
<key>

The name of the variable to set.

[value]

The value to assign to the variable. Optional only when you pass --secret-id, which links the variable to a Shared Vault secret instead of an inline value.

Options

-w, --workspace <workspaceId>

The ID of the Postman Cloud workspace whose globals to update.

--secret-id <id>

Links this variable to a Shared Vault secret instead of an inline value. Use the secret ID from postman secret create’s output.

--vault-id <id>

The vault ID for --secret-id. Auto-resolved from --workspace when omitted. To set it explicitly, get it from postman secret list’s output.

--workspace-path <path>
Defaults to current directory

The path to a local Postman workspace.

--json

Prints the result as JSON for machine-readable output.

--verbose

Prints more request and debug details.

Examples

postman globals var set baseUrl https://api.example.com
postman globals var set apiToken --secret-id b8748ab8-d1bb-477f-95e2-78625adea75f --vault-id <vaultId>
postman globals var set baseUrl https://api.example.com --workspace 12345678-90ab-cdef-1234-567890abcdef

postman globals var unset

Removes a variable from workspace globals.

Usage

postman globals var unset <key> [options]
<key>

The name of the variable to remove.

Options

-w, --workspace <workspaceId>

The ID of the Postman Cloud workspace whose globals to update.

--workspace-path <path>
Defaults to current directory

The path to a local Postman workspace.

--json

Prints the result as JSON for machine-readable output.

--verbose

Prints more request and debug details.

Examples

postman globals var unset token
postman globals var unset token --workspace 12345678-90ab-cdef-1234-567890abcdef

postman globals lint

This command checks that a local global variables file is valid YAML and has the expected structure, field types, and required fields.

Usage

postman globals lint <path> [options]
<path>

Path to a global variables file or directory to lint.

Options

-o, --output <format>
Defaults to cli

Specifies the format of the lint results printed to the terminal. Accepted values are cli (human-readable output), table (a human-readable table), json, and csv. Results print to the terminal rather than saving to a file. To save the results, redirect the output to a file, for example --output json > results.json.

-f, --fail-severity <level>
Defaults to error

The command always lints everything and reports all issues. This option only sets the exit code, returning a failure code if any diagnostics are at this severity level or higher.

With error, the command returns a failure code only if errors are present. With warning, it returns a failure code whether warnings or errors are present. The failure code matters most in CI/CD, where it can stop the pipeline before invalid entities reach the cloud, or fail a pull request check.

Examples

postman globals lint ./postman/globals
postman globals lint ./postman/globals/workspace.globals.yaml --fail-severity warning
postman globals lint ./postman/globals/workspace.globals.yaml --output json