What an API is, how REST requests and responses work, and how to test an API with Postman, from your first GET request to environments, collections and automated checks.
40–65 min beginner Web
Your progress
A food delivery app had a neat little quantity stepper: the – button stopped at 1, so you could never order fewer than one pizza. The UI was tested carefully and worked perfectly.
Then someone sent the request to the server directly, with "quantity": -3. The server accepted it. The order total went negative, and the “refund” landed on a real card.
Almost every modern app is two parts: a front end (the website or the mobile app you see) and a back end (servers and databases). They talk to each other through APIs. The same API often serves the website, the iOS app, the Android app and partner companies.
That means:
One API bug breaks every platform at once.
The UI can hide bugs. A form may block bad input, but the API might still accept it from anyone who sends a request directly.
API tests are fast. You can check 20 cases in the time it takes to click through one checkout.
An API (Application Programming Interface) is a set of rules that lets one program ask another program for data or actions.
The classic analogy is a restaurant:
🧑💻
You (the client)
The app or website. It knows what it wants, but can't go into the kitchen.
🤵
The waiter (the API)
Takes your order in an agreed format (the menu), carries it to the kitchen and brings back the result.
👩🍳
The kitchen (the server)
Does the real work: checks stock, saves orders, reads the database.
The menu is the API documentation: it lists what you can order and how. As an API tester you skip the dining room (the UI) and talk to the waiter directly: you order normal dishes, strange dishes, dishes that aren’t on the menu, and you check that the waiter always responds correctly.
Check this part
In the restaurant analogy, what is the API?
The waiter takes your order in an agreed format and brings back the result. The kitchen is the server, the menu is the documentation.
The API returns the right data, but the screen shows it wrong. Where is the bug?
If the API is right but the screen is wrong, it's a front-end bug. Wrong data in the API response points to the back end.
An API is the waiter between the app and the server, and one API bug can break every platform at once.
Who are you? No token, or an invalid / expired one
403
Forbidden
I know who you are, but you’re not allowed
404
Not Found
The resource doesn’t exist
405
Method Not Allowed
E.g. DELETE on an endpoint that only supports GET
409
Conflict
Clashes with current state, e.g. creating a duplicate
422
Unprocessable Content
The JSON is valid but the values break a rule (some APIs use 400 for this)
429
Too Many Requests
Rate limit hit
5xx
Server error (the server failed)
500
Internal Server Error
Unhandled crash on the server: almost always a bug
502 / 503 / 504
Bad Gateway / Service Unavailable / Gateway Timeout
Server down, overloaded or too slow
Headers
Headers are key–value pairs with extra information about the request or response:
Content-Type: application/json — “the body I’m sending is JSON”.
Authorization: Bearer eyJhbGci... — “here’s my token, this is who I am”.
Accept: application/json — “please answer in JSON”.
Response headers like Cache-Control, Location (where a new resource lives) or X-Request-Id (great to paste into bug reports so developers can find the server log).
JSON bodies
POST, PUT and PATCH usually send a body in JSON: keys in double quotes, values as strings, numbers, true/false, null, arrays [ ] or objects { }.
{ "productId": 1, "quantity": 2, "giftWrap": false, "note": "Leave at the door"}
Notice that 1 (a number) and "1" (a string) are different types. Many API bugs are type bugs.
The two error codes to remember: 401 = missing or invalid credentials; 403 = valid credentials, but not allowed (for example a customer trying an admin endpoint).
Check this part
You send a request with a valid customer token to an admin-only endpoint. What status code should you get?
401 means the server does not know who you are (no or invalid token). 403 means it knows who you are, but you are not allowed.
Which request should be idempotent?
PUT sets a value. Sending it once or five times must leave the same state. POST creates something new each time.
Creating a user with an email that already exists returns 500. Is that a bug?
5xx means the server failed. A predictable client mistake should get a 4xx and a clear message.
Endpoints, methods, status codes, headers, JSON bodies and tokens: the building blocks of every REST request.
Part Not started
Why test the API directly?
Reason
Example
Faster feedback
Check 15 invalid inputs in two minutes, no clicking through screens
Finds bugs the UI hides
The UI greys out ”–” at 1, but the API accepts -5
Validation bypass
Front-end checks can be skipped by anyone. The server must validate everything again.
Earlier testing
The API is often ready days before the screens are
Clear blame
Wrong data in the API response → back-end bug. Correct response but wrong screen → front-end bug.
Security checks
Call another user’s resources with your token to test access rules (see Security Basics)
Try it: a mini API client
Here’s a simplified Postman-like client connected to a simulated Shop API that runs in your browser. Nothing is sent over the internet. Try these:
Send the first request. “List products” is preloaded. Click Send and look at the status, time and JSON body.
Change a query parameter. In Params, change limit to 2, then to 0. Which status do you get for 0, and does the message help?
Use the environment. Click the eye icon to see {{baseUrl}} and {{token}}. Switch the environment to No environment and send again. Then switch back.
Check 401 vs 403. Load View cart, untick the Authorization header and send (401). Then load Delete product (admin) and change {{adminToken}} to {{token}} (403).
Break the body. Load Add to cart, change "quantity": 2 to "quantity": "two", then remove the closing }.
Run tests. Open Tests, tick a few checks, send, and open Test Results. Then click curl to see the same request as a terminal command.
GET https://api.shop.test/v1/products?category=accessories&limit=10
Query parameters are added after a ? in the URL. Edit here or in the URL bar.
Response
Click Send to get a response.
History
Requests you send appear here.
Check this part
The UI blocks quantities below 1. Why test quantity -5 on the API anyway?
Front-end checks can be skipped by anyone. The server must validate everything again.
Why can API testing start earlier than UI testing?
Earlier testing is one of the reasons to test the API directly.
Testing the API directly is faster, finds bugs the UI hides, and you can try it in a mini API client.
Part Not started
Postman essentials
Postman is an app (desktop and web, with a free plan) for building, sending, saving and automating API requests. Here’s what you’ll use every day.
Build a request. Click New › HTTP (or the + tab). Choose the method from the dropdown, paste the URL and click Send. The response appears below with status, time, size, body (Pretty / Raw / Preview) and headers.
Params. Query parameters typed in the URL appear in the Params tab, and vice versa. Path variables written as :id in the URL (e.g. /products/:id) also get a value field there.
Headers. Add headers in the Headers tab. For tokens, the Authorization tab is easier: choose Bearer Token and paste {{token}}. Postman then adds the header for you.
Body. In Body, choose raw and JSON. Postman highlights invalid JSON and sets Content-Type: application/json automatically.
Collections. Save requests into a collection (a folder for one API, e.g. Shop API) with sub-folders like Products and Cart. Collections can be shared with your team and run all at once with the Collection Runner.
Scripts and tests. In the Scripts tab (called Tests in older versions), the Post-response script runs after every response. Add checks with pm.test and pm.expect. The Snippets list on the side writes common ones for you.
A few tests worth knowing, in Postman’s JavaScript syntax:
// Status codepm.test("Status code is 200", () => { pm.response.to.have.status(200);});// Response timepm.test("Response time is below 500 ms", () => { pm.expect(pm.response.responseTime).to.be.below(500);});// Body content and typespm.test("Product has the right shape", () => { const json = pm.response.json(); pm.expect(json.id).to.eql(1); pm.expect(json.name).to.be.a("string"); pm.expect(json.price).to.be.a("number");});// Headerpm.test("Content-Type is JSON", () => { pm.expect(pm.response.headers.get("Content-Type")).to.include("application/json");});// Save a value for the next request (e.g. after POST /login)pm.environment.set("token", pm.response.json().token);
Check this part
Which Postman script checks that the response status is 200?
Wrap it in a test: pm.test("Status code is 200", () => { pm.response.to.have.status(200); });
Why use {{baseUrl}} instead of typing the full staging URL in every request?
Environments and variables let one collection run against dev, staging or a local server without editing each request.
Requests, params, headers, bodies, environments, collections and test scripts in Postman.
Missing required fields → 400 with a message naming the field.
Wrong types: "quantity": "two", "price": "19.99", null, an array instead of an object.
Boundary values (boundary value analysis): if quantity is 1–10, try 0, 1, 10, 11, and also -1 and 1.5.
Invalid JSON (a missing bracket) → 400, not 500.
Extra or unknown fields like "isAdmin": true are ignored or rejected, never applied.
Negative: auth and existence.
No token or an invalid / expired token → 401.
Valid token but no permission → 403. Another user’s resource → 403 or 404.
An ID that doesn’t exist → 404, not 200 with an empty body.
Creating a duplicate (same email, same coupon code) → 409, not 500.
Wrong method on an endpoint → 405.
Behavior:
Idempotency. Send the same PUT or DELETE twice; the result must be the same as sending it once.
Response schema and data. Field names, types and formats match the docs (dates, currencies, IDs). No missing fields, no extra sensitive fields like passwords or other users’ emails.
You ask for a product ID that doesn't exist. What should the API return?
An ID that doesn't exist should give 404, not 200 with an empty body or null.
A request includes an unknown extra field like "isAdmin": true. What should happen?
Extra or unknown fields must never be applied. Accepting them is a serious bug.
What to check on every endpoint: valid requests, input validation, auth and missing resources, idempotency, response data and error messages.
Part Not started
Common API bugs
#
Bug
What you see
Typical severity
1
Missing server validation
quantity: -5 or 0 is accepted, totals go negative
High
2
Wrong status code
200 with null or {} instead of 404; 200 with {"error": ...}
Medium
3
500 instead of 4xx
A duplicate, missing field or bad JSON crashes the server
Medium–High
4
Missing auth check
An endpoint works without a token, or for the wrong user
Critical
5
Type / schema mismatch
"price": "19.99" (string) where the docs say number; renamed fields
Medium
6
Not idempotent
Repeating PUT adds the item again; a retried payment charges twice
High
7
Over-sharing
The response includes password hashes, internal IDs or other users’ data
High–Critical
8
Leaky errors
Stack traces, SQL queries or server paths in error messages
Medium
9
Inconsistent errors
Each endpoint returns errors in a different format
Low
10
Slow endpoints
A list call takes 4 seconds once there are 1,000 items
Medium
Find the bug
Here’s the same client connected to a buggy build of the Shop API. The API docs at the bottom say what the API promises. Compare the real responses with the docs, and use the Tests tab and History to help.
🐞 Bug hunt: Shop API test build
This demo has 6 hidden bugs. Explore it like a tester, then check your findings.
Found0/6
GET https://api.shop.test/v1/products?category=accessories&limit=10
Query parameters are added after a ? in the URL. Edit here or in the URL bar.
204 · 401 no/invalid token · 403 not an admin · 404
GET/cartToken
The current user’s cart: { items, total: number }.
200 · 401
POST/cart/itemsToken
Add a product. Body { productId: integer, quantity: integer 1–10 }. Adds to any quantity already in the cart.
201 · 400 invalid body · 401 · 404 unknown product · 409 out of stock
PUT/cart/items/{productId}Token
Set the quantity of a cart item. Body { quantity: integer 1–10 }. Idempotent: sending it twice gives the same result.
200 · 400 · 401 · 404
DELETE/cart/items/{productId}Token
Remove an item from the cart.
204 · 401 · 404 not in cart
POST/couponsAdmin token
Create a coupon. Body { code: string, percent: integer 1–90 }. Codes are unique.
201 · 400 · 401 · 403 · 409 code already exists
1
Hint: The docs say quantity must be 1–10. Try values outside that range in Add to cart.
Adding a negative quantity to the cart is accepted
POST /cart/items with "quantity": -5 (or 0) returns 201 Created and the cart total becomes negative. Only the upper limit (10) is checked. Expected: 400 "quantity must be between 1 and 10".
2
Hint: Ask for a product ID that is not in the list.
A product that does not exist returns 200 with null
GET /products/999 returns 200 OK with the body null. Apps then crash or show an empty page. Expected: 404 Not Found as documented.
3
Hint: Add an item, then untick the Authorization header and remove it.
Removing a cart item works without a token
DELETE /cart/items/1 without an Authorization header returns 204 and really deletes the item. Expected: 401 Unauthorized. Missing auth checks are critical security bugs.
4
Hint: Send Create coupon (admin) twice with the same code.
Creating the same coupon twice crashes the server (500)
The second call returns 500 Internal Server Error with a raw database message (duplicate key value violates unique constraint). Expected: 409 Conflict with a clear message, and no database details.
5
Hint: Compare the type of price with the docs, or run the price test.
price is a string, not a number
Products return "price": "19.99" (a string in quotes) but the docs say number. Apps that add prices may concatenate text ("19.99" + "9.50" = "19.999.50"). The price test fails with expected '19.99' to be a number.
6
Hint: Send Update cart item several times and look at the quantity.
PUT is not idempotent: each call adds the quantity again
PUT /cart/items/1 with "quantity": 3 gives 3, then 6, then 9. PUT should set the quantity, so repeating it must always leave 3. Retries on a bad network would silently inflate orders.
Check this part
An endpoint answers 200 with the body {"error": "not found"}. Which common bug is this?
The status must tell the truth. A missing resource is 404, not a 200 that hides an error in the body.
Sending the same PUT twice adds the item to the cart twice. Which common bug is this?
PUT must have the same effect once or twice. Apps retry requests on bad networks, so this causes duplicates and double charges.
The API bugs teams ship most often, and a buggy Shop API with six of them to find.
An API is how apps talk to servers. Testing it directly is fast, finds bugs the UI hides, and shows whether a bug is front end or back end.
Know the basics: methods (GET, POST, PUT, PATCH, DELETE), status codes (2xx success, 4xx client error, 5xx server error), headers, JSON bodies and tokens.
Remember 401 vs 403, 404 for missing items, 409 for duplicates, and that a 500 caused by user input is a bug.
In Postman, use environments and variables, organize requests in collections, and automate checks with pm.test and pm.expect.
Always test validation, auth, idempotency, the response schema against the docs, response time and error messages.
Go deeper:API Testing in Depth covers JWTs and expired tokens, authorization tests, negative requests, response checks beyond the status code, and a FoodDash API sandbox with 8 bugs to find.
Finished this page?Nice work, this page is complete!
Mark it as done to track your progress. It's saved in this browser, no account needed.