API Automation from Zero to Confident Β· Lesson 1 of 6

The HTTP Mental Model & Your First Postman Collection

Every API test starts with one simple question: what am I sending, and what should come back? Get that picture clear and the tools become easy.

By Shahriyar Β· Updated

The idea, in one line

An API request is a message you send to a server, and the response is its reply. Your job is to check the reply is the one you expected.

The methods β€” what you're asking for

Each method names your intent. There are five you'll meet constantly:

Two words about those methods come up a lot. Safe means the request changes nothing on the server β€” GET is safe. Idempotent is a big word for a simple idea: sending it twice leaves the server in the same state as sending it once. GET, PUT and DELETE are idempotent; POST and PATCH are not. That's exactly why a POST that gets retried can create a duplicate β€” a classic bug to go hunting for.

The status codes β€” what came back

The response arrives with a number that tells you how it went. They group into families:

Responses also carry headers β€” small labels of metadata, like Content-Type (what format the body is) and Authorization (who's asking).

See it work

Start in Postman, a friendly app for sending requests by hand. In each request's Tests tab you write a little JavaScript that runs after the reply arrives and checks it.

β–Έ try it
// Postman Tests tab: this JS runs after the response arrives.
// POST /posts -> create a record, then save its new id.

pm.test("status is 201 Created", function () {
    pm.response.to.have.status(201);
});

pm.test("body echoes what we sent", function () {
    const body = pm.response.json();
    pm.expect(body.title).to.eql("smoke test");
});

// Save the new id so later requests can reuse it.
pm.environment.set("post_id", pm.response.json().id);
// base_url also lives in the environment: {{base_url}}/posts

Read it top to bottom: you checked the status was 201, checked the reply contained what you sent, then stashed the new id. Nothing more mysterious than that.

Advanced β€” why an environment matters

An environment is a small bag of saved values, like the base URL and your token. Because your requests read from the bag instead of hard-coding those values, the exact same collection can run against a dev server today and a prod server tomorrow β€” you just swap the bag. That reuse is what turns a pile of requests into a proper suite.

Grounded in the MDN HTTP methods reference and Postman Learning Center (Writing tests)

All lessons in API Automation from Zero to Confident

  1. The HTTP Mental Model & Your First Postman Collection
  2. Recreate It in Code: requests + pytest with Shared State
  3. Trust the Shape: Schema Validation & Negative Testing
  4. Getting Past the Gate: API Keys, Bearer/JWT & OAuth2
  5. SQL for Testers: Prove the API Actually Wrote to the DB
  6. Mocking & Contracts: Fast, Offline, Reliable Tests