TOPIC 59/6216 MINNOT STARTED

Postman: variables, scripts and running a collection from the command line

Make one collection work for many servers and many sets of data. Learn variable scopes, pre-request and test scripts, the collection runner and Newman.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: a radio with presets. A radio has buttons for your stations. Press one and it tunes in at once. Change the preset and the same button plays a new station.

You do not rebuild the radio.

Variables are the presets. Tom, the tester at Daily List, a to-do list app, changes one setting and the same requests run on a new server. The goal is one collection that works on any server, with any data, without editing each request.

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB A radio with preset buttons.

  1. Set
  2. Run
  3. Report
Radio

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The preset buttonsVariables
Changing a presetSwitching the environment
A song list for the eveningA data file
The radio itselfThe collection

WHERE THIS PICTURE STOPS

  • A radio has a few presets, but a collection can hold hundreds of values.
  • A preset is chosen by hand, but a script can set a value.
  • A radio plays one station, but a runner plays every request.

HOOK

Presets, a song list, one press.

TELL A FRIEND

A radio with presets: change the button, not the radio.

OFTEN MIXED UP WITH Postman: a first collection of API checks. That topic builds the first collection. This one makes it reusable and runs it from a pipeline.

PRACTISE AND KEEP

Sources for this topic — 5 sources
  1. Market practice

    Store and reuse values using variables (Postman docs) ↗ — Postman · Postman docs: variable scopes run from global through collection, environment and data to local, and the narrowest scope wins when a name appears twice (search excerpt, page not opened)

    Postman documentation on variable scopes, from broadest to narrowest, and which value wins. Vendor documentation. Practitioner guidance, not a standard. · Checked 2026-11-06

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

    Verification supplement, 6 November 2026: Actual current v12 page opened: global/collection/environment/data/local scope precedence; local variable value distinct from local scope; shared values used by some cloud features. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.

  2. Market practice

    Write pre-request scripts to add dynamic behavior (Postman docs) ↗ — Postman · Postman docs: a pre-request script runs before a request is sent, for example to set variable values, and a collection-level script runs before every request in it (search excerpt, page not opened)

    Postman documentation on scripts that run before a request is sent. Vendor documentation. Practitioner guidance, not a standard. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    Write scripts to test API response data (Postman docs) ↗ — Postman · Postman docs: test scripts run after the response arrives and check things such as status, structure and field values (search excerpt, page not opened)

    Postman documentation on test scripts that check a response. Vendor documentation. Practitioner guidance, not a standard. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Newman CLI Overview — Postman documentation Latest (v12) ↗ — Postman · Latest(v12)NewmanCLIOverview:legacycollectionv2.1JSON,no further updates/fixes,currentPostmanCLI supportsv3;record runner/collection versions (relevant primary passages opened6November2026).

    Current vendor page opened: Newman supports collectionv2.1 JSON, not current collectionv3; no further updates or fixes. Postman CLI handles v3. Legacy exercises explicitly retain compatible v2.1 files. · Checked 2026-11-06

    Opened relevant primary passages on6November2026 via normal web search and document view. Current vendor page opened: Newman supports collectionv2.1 JSON, not current collectionv3; no further updates or fixes. Postman CLI handles v3. Legacy exercises explicitly retain compatible v2.1 files.

  5. Market practice

    Store and reuse values using variables (Postman docs) ↗ — Postman · Postman current v12 variables: scope precedence global→collection→environment→data→local; local value differs from temporary local scope (actual relevant primary passages opened 6 November 2026).

    Postman documentation on variable scopes, from broadest to narrowest, and which value wins. Vendor documentation. Practitioner guidance, not a standard. · Checked 2026-11-06

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

    Verification supplement, 6 November 2026: Actual current v12 page opened: global/collection/environment/data/local scope precedence; local variable value distinct from local scope; shared values used by some cloud features. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.