Cheat Sheet Library

Postman Cheat Sheet

Build, test and document API requests. Collection = a folder of saved requests. Environment = a set of variables (dev / prod). On macOS use ⌘ instead of Ctrl.

  • 43 entries
  • 7 sections
  • Updated
  • Click a command to see all its options

43 entries

On this page

Shortcuts #

ShortcutAction
Ctrl + EnterSend the request
Ctrl + TNew tab
Ctrl + NCreate new (request, collection…)
Ctrl + SSave the request
Ctrl + WClose tab
Ctrl + LFocus the URL bar
Ctrl + OImport (file, cURL, OpenAPI)
Ctrl + KSearch everything
Ctrl + BBeautify the body (JSON/XML)
Ctrl + \Toggle the sidebar
Ctrl + Alt + CPostman Console (see raw requests and console.log)
Ctrl + ,Settings

Variables #

SyntaxMeaning
{{baseUrl}}/usersUse a variable anywhere (URL, headers, body)
Scopes (narrow wins)Global → Collection → Environment → Data → Local
{{$guid}}Random UUID
{{$timestamp}}Unix timestamp
{{$randomEmail}} / {{$randomFirstName}}Fake test data
{{$randomInt}}Random number 0–1000

Store secrets in environment variables and mark them as secret. Never hard-code tokens in shared requests.

Auth #

SetupHow
Bearer tokenAuthorization tab → Bearer Token → {{token}}
Set once for allPut auth on the collection; requests use Inherit auth from parent
OAuth 2.0Authorization tab → OAuth 2.0 → Get New Access Token

Scripts (Pre-request & Post-response) #

// Post-response: save a token from a login response
const json = pm.response.json();
pm.environment.set("token", json.token);

// Tests
pm.test("Status is 200", () => pm.response.to.have.status(200));
pm.test("Has a user id", () => pm.expect(json.id).to.be.a("number"));
pm.test("Fast enough", () => pm.expect(pm.response.responseTime).to.be.below(500));

// Pre-request: set a timestamp header
pm.request.headers.add({ key: "X-Time", value: Date.now().toString() });
APIUse
pm.environment.get/setEnvironment variables
pm.collectionVariables.get/setCollection variables
pm.response.json() / .text()Response body
pm.response.codeStatus code
pm.sendRequest(url, cb)Send an extra request from a script

Handy Features #

FeatureWhere
Paste a cURL commandPaste it in the URL bar or Import it
Generate code (fetch, axios, Python…)</> icon on the right
Run a whole collectionCollection → Run (Collection Runner)
Mock serverCollection → Mock (fake API from saved examples)
Save response as exampleResponse → Save as example
HistorySidebar → History

Command Line #

CommandAction
Install Newman
Run a collection (CI)
Postman CLI (logs in with an API key)

HTTP Status Codes #

CodeMeaning
200 / 201 / 204OK / Created / No content
301 / 304Moved permanently / Not modified
400Bad request (invalid input)
401 / 403Not logged in / not allowed
404Not found
409 / 422Conflict / validation error
429Too many requests
500 / 502 / 503Server error / bad gateway / unavailable