Home / Blog / API Testing Real Scenarios
API Testing Real Scenarios
The most common trap junior QA engineers fall into during technical interviews is defining API testing simply as "Checking if the endpoint returns a 200 Status Code."
In real-world distributed architectures, a 200 OK is completely meaningless if the underlying database transaction rolled back, the cache wasn't invalidated, or the payload exposed PII (Personally Identifiable Information).
If you want to pass senior SDET and QA automation interviews, you must demonstrate that you test the entire system boundary, not just the HTTP layer. Here are the real scenarios you must validate.
Scenario 1: State Management Validation
An API is often just a window into a database. You must verify the state changed.
The Workflow:
- A user calls
POST /api/ecommerce/cart/checkoutwith a valid payload. - The endpoint returns
201 Createdwith anorder_id.
The Beginner Test:
Just asserted response.status_code == 201.
The Senior Test (What you should say in interviews):
- Extract the
order_idfrom the API response. - Query the database using the framework's DB client (
SELECT status FROM orders WHERE id=...). Does the DB actually reflect theCREATEDstatus? - Query the Inventory REST API. Did the stock count decrease by the exact amount purchased?
- Call
GET /api/ecommerce/orders/{order_id}. Does the read endpoint return the exact same JSON schema and values that thePOSTendpoint generated?
Scenario 2: Idempotency Validation
Network connections drop. Clients click "Submit" twice. If an API handles financial transactions or side-effects, it must be Idempotent (calling it twice has the exact same safe effect as calling it once).
The Workflow:
You are testing a refund endpoint: POST /api/payments/refund with a unique transaction_id and a refund amount.
The Senior Test:
- Send the
POSTrequest. Validate the200 OKand that the refund is processed in the database. - Send the exact same request again immediately.
- The API should return
200 OKor409 Conflict, but under no circumstances should the user be refunded a second time. - Verify the database shows only 1 refund processed.
When you mention testing for Idempotence keys (x-idempotency-key headers) in an interview, the hiring manager immediately knows you understand production-grade system design.
Scenario 3: Pagination and Sorting Boundaries
Any API returning lists of data implements pagination (Offset or Cursor-based). This is notoriously buggy.
The Workflow:
An endpoint GET /api/users accepts ?limit=10&page=2&sort=created_at,desc.
The Senior Test: Don't just check if a list comes back. Test the boundaries.
- Mathematical boundary: If the database has 25 total users, page 1 with
limit=10should return 10 users. Page 2 should return 10. Page 3 should return exactly 5. Page 4 should return an empty array[], not a404or500. - Sorting validation: Iterate through the JSON response using your automation script and physically compare the timestamps. Does
users[0].created_atactually parse to a date mathematically greater thanusers[1].created_at? - Cursor hijacking: If it's Cursor-based pagination, try passing invalid Base64 cursor strings. Does the API elegantly handle it with a
400 Bad Request, or does it crash?
Scenario 4: Authorization and Scope Bleed (BOLA)
Broken Object Level Authorization (BOLA), formerly IDOR, is the #1 API vulnerability globally. QA must test it.
The Workflow:
User A logs in, gets a JWT token, and accesses their profile via GET /api/users/profile/123.
The Senior Test:
- Log in as User A to get their JWT token in the automation setup.
- Call an endpoint meant for a different user, e.g.,
GET /api/users/profile/999, but pass User A's token. - It must return a
403 Forbiddenor404 Not Found. If it returns a200 OKwith User 999's data, your company has a critical vulnerability. - Automate this exact flow for every single
PUT,DELETE, andGETendpoint in the system.
Final Takeaway
To excel in API testing, you must think like an engineer trying to break the system logic, not a user following a happy path. In your next interview, bring up Idempotency, Database State Validation, and BOLA, and you will set yourself apart from 90% of candidates.
Ready to level up your automation setup? Check out our QA products for pre-built Postman collections and Pytest frameworks focused on these exact edge cases.
Want structured interview prep?
Download a free QA kit and move faster through your prep.
Get Free QA Interview Kit โRelated Posts
Contract Testing with Pact: Stop Integration Tests from Lying to You
Learn how consumer-driven contract testing with Pact eliminates the 'it works on staging but breaks in prod' problem for microservices teams.
Read article โTop 15 API Testing Interview Questions (And How to Answer Them)
A curated list of real API testing interview questions asked by top tech companies, complete with senior-level answers.
Read article โMicroservices Testing Strategy: Beyond the Pyramid
How to adapt the Testing Pyramid for distributed architectures, covering service tests, contracts, and chaos engineering.
Read article โ