DevTools Logo

API Testing & Postman Cheat Sheet

HTTP methods, status codes, request structure, Postman collections, environments, and test assertions.

Web & Network
api
postman
testing

API testing verifies that endpoints behave as documented: correct methods, status codes, headers, and response bodies. Postman organizes requests into collections with reusable environments and scripted assertions.

HTTP methods

Table
MethodPurpose
GETRead a resource.
POSTCreate a resource.
PUTReplace a resource.
PATCHPartially update a resource.
DELETERemove a resource.
HEADRead headers only.
OPTIONSDiscover allowed methods (CORS).

Common status codes

Table
CodeMeaning
200OK.
201Created.
204No content.
400Bad request.
401Unauthenticated.
403Forbidden.
404Not found.
422Unprocessable entity (validation).
429Rate limited.
500Server error.

Postman test assertions

js
pm.test("Status is 200", () => pm.response.to.have.status(200));
pm.test("Body has id", () => {
  const json = pm.response.json();
  pm.expect(json.id).to.be.a("string");
});
pm.test("Response time OK", () => {
  pm.expect(pm.response.responseTime).to.be.below(500);
});

Environments and variables

Table
ScopeExample
GlobalShared across all collections.
CollectionScoped to one collection.
EnvironmentPer-environment (dev/staging/prod).
LocalPer-request temporary.

Use {{baseUrl}}/users with an environment variable baseUrl to switch hosts without editing requests.

References