Postman Deep-Dive

20Postman Deep-Dive

What you will master here

  • Every configuration option in a Postman request
  • Authentication: API key, Basic, Bearer/JWT, Digest, AWS, NTLM, OAuth1 vs OAuth2
  • JWT internals — header.payload.signature
  • OAuth 1.0a vs OAuth 2.0 — the actual difference
  • Collections, environments, variables, scopes
  • Pre-request scripts, test scripts (the "Tests" tab)
  • Collection runner, data-driven runs, Newman (CLI), CI integration
  • Mock servers, monitors, public workspaces

20.1 Anatomy of a Postman request

TabWhat lives here
ParamsURL query string (?key=value), URL path variables (:id)
AuthorizationAuth type + credentials (see 17.2)
HeadersRequest headers (Content-Type, custom)
BodyJSON / form-data / x-www-form-urlencoded / raw / binary / GraphQL
Pre-request ScriptJS that runs before sending — set variables, compute signatures
TestsJS that runs after response arrives — assertions, capture variables
SettingsPer-request: SSL verify, automatic redirect, timeout, cookies

20.2 Authorization types — exhaustive

TypeWhat it sendsWhen to use
No authNothingPublic endpoints
API KeyKey passed as header or query param (configurable)Simple API key auth (Stripe, Twilio)
Bearer TokenAuthorization: Bearer <token>JWT, OAuth2 access tokens
Basic AuthAuthorization: Basic base64(user:pass)Legacy admin endpoints, internal tools
Digest AuthChallenge-response, MD5 hashedOld enterprise systems
OAuth 1.0Header with nonce, timestamp, signature, etc.Legacy (Twitter v1, old APIs)
OAuth 2.0Access token obtained via grant flow; sent as BearerModern OAuth (Google, GitHub, almost all)
Hawk AuthHMAC-based, similar to OAuth1Mozilla / Atlassian internal
AWS SignatureAWS Sig v4 calculated automaticallyAWS API calls (S3, DynamoDB, etc.)
NTLMWindows-domain challenge authOn-prem Microsoft systems
Akamai EdgeGridCustom Akamai header setAkamai's APIs
ASAPAtlassian Service Auth ProtocolAtlassian internal
Inherit auth from parentUse folder/collection's authApply once at collection, inherit in every request

20.3 JWT — what's inside that token

A JWT (JSON Web Token) is just three base64-url chunks joined by dots:

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0Iiwicm9sZSI6ImFkbWluIn0.4Adcj3UFYzPUVaVF43FmMab6RlaQD8A9V8wFzzht-KQ
└──── header ────┘ └──────── payload ────────┘ └────────── signature ──────────┘
PartWhat it holdsDecoded example
HeaderAlgorithm + token type{ "alg": "HS256", "typ": "JWT" }
PayloadClaims about the user / token{ "sub": "1234", "role": "admin", "exp": 1735689600 }
SignatureHMAC of header.payload using a secretBinary, base64url

Standard claims (RFC 7519)

CriticalThe signature ONLY proves the token wasn't tampered with — it does NOT encrypt. Anyone with the token can decode it: echo "eyJzdWIi..." | base64 -d. Never put secrets in JWT payload.

Using a JWT in Postman

  1. POST to /auth/login with credentials
  2. In the Tests tab: pm.collectionVariables.set('token', pm.response.json().access_token)
  3. On other requests, Authorization → Bearer Token → {{token}}

20.4 OAuth 1.0a vs OAuth 2.0 — the real difference

OAuth 1.0a (legacy)
  • Stateless signing on every request
  • Client signs each request with a consumer secret using HMAC-SHA1
  • No reliance on TLS — built to work over plain HTTP
  • Header contains: nonce, timestamp, signature, signature_method, consumer_key, token, version
  • Complex — hard to implement correctly
  • Used by old Twitter API, some legacy systems
