You've sent a request. Now you'll make it reusable with variables, let Agent Mode add tests for you, and see your data come to life. Each step builds on the last — finish one before moving on.
Learn more: Variables, Agent Mode, Postman Visualizer
Store Your Destination in a Variable
Right now your country is hard-coded in the request. A variable lets you change the destination without editing the request each time. This lesson uses collection variables (scoped to the collection) rather than an environment — a different approach than in API Basics.
- In the left sidebar, click Country Dossier (the collection name itself, not a request inside it) — it opens in a tab.
- In that tab, select Variables.
- Add a variable named
country. If you don't see a Shared Value column, click the ⋯ menu at the far right of the variables table header, then under Show as column, check Shared Value. - In the Shared Value column, enter your country (e.g.
Bangladesh). - Back in Get Country, open the Params tab. In the Query Params table, leave Key as
nameand change Value from your country (e.g.Bangladesh) to{{country}}. - Save the request (Ctrl/Cmd+S).
LiftOff tip: Enter your country in Shared Value, not the local Value column — LiftOff validates via the Postman API, which only sees shared values.
Let Agent Mode Be Your Guide
Tests automatically check the response when you hit Send. Agent Mode can write them for you — you review and accept.
-
Open Agent Mode from the command palette: click the universal search bar at the top, type
>to switch to commands, then type Open Agent Mode and select it. -
Give it a prompt like:
In my "Get Country" request, add a post-response test that checks the status is 200 and that the first result's
namematches mycountrycollection variable. -
Review what Agent Mode proposes. You should end up with a post-response script similar to:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Found my country", function () {
const data = pm.response.json();
pm.expect(data[0].name).to.eql(pm.collectionVariables.get("country"));
});- Accept the change and save the request.
No Agent Mode available? Open Get Country, go to the Scripts tab → Post-response, and paste the script above yourself.
Stamp Your Passport
Post-response scripts run automatically after you hit Send. This one reads the response and saves the capital and currency for later. You don't need to understand every line — paste it at the bottom of your existing script.
Open Get Country → Scripts → Post-response and add this to the bottom of your existing script:
const country = pm.response.json()[0];
pm.collectionVariables.set("capital", country.capital);
pm.collectionVariables.set("currency", country.currency);
console.log(`Welcome to ${country.capital}! Don't forget some ${country.currency}.`);Save the request.
Turn Your Stamp Into a Visualization
Postman can render a custom view of your response in the Visualization tab. Agent Mode will build a simple card — you don't need to write or understand the script yourself. See Postman Visualizer if you want to dig deeper.
-
Open Agent Mode again (same as Step 6).
-
Give it a prompt like:
In my "Get Country" request, add a post-response visualization using
pm.visualizer.set. Render a passport-stamp style card for the first result showing the flag image (media.flag), the country name, capital, currency, and population. -
Review the proposed script. It should call
pm.visualizer.setwith an HTML template, similar to:
const country = pm.response.json()[0];
const template = `
<div style="font-family: sans-serif; border: 3px dashed #444; border-radius: 12px; padding: 16px; max-width: 320px;">
<img src="{{flag}}" alt="flag" style="width: 100%; border-radius: 6px;" />
<h2 style="margin: 12px 0 4px;">{{name}}</h2>
<p style="margin: 2px 0;">Capital: <b>{{capital}}</b></p>
<p style="margin: 2px 0;">Currency: <b>{{currency}}</b></p>
<p style="margin: 2px 0;">Population: <b>{{population}}</b></p>
</div>
`;
pm.visualizer.set(template, {
name: country.name,
capital: country.capital,
currency: country.currency,
population: country.population,
flag: country.media.flag
});- Accept the change and save the request.
No Agent Mode available? Paste the script above at the bottom of your Post-response script yourself.
Verify the Journey
Quick end-to-end check — one Send should pass tests, show your card, and fill in your variables.
- Click Send.
- Check Test Results — both tests should pass.
- Open the response's Visualize tab to see your passport-stamp card, flag and all.
- Open the Postman Console (bottom-left, or View → Show Postman Console) and find your
Welcome to ...message. - Pop back to the Country Dossier tab, open Variables, and confirm
capitalandcurrencynow hold values from the response.