Skip to main content

Postman cheatsheet

A one-page reference for Postman. For workspace organization and interview Q&A, see the complete guide.

๐Ÿ“– Full guide: Postman โ†’

pm.* test scriptsโ€‹

pm.test("status is 200", () => {
pm.response.to.have.status(200);
});

pm.test("has user id", () => {
const json = pm.response.json();
pm.expect(json.id).to.be.a('number');
});

Pre-request scriptsโ€‹

pm.environment.set("timestamp", Date.now());
pm.request.headers.add({
key: "X-Signature",
value: computeHmac(pm.environment.get("secret"))
});

Chaining requestsโ€‹

// in a "Login" request's Tests tab
pm.environment.set("authToken", pm.response.json().token);
// next request uses {{authToken}} in its Authorization header

Collection Runner (data-driven)โ€‹

Runner โ†’ select collection โ†’ select CSV/JSON data file
โ†’ each row runs the whole collection once, {{variables}} pulled from row

Newman โ€” CI executionโ€‹

newman run collection.json -e env.json \
--reporters cli,junit --reporter-junit-export results.xml

Mock serversโ€‹

New โ†’ Mock Server โ†’ pick collection
โ†’ returns saved example responses without hitting the real backend

Useful for frontend teams to develop against before the API exists.

Environments & variablesโ€‹

{{baseUrl}}/users/{{userId}}

Scope order (highest wins): Local โ†’ Environment โ†’ Collection โ†’ Global.

Postman vs Rest Assuredโ€‹

PostmanRest Assured
AuthoringGUI + JSJava code
Version controlexport JSON (noisy diffs)native, clean diffs
Best forexploratory, quick checksCI-integrated regression suites
See: Postman vs Rest Assured