OAuth 2.0 (modern)
  • Token-based — get an access token, send it on every request
  • Relies on TLS for transport security; tokens are bearer tokens
  • Multiple grant flows: authorization code, client credentials, device code, refresh token, (deprecated) password, (deprecated) implicit
  • Much simpler client implementation
  • De facto standard for modern APIs

OAuth 2.0 grant flows (Postman supports all)

FlowUsed forHow it works
Authorization CodeUser-facing web appsUser logs in on the provider, returns a code, client exchanges code for token
Authorization Code + PKCEMobile / SPASame + Proof Key for Code Exchange — protects public clients (no secret)
Client CredentialsServer-to-serverService uses its own client_id + secret to get a token — no user involved
Refresh TokenRenewalExchange long-lived refresh for short-lived access
Device CodeTVs / CLI toolsDisplay code, user visits URL on phone, then token issued
Resource Owner PasswordLegacy / trustedDeprecated — pass username+password directly. Avoid.
ImplicitOld SPADeprecated — replaced by Auth Code + PKCE
Interview one-liner"OAuth1 signs every request with HMAC; OAuth2 obtains an access token once and sends it as a Bearer header per request. OAuth2 wins on simplicity but depends on TLS for security."

20.5 Variables & scopes

ScopeLifetimeUse for
GlobalWorkspace-wideTruly cross-collection constants (rare)
CollectionOne collectionbaseUrl, apiVersion, shared tokens
EnvironmentPer environment (dev/stg/prod)URLs, credentials per env
DataPer row in a CSV/JSON data file (during run)Data-driven iteration
LocalSingle requestCaptured response values used by chained next request

Reference: {{baseUrl}}/users/{{userId}}. Resolution order: data → local → environment → collection → global.

20.6 Pre-request & Tests scripts

Pre-request — runs BEFORE sending

// Compute a signed HMAC header
const ts = Date.now();
const body = pm.request.body.raw || '';
const sig = CryptoJS.HmacSHA256(ts + body, pm.environment.get('signingKey')).toString();
pm.request.headers.add({ key: 'X-Timestamp', value: ts });
pm.request.headers.add({ key: 'X-Signature', value: sig });

Tests — runs AFTER response (assertions + capture)

// Status assertion
pm.test('status 200', () => pm.response.to.have.status(200));

// JSON schema assertion
pm.test('response has user', () => {
  const body = pm.response.json();
  pm.expect(body).to.have.property('id');
  pm.expect(body.email).to.match(/@/);
});

// Capture value for next request
const token = pm.response.json().access_token;
pm.collectionVariables.set('token', token);

// Conditional next request
postman.setNextRequest('Verify Token');   // skip to a specific request in the run
// postman.setNextRequest(null);          // stop the runner

20.7 Collections, folders, runner

Data-driven runs

Upload a CSV / JSON file. Postman runs the collection once per row, with each row's columns available as {{column}}.

// users.csv
email,role
alice@test.com,admin
bob@test.com,user
carol@test.com,viewer

Request body becomes {"email": "{{email}}", "role": "{{role}}"}. Three iterations run automatically.

20.8 Newman — Postman in CI

Newman is Postman's CLI. Export the collection JSON, commit it, and run on CI.

npm i -g newman
newman run my-collection.json -e staging.postman_environment.json \
  --iteration-data users.csv \
  --reporters cli,htmlextra,junit \
  --reporter-junit-export results/junit.xml
# GitHub Actions
- uses: actions/setup-node@v4
  with: { node-version: '20' }
- run: npm i -g newman newman-reporter-htmlextra
- run: newman run my-collection.json -e prod.json --reporters cli,htmlextra
- uses: actions/upload-artifact@v4
  if: always()
  with: { name: newman-report, path: newman/ }

20.9 Mock servers and monitors

20.10 When to use Postman vs Playwright API vs REST Assured

Use Postman whenUse Playwright/REST Assured when
Exploring an API manuallyAutomated regression in CI
Non-engineers need to testTests live alongside app code
Demo / share via public workspaceTight integration with UI tests
Light scheduled monitoringHeavy load, parallel suites
Quick ad-hoc data-driven runsType-safe, reviewable test code

