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
| Method | Purpose |
|---|---|
GET | Read a resource. |
POST | Create a resource. |
PUT | Replace a resource. |
PATCH | Partially update a resource. |
DELETE | Remove a resource. |
HEAD | Read headers only. |
OPTIONS | Discover allowed methods (CORS). |
Common status codes
Table
| Code | Meaning |
|---|---|
200 | OK. |
201 | Created. |
204 | No content. |
400 | Bad request. |
401 | Unauthenticated. |
403 | Forbidden. |
404 | Not found. |
422 | Unprocessable entity (validation). |
429 | Rate limited. |
500 | Server 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
| Scope | Example |
|---|---|
| Global | Shared across all collections. |
| Collection | Scoped to one collection. |
| Environment | Per-environment (dev/staging/prod). |
| Local | Per-request temporary. |
Use {{baseUrl}}/users with an environment variable baseUrl to switch hosts without editing requests.