You have created an environment. You have variables in it. Now what? You use them. Everywhere. URLs, headers, request bodies, query parameters, even test scripts. The syntax is always the same: {{variableName}}.
// Instead of:
GET https://www.testerrank.com/api/users/42
// Write:
GET {{baseUrl}}/users/{{userId}}
// Postman resolves it before sending.
// If baseUrl = "https://www.testerrank.com/api" and userId = "42"
// The actual request goes to: https://www.testerrank.com/api/users/42// Authorization header:
Key: Authorization
Value: Bearer {{authToken}}
// Custom headers:
Key: X-API-Key
Value: {{apiKey}}
Key: X-Request-ID
Value: {{requestId}}{
"username": "{{testUsername}}",
"email": "{{testEmail}}",
"role": "{{userRole}}",
"metadata": {
"source": "{{appName}}",
"timestamp": "{{currentTimestamp}}"
}
}// URL with query params:
GET {{baseUrl}}/products?category={{category}}&limit={{pageSize}}&sort={{sortField}}
// Or use Postman's Params tab:
// Key: category Value: {{category}}
// Key: limit Value: {{pageSize}}
// Key: sort Value: {{sortField}}Hover over any {{variable}} in Postman to see its resolved value and which scope it comes from. Orange text means the variable is unresolved — you either misspelled it or forgot to set it.
Inside pre-request and post-response scripts, you do NOT use curly braces. You use the pm.variables.get() method instead. The {{syntax}} is only for the UI fields (URL, headers, body).
// WRONG — curly braces do not work in scripts
const url = "{{baseUrl}}/users"; // This stays as literal text
// CORRECT — use pm.variables.get()
const baseUrl = pm.variables.get("baseUrl");
const url = baseUrl + "/users";
// Or get from specific scope
const envUrl = pm.environment.get("baseUrl");
const globalKey = pm.globals.get("apiKey");Common mistake: using {{variable}} inside JavaScript code in the Scripts tab. It will NOT resolve. Postman only replaces {{}} in URL, Headers, Body, and Params fields. In scripts, always use pm.variables.get() or pm.environment.get().
Here is a complete example. A POST request to create a user, using variables everywhere.
POST {{baseUrl}}/users
Headers:
Authorization: Bearer {{authToken}}
Content-Type: application/json
Body:
{
"name": "{{testUserName}}",
"email": "{{testEmail}}",
"company": "{{companyName}}"
}Q: Where can you use {{variables}} in Postman, and where can you NOT use them?
A: You can use {{variableName}} syntax in URL, Headers, Body (raw/form-data/x-www-form-urlencoded), and Query Parameters — basically any input field in the request builder. You CANNOT use {{}} syntax inside the Scripts tab (pre-request or post-response). In scripts, you must use pm.variables.get("name"), pm.environment.get("name"), or pm.globals.get("name") to access variable values programmatically.
Key Point: Use {{variableName}} in URL, headers, body, and params. In scripts, use pm.variables.get("name") instead.