API testing · Guide
10 common API bugs every tester should know
A 200 OK can still be broken. These are the API bugs we see most often, how to spot each one in the response, and a checklist you can use on your next test run.
Most API testing stops at the status code. The request went through, the response was 200, the test passed. But many of the worst bugs live inside the body of a successful response, where nobody looks. An API can return the wrong customer, leak a password hash or quietly ignore your filter, and still answer with a cheerful 200.
Below are ten API bugs that show up again and again in real products. For each one you get what it looks like, why it matters and the one check that catches it. Every example links to a page in our Bug library, and you can try to spot each bug yourself before reading the answer.
1The API returns the wrong record
You ask for user 17 and get user 18. The response looks perfect: right shape, right fields, status 200. Only the id gives it away. An off-by-one in a lookup, a wrong index or a cached response can show one customer another customer’s profile, which turns a small coding slip into a privacy incident.
GET /api/users/17
200 OK
{ "id": 18, "name": "Arjun Mehta", ... }
How to catch it: compare the id in the response with the id you asked for, every time. In automated tests this is a single line, and it is one of the most valuable lines you can write.
2An error hidden inside a 200 OK
The status says success, but the body says "error": "Order not found". Apps that trust the status code will treat a failure as a success: they show an empty order, cache the error or move the user to the next step as if nothing went wrong.
GET /api/orders/99999
200 OK
{ "error": "Order not found" }
How to catch it: assert the status code and the body together. A missing record should be a 404, bad input a 400, a server problem a 5xx. If the body contains an error, the status must not be 2xx.
3Private fields leak to the browser
The profile screen shows a name and an email, but the API sends the whole database row, including the password hash. Nobody sees it on screen, but anyone can see it in the browser’s network tab. Tokens, internal flags, other users’ emails and admin notes leak the same way, usually because the code returns a full object instead of picking safe fields.
How to catch it: read every field in the response, not just the ones the screen uses. Ask for each field: would I be happy if a stranger read this?
Think you would catch these?
Today’s quiz hides 8 bugs in fake app screens. Free, no sign-up.
4Pagination and limits are ignored
You ask for limit=10 and get 12 items. It sounds harmless, but on the next page some orders will repeat and others will never be shown. Users will say “my order disappeared”, and nobody will be able to reproduce it.
How to catch it: count the items on the first, a middle and the last page. Walk through every page and check that no item appears twice and none goes missing. Try limit=0, a negative limit and a very large one too.
5Sort and filter parameters do not work
You sort by price from low to high and get ₹249, ₹1,299, ₹899, ₹1,999. The classic cause is sorting numbers as text, where “1299” comes before “899” because 1 comes before 8. The same thing happens with filters that are silently ignored when a parameter name is misspelt.
How to catch it: test sorting with values of different lengths, such as 99, 899 and 1,299. For filters, check that every item in the response really matches the filter, not just the first few.
6Impossible dates
An order placed near the end of February gets a delivery date of 2026-02-31. Date maths done by hand (adding days to the day number without moving the month) breaks at month ends and leap years. Time zones cause the same class of bug: a date that is right in UTC can be a day off for a user in India.
How to catch it: test dates around the 28th to the 31st, on 29 February, at the end of the year, and close to midnight in your users’ time zone. Parse every date in the response and check that it is a real date.
7Values the screen blocks, but the API accepts
The app’s quantity picker stops at 1, so testers assume negative quantities are impossible. But the API is a separate door. Send "qty": -3 straight to the cart API and it may accept it and make the order total negative. Anyone with a browser’s developer tools or a tool like Postman can do this.
POST /api/cart/items
{ "productId": 4, "qty": -3 }
200 OK
{ "total": -3897 }
How to catch it: call the API directly with values the screen never sends: negative numbers, zero, huge numbers, empty strings, very long text and the wrong data types. The server must validate everything itself.
8Deleted data comes back
You delete item 9 from the cart and get a 204 No Content. Then you read the cart and item 9 is still there. The delete may have hit a cache, a different replica or the wrong table. Either way, the success code lied.
How to catch it: after every create, update or delete, read the data back and check that it really changed. A status code only tells you what the server thinks happened.
9Tokens that never expire
Access tokens are meant to be short lived, often around 15 minutes, so a stolen token stops working quickly. If a token is issued with an expiry ten years away, anyone who copies it from a log, a shared screenshot or a public Wi-Fi network can use the account for a decade.
How to catch it: decode the token (for a JWT, any JWT decoder will do) and read the exp value. Also check that old tokens stop working after sign-out and after a password change.
10CORS that trusts every website
CORS headers tell the browser which other websites may read your API’s responses. A common shortcut is to copy whatever Origin the request sends back into Access-Control-Allow-Origin, together with Access-Control-Allow-Credentials: true. That lets any website a signed-in user visits read their account data.
GET /api/account
Origin: https://evil.example
200 OK
Access-Control-Allow-Origin: https://evil.example
Access-Control-Allow-Credentials: true
How to catch it: send a request with a made-up Origin header and read the response headers. Only your own domains should ever be allowed when credentials are allowed.
Two more to keep in mind
Error messages that say too much. Send a text id where a number is expected. If the error shows a stack trace, a database host name or file paths, attackers get a map of your system. Errors should be short; details belong in server logs.
Required fields that come back null. An active product with "name": null shows up as a blank card, or as the word “null” on screen. Check that required fields are always present and never empty.
Your API test checklist
- The id in the response matches the id you asked for
- The status code and the body agree (no errors inside a 2xx)
- No password hash, token or internal field in any response
- limit, page, sort and filter are really applied
- Every date is a real date, in the right time zone
- Negative, zero, huge and wrong-type values are rejected with a 400
- After a write, reading the data back shows the change
- Tokens expire, and old ones stop working after sign-out
- CORS allows only your own domains
- Error responses are short and reveal nothing internal
None of these checks needs automation to start. A browser’s network tab, Postman or curl is enough to find every bug on this page. Once you have found one by hand, turn it into an automated check so it never comes back.
Frequently asked questions
What is the most common API bug?
Responses that pass on the status code but carry wrong or missing data in the body, such as the wrong record, a null required field or an error message inside a 200 OK.
Do I need to write code to test an API?
No. Postman, the browser’s network tab or curl is enough to find every bug in this guide. Code helps later, when you want to repeat the checks on every build.
Why test the API if the screen already blocks bad input?
The screen is only one way in. Anyone can call the API directly with values the screen never sends, so the server must validate every input on its own.
What status code should an API return when a record is not found?
Usually 404 Not Found, with a short error message in the body. Returning 200 OK with an error message makes clients treat the failure as a success.