Module 17 — Postman interview Q&A bank

What are the auth types available in Postman?
No auth, API Key, Bearer Token, Basic, Digest, OAuth 1.0, OAuth 2.0, Hawk, AWS Signature, NTLM, Akamai EdgeGrid, ASAP, and Inherit-from-parent. Choose based on what the API expects.
What is a JWT?
JSON Web Token — base64-url-encoded header + payload + signature, joined by dots. The signature uses a secret + algorithm (e.g. HS256) to sign header+payload, proving tampering hasn't happened. Payload is readable to anyone — never put secrets in it.
What are the standard JWT claims?
iss (issuer), sub (subject), aud (audience), exp (expiry), nbf (not before), iat (issued at), jti (token id). Defined by RFC 7519.
What's the difference between OAuth 1.0 and OAuth 2.0?
OAuth1 signs every request with HMAC using a consumer secret — no TLS dependency, but the signing is complex. OAuth2 obtains an access token via one of several grant flows and sends it as a Bearer header per request — simpler, but depends on TLS for transport security. Modern APIs use OAuth2.
What's the OAuth2 Authorization Code flow?
User clicks "Sign in with X", redirected to provider, logs in, redirected back to your app with a one-time code, your server exchanges the code (using its client secret) for an access token. Used for web apps with a server backend.
What is PKCE and why does it exist?
Proof Key for Code Exchange. Public clients (mobile apps, SPAs) can't keep a client secret. PKCE replaces the secret with a per-request code_verifier the client generates, hashes (code_challenge) and sends with the auth request, then proves at token exchange. Prevents intercepted auth codes from being usable.
What's a Bearer token?
A credential passed in the Authorization header as Bearer <token>. Whoever holds the token can use it — there's no other proof of identity. Hence "bearer". Standard for OAuth2 access tokens.
How do you chain requests in Postman?
In the Tests tab of request 1, capture a value: pm.collectionVariables.set('userId', pm.response.json().id). In request 2's URL or body, reference {{userId}}. Run via Collection Runner so they execute in order.
Difference between pre-request and tests scripts?
Pre-request runs before sending — generate signatures, set headers, compute timestamps. Tests runs after the response — assertions and capturing variables for next requests.
What is Newman?
Postman's command-line runner. Reads exported collection + environment JSON, runs them headlessly, supports iteration data, multiple reporters (CLI, HTML, JUnit). Used to run Postman tests in CI without a desktop GUI.
Variable resolution order?
Data > Local > Environment > Collection > Global. Data file variables (during a runner iteration) override everything else; globals are fallback.
How do you do data-driven testing in Postman?
Provide a CSV or JSON file to Collection Runner. Each row becomes a set of variables; the collection runs once per row. Reference {{columnName}} in URL/body/headers.
What is a Postman mock server?
A cloud-hosted endpoint that returns saved example responses. Pin examples to specific URLs/methods; calls to the mock match and return them. Useful for parallel frontend development before a real API exists.
What is a Postman monitor?
A scheduled cloud run of a collection. Pings endpoints on a cadence (every 5 min/hour). Sends alerts on failure — lightweight uptime / contract monitoring.
When would you NOT use Postman?
When you want full code-review on tests, run them alongside UI tests, share fixtures between API and UI suites, or need a typed test language. Use Playwright's request fixture or REST Assured in those cases.
How do you keep secrets out of Postman exports?
Mark variables as "secret" type and store in a local environment (not synced) or external vault. For Newman in CI, pass via --env-var "TOKEN=$TOKEN" using CI secrets. Never commit environment JSON containing real tokens.
What's the difference between collection auth and request auth?
Collection-level auth applies to every request that inherits ("Inherit auth from parent"). Override at folder or request level when an endpoint needs different auth. Set common auth once, override exceptions.
How would you script Newman to fail CI when tests fail?
Newman exits non-zero on test failures by default — CI step fails automatically. Use --bail to stop on first failure, or --suppress-exit-code only if you want CI to continue (rare).