Hiring an API tester means assessing whether a candidate can establish correct behavior beyond a successful status code. An endpoint can return 200 while exposing another customer’s data, losing a concurrent update or accepting a request whose downstream work never completes. Recruiters should look for a clear test oracle: what evidence would show that the promised outcome actually occurred?
This guide to 100+ API Testing Interview Questions and Answers contains 120 questions across beginner, intermediate and experienced levels. It covers HTTP and data fundamentals, contracts, authorization, asynchronous workflows, reliability and test strategy. HTTP APIs are the main focus, with protocol-specific distinctions for other API styles where they matter.
How can recruiters recognize API testing judgment beyond memorized methods and status codes?
Give the candidate a small order or account API and ask what they would assert after a successful response. Then introduce a different user, a malformed field, an uncertain timeout or a repeated request. Strong answers identify the business invariant, choose controlled test data and explain which observations distinguish a service defect from a test or environment problem.
Sherlock AI helps hiring teams assess signals of potential AI cheating, deepfakes, impersonation and unauthorized assistance during remote interviews. Combine those signals with request walkthroughs, assertion design and structured debugging questions. They provide context for human review rather than conclusive proof of misconduct.
API Testing Interview Questions
Begin with request and response reasoning, then choose contract, security and distributed-workflow questions that match the role. Each question has a matching numbered answer below.
API Testing Interview Questions for Beginners
Establish requests, responses, data and test assertions.
What is API testing?
How does API testing differ from UI testing?
What should you learn before testing an unfamiliar API?
What belongs in an API test case?
What is the difference between a request and a response?
How do path, query and body inputs differ?
Why should a test verify the HTTP method?
What should you verify for a GET request?
What should you verify for a POST request?
How would you explain PUT at a basic level?
What should a DELETE test verify?
How do safe and idempotent methods differ?
What does a successful HTTP status establish?
How do 200, 201, 202 and 204 differ?
How should you test an error response?
What is the practical distinction between 401 and 403?
Why should tests inspect response headers?
How do Content-Type and Accept differ?
What makes a payload valid JSON?
How should you compare JSON responses?
How do missing, null and empty values differ in an API?
What is schema validation, and what does it miss?
How does an OpenAPI description help API testing?
What is the difference between authentication and authorization?
What basic credential cases should an API test cover?
Why is testing access to individual objects important?
How do positive and negative tests complement each other?
How would you apply boundary-value testing to an API?
What is equivalence partitioning in API test design?
Why should malformed syntax and invalid business data be separate tests?
What is a useful business assertion beyond status and schema?
Why should a write-operation test check state after the response?
How do you keep test data isolated?
Why is cleanup part of API test design?
What is a mock or stub useful for in API testing?
How does a unit-level API test differ from an integration test?
How should dynamic response fields be asserted?
What makes an API test deterministic?
What evidence belongs in an API defect report?
How would you explain the limits of a passing API test suite?
API Testing Interview Questions for Intermediate
Test contracts, conditional requests, asynchronous behavior and access boundaries.
How do you test ambiguity in oneOf and anyOf schemas?
How would you test query-parameter serialization for arrays and reserved characters?
Why must OpenAPI tests use the document’s declared version?
How would you assess whether a response change is backward compatible?
How should unknown request properties be tested?
How do you test numeric precision and boundary values?
How would you test offset pagination on a stable dataset?
What additional cases matter for cursor pagination?
How should pagination be tested while records change?
How would you test combined filtering and sorting?
How do you test an ETag-based conditional GET?
How does If-Match help prevent lost updates?
How do weak and strong ETags affect testing?
What is the difference between no-cache and no-store?
How would you test cache variation without leaking one user’s data to another?
How would you test PATCH atomicity and patch-document semantics?
What should an idempotency-key test cover?
How would you test a timeout after the server may have committed?
How should retry backoff be tested?
How do you test Retry-After handling?
How would you test rate limiting safely?
What should you verify for a 202 Accepted workflow?
How should polling tests avoid arbitrary sleeps?
How would you test cancellation of an asynchronous API job?
What should a webhook-delivery test verify beyond the payload?
How do you test webhook signatures and replay protection?
How should webhook duplicates and out-of-order events be tested?
How do GraphQL assertions differ from ordinary status-code checks?
How should GraphQL nullability be tested?
What resource-control cases matter for GraphQL APIs?
How do gRPC status assertions differ from HTTP status assertions?
How would you test gRPC deadlines?
What additional cases do streaming RPC tests need?
How do you test object-level authorization across tenants?
How does property-level authorization differ from object-level authorization?
How do you test function-level authorization?
What should JWT validation tests check beyond decoding the payload?
How should clock skew and key rotation be tested for tokens?
How would you test RFC 9457 Problem Details responses and clients?
How can a stateful model strengthen API tests?
API Testing Interview Questions for Experienced
Assess risk, distributed failure diagnosis and release confidence.
How would you prioritize API tests when release time is limited?
How would you design a test architecture for many services?
How would you create a reliable test oracle for a complex API?
When would you use metamorphic testing for an API?
How would you detect specification drift?
What does consumer-driven contract testing fail to prove?
How would you test a rolling API version deployment?
How would you test an API deprecation plan?
How would you test authorization revocation during an in-flight request?
How would you test business invariants across a saga?
How would you verify compensation without assuming it is a perfect inverse?
How would you test eventual consistency meaningfully?
How would you test multi-region consistency and failover?
How would you investigate a concurrency defect that passes sequential API tests?
How would you test retention and ownership of asynchronous results?
How would you test a dependency outage without relying on live failure?
How would you test recovery after a backlog accumulates?
How would you validate disaster recovery through API behavior?
How would you design a representative performance workload?
Why can a low average latency conceal a serious API problem?
Why should service percentiles not be averaged to obtain a global percentile?
How would you avoid coordinated omission in latency testing?
How would you test overload behavior?
How would you distinguish a slow service from a slow test harness?
How would you use tracing to diagnose an API test failure?
How would you test observability itself?
How would you investigate a flaky API test?
How would you recover from test-fixture provisioning failures?
How would you test time-dependent behavior reliably?
How would you control randomized API testing?
How would you scope an authorized API security test?
How would you test authorization across a resource lifecycle?
How would you test that sensitive data stays out of diagnostics?
How would you assess risks when consuming a third-party API?
How would you keep mocks from becoming misleading?
How would you define evidence for an API release decision?
How would you turn a production incident into useful regression tests?
How would you review AI-generated API tests?
What should an API test-suite handover contain?
What demonstrates senior API testing judgment?
API Testing Interview Questions and Answers
Specify the contract, preconditions and expected evidence before choosing a tool. Distinguish protocol rules from product-specific behavior, and make the scope of each test explicit so a passing fixture is not mistaken for end-to-end assurance.
API Testing Interview Questions and Answers for Beginners
Look for a direct explanation followed by a small example and a clear expected result. Status, payload and persistent effects each provide different evidence.
1. What is API testing?
API testing verifies the behavior exposed through a software interface, including its contract, results and failure handling. An API is not necessarily an HTTP endpoint: libraries, messaging systems and other interfaces also expose APIs. The examples here focus mainly on HTTP request-response contracts because those are common interview scenarios.
For an order interface, I would verify more than whether a request returns successfully. The returned order, stored state and rejection of invalid input must match the agreed behavior. Testing at the interface can reveal problems without relying on a user interface, but it does not replace testing the user journey or every internal component.
2. How does API testing differ from UI testing?
API tests exercise an interface directly, while UI tests interact through the presentation layer. Direct calls can isolate service behavior and cover input combinations without navigating screens. UI tests remain useful for presentation, accessibility and whether users can complete the intended workflow.
A form may prevent a negative quantity in the browser, but the API still needs to enforce the rule for other clients. An API test can verify that rejection directly. Conversely, an API returning the correct validation message does not prove the UI displays it clearly. I would use each layer to test the responsibilities it actually owns.
3. What should you learn before testing an unfamiliar API?
I would establish the interface style, supported operations, environment, authentication requirements, data model and expected outcomes. The contract and business rules are the starting point, not assumptions based on another service’s conventions. I would also identify permitted test data and cleanup procedures.
For a booking operation, important questions include whether a response means confirmed or merely accepted for processing, and whether repeated requests can create separate bookings. A sample successful call is useful but incomplete. I would turn ambiguities into explicit expectations before writing assertions that might lock in accidental behavior.
4. What belongs in an API test case?
A test case should identify its purpose, preconditions, input, action, expected result and relevant state checks or cleanup. The expected result needs to be specific enough to decide pass or fail. “The API should work” does not establish a test oracle.
A valid-order case can specify a known product, an allowed quantity and the expected calculated total. It should also define whether one order is created and how the test identifies that order afterward. Keeping setup and assertions explicit helps distinguish a service defect from a fixture that was never valid.
5. What is the difference between a request and a response?
A request asks an interface to perform an operation; a response communicates the result or current outcome. For HTTP, method, target, fields and optional content convey the request, while status, fields and optional content convey the response. The body is only one part of the exchange.
A response can contain valid-looking JSON while its status or media type contradicts the contract. Likewise, a request with the expected body can target the wrong operation. I would record enough of both sides to reproduce a failure, while excluding credentials and sensitive customer data from test evidence.
6. How do path, query and body inputs differ?
Their roles are defined by the interface contract. A path commonly identifies a resource, query parameters can refine a request, and body content can carry a structured representation or command. These conventions are not permission to move inputs between locations and expect identical behavior.
An order ID in the path and a customer ID inside an order body may have different validation and authorization implications. I would test the documented locations, encoding and missing-value behavior. I would also avoid placing secrets in a query merely because it is convenient, since URLs can be recorded by several parts of a system.
7. Why should a test verify the HTTP method?
The method contributes to the operation’s meaning; the same path can support different actions for different methods. Tests should verify both supported methods and the contract’s behavior for inappropriate ones. A path that responds to GET does not establish how POST or DELETE should behave.
For example, reading an order and creating an order may share a collection namespace but have different inputs and effects. I would not send an unintended write method against a live service to explore it. Authorized tests should operate in a controlled environment with explicit expectations about any state change.
8. What should you verify for a GET request?
GET requests a representation of the target resource and has safe semantics: the client is not requesting a state-changing operation. A test should verify the selected representation and relevant contract details. Incidental effects such as access logging do not mean every server-side change violates that semantic distinction.
For a customer lookup, I would verify that the correct customer is returned and that performing the read does not submit an order or alter a business field. I would not assume that a body on GET has portable application meaning; the API’s supported request contract should determine how inputs are supplied.
9. What should you verify for a POST request?
POST asks the target resource to process the supplied representation according to its own semantics. It is often used for creation, but it is not limited to that purpose. A test should identify the operation’s intended effect and verify the response and resulting state together.
For a synthetic order-creation contract, I would check the generated identity, submitted fields and computed total, then confirm that the expected record exists. I would not assume every successful POST returns 201 or is safe to repeat automatically. Those outcomes depend on the operation and its documented processing rules.
10. How would you explain PUT at a basic level?
PUT expresses creation or replacement of the target resource’s state with the supplied representation, subject to the server’s constraints. Tests need to understand which representation the contract expects and which fields are server-managed. It should not be treated as a generic synonym for any update.
If the contract describes a complete preferences representation, omitting a field may have a different meaning from leaving that field unchanged. I would verify the documented behavior rather than infer partial-update semantics from a successful response. I would also distinguish the requested resource state from incidental response fields such as modification timestamps.
11. What should a DELETE test verify?
A DELETE test should verify the contract’s removal behavior and the consequences visible through the interface. The request concerns the association or resource exposed by the target URI; it does not by itself prove physical erasure from every storage system or backup. Retention behavior needs a separate requirement.
For a disposable test record, I would verify the response and the subsequent lookup behavior expected by the contract. A second deletion may produce a different status while still having the same intended effect. I would not require identical responses merely because the operation has idempotent semantics.
12. How do safe and idempotent methods differ?
Safe semantics mean the client does not request a state change. Idempotent semantics mean repeating an identical request has the same intended server effect as making it once. These concepts do not require identical responses, nor do they guarantee that a poorly implemented endpoint follows its declared method semantics.
Repeated deletion can leave a resource absent even if the first response and later response differ. A read can update access logs without becoming a requested business mutation. In tests I would identify the relevant business state and verify that property, rather than compare every response byte and call it an idempotency test.
13. What does a successful HTTP status establish?
A successful status communicates HTTP-level success according to its specific semantics, but it is not a complete assertion of business correctness. The body and any resulting state must still satisfy the operation’s contract. A test that accepts every 2xx status can miss a meaningful behavior change.
An order endpoint might respond with a successful status while calculating the wrong tax or returning another user’s order. I would assert the exact permitted status and the meaningful result. Where several statuses are legitimate, I would explain the condition for each rather than permit an unexplained broad range.
14. How do 200, 201, 202 and 204 differ?
They describe different successful outcomes: 200 indicates success, 201 indicates creation, 202 indicates acceptance without completed processing, and 204 indicates success with no response content. A client test should reflect the operation’s actual contract rather than interpret all four as a completed result with JSON.
If a request receives 202, the test must not immediately claim the requested work is finished solely from that response. For 204, it should not demand a JSON object. These distinctions guide the next check: inspect the created representation when promised, or verify completion through the contract’s supported mechanism when processing is deferred.
15. How should you test an error response?
I would verify the agreed status, stable machine-readable error information and the absence of an unintended state change. The message should be useful without exposing sensitive internals. A negative test succeeds when the API rejects the request correctly, not when the test framework itself crashes.
For an invalid quantity, I would check the error code or field identifier defined by the contract and confirm that no order was created. Matching the complete human-readable sentence may be unnecessarily brittle if wording can change. I would not accept a server exception just because the invalid request did not succeed.
16. What is the practical distinction between 401 and 403?
401 indicates that the request lacks valid authentication credentials for the target resource and includes the applicable authentication challenge. 403 indicates that the server understands the request but refuses it. The API’s disclosure policy can affect what a caller sees, so tests should follow the documented contract.
I would separately test an absent or invalid credential and a valid identity lacking permission. Those are different preconditions even if the product deliberately avoids revealing some resource details. Treating every denial as “login failed” can conceal authorization defects or produce misleading client behavior.
17. Why should tests inspect response headers?
Response fields can affect how a client interprets content, follows the operation or handles the result. They are part of the contract rather than decorative metadata. A body assertion alone can miss a response whose declared representation differs from the actual content.
For a JSON response, I would verify the expected media type in a case-appropriate parser rather than demand an exact raw header string with one particular spacing. I would also inspect operation-specific fields where the contract requires them. Tests should assert meaningful semantics, not incidental header ordering.
18. How do Content-Type and Accept differ?
Content-Type describes the media type of the representation being sent, whereas Accept communicates the response media types the client is willing to receive. They operate in different directions. Setting one does not automatically establish the other or guarantee the server supports the requested representation.
A client can send JSON while requesting a particular response format. I would test the documented supported combinations and unsupported-content behavior, rather than assume every endpoint consumes and returns JSON. A server returning an HTML error page where a JSON error is promised should be detected even if the status is otherwise expected.
19. What makes a payload valid JSON?
Valid JSON must satisfy JSON syntax and value rules. It can contain objects, arrays, strings, numbers, booleans or null; the top-level value is not universally required to be an object. Valid syntax alone does not mean the payload satisfies an API’s schema or business rules.
A body containing a quoted quantity can parse as JSON while violating a contract that requires an integer. I would separate parser failures from schema failures and domain failures so the test explains what went wrong. Duplicate object member names are an interoperability hazard and should not be relied upon to carry distinct values.
20. How should you compare JSON responses?
I would parse JSON and compare the meaningful structure and values rather than compare raw text formatting. Object member order and whitespace are generally not the business contract; array ordering may be meaningful. The test should explicitly identify fields whose values are dynamic.
Two serialized objects can differ in spacing and key order while representing the same result. An array of ranked products is different: changing its order can change the response meaning. I would not sort every array merely to make the assertion pass.
21. How do missing, null and empty values differ in an API?
An omitted property, an explicit null and an empty value can have different meanings. The contract must define those meanings for each field and operation. Treating them as equivalent can break partial updates, validation or client defaults.
For a nickname, omission might mean “leave unchanged,” null might mean “clear it,” and an empty string might be rejected. Another API can choose different rules. I would create separate test cases for all three rather than send one blank example and claim missing-value coverage.
22. What is schema validation, and what does it miss?
Schema validation checks declared structural rules such as types, required properties and constraints supported by the selected schema dialect and validator. It can detect many contract violations, but it cannot establish every business relationship or side effect. A structurally correct response can still be wrong.
An order object can contain valid numeric fields while its total disagrees with its line items. I would add an explicit business assertion for that relationship. I would also verify the OpenAPI and schema versions used by the tool, because unsupported keywords can create a false impression that a rule was checked.
23. How does an OpenAPI description help API testing?
OpenAPI describes HTTP API operations, parameters, representations, responses and related contract information in a machine-readable format. It can guide coverage and support tooling, but it is a description, not proof that an implementation behaves accordingly. It also does not describe every possible non-HTTP API.
I would use the declared operations and response schemas to identify missing tests, then add examples for business rules not fully captured there. If documentation and implementation disagree, the discrepancy needs resolution. Generating tests from the same mistaken document does not independently establish the correct business behavior.
24. What is the difference between authentication and authorization?
Authentication establishes the identity or credential context of a caller; authorization decides what that caller may do with a particular operation or resource. A valid login does not imply access to every record. Tests need to distinguish those concerns explicitly.
Using two synthetic users and separate test-owned records, I would verify that each user can access permitted records and cannot access the other’s restricted record. This is an authorized fixture-based check, not probing arbitrary real identifiers. A success test with one administrator identity cannot demonstrate that ordinary-user access is correct.
25. What basic credential cases should an API test cover?
I would cover the credential states relevant to the supported authentication scheme, such as valid, missing, malformed or expired credentials when expiry applies. Each case needs an expected outcome and appropriate test identities. The goal is to verify the contract without leaking secrets into fixtures or logs.
A fabricated token string is not a substitute for a controlled valid test credential when checking an authenticated path. Conversely, an offline unit test can simulate the authentication result without claiming to have validated the real identity provider. I would state which boundary the test actually exercised.
26. Why is testing access to individual objects important?
An API can authenticate a caller correctly while failing to verify permission for the requested object. Object-level authorization checks must follow the relevant record and user relationship, not just the presence of a token. OWASP identifies this as a distinct API security concern.
For a controlled fixture, user A owns record A and user B owns record B. The test checks permitted access and cross-user denial using only those authorized records. It should also verify that denied responses do not leak the protected record. Randomizing IDs is not evidence that authorization is enforced.
27. How do positive and negative tests complement each other?
Positive tests verify that valid requests produce the intended result. Negative tests verify that invalid or unauthorized requests are handled correctly and safely. Both need precise expectations; a suite of rejected requests cannot establish that the useful workflow works.
For a quantity restricted to 1 through 10, a valid quantity of 4 should succeed while 0 should be rejected without creating an order. A negative case should normally change one relevant condition from a valid baseline. If several inputs are invalid at once, the observed error may not demonstrate which validation rule was exercised.
28. How would you apply boundary-value testing to an API?
I would identify allowed ranges and test values at, immediately inside and immediately outside their boundaries. Boundary defects often occur where inclusive and exclusive comparisons differ. The data type and measurement unit must be clear before selecting test values.
For an integer quantity from 1 through 10, useful cases include 0, 1, 2, 9, 10 and 11. For a text length limit, I would clarify whether length means bytes, code points or another measure instead of assuming every character occupies one byte. Boundaries come from the contract, not from arbitrary “large” values.
29. What is equivalence partitioning in API test design?
Equivalence partitioning groups inputs expected to receive the same kind of treatment so a representative can exercise each class. It helps avoid many redundant examples while retaining meaningful coverage. The partitions must be justified by rules and risk, not by visual similarity alone.
An integer quantity might have valid-range, below-range, above-range and wrong-type classes. A missing value may form another class if it has a separate rule. I would combine this approach with boundary checks because two values in a broad invalid class can still reveal different edge behavior near a limit.
30. Why should malformed syntax and invalid business data be separate tests?
Malformed syntax prevents the payload from being interpreted as intended, while invalid business data can be structurally understandable but disallowed. These failures occur at different boundaries and may require different error contracts. Combining them can prevent the business validation from being reached.
A truncated JSON document tests parsing. A well-formed object with a negative quantity tests a domain rule if the schema permits that type. I would start with a valid request and alter the relevant aspect so the resulting failure is attributable. An arbitrary damaged payload is not evidence that all validation paths work.
31. What is a useful business assertion beyond status and schema?
A business assertion checks a relationship or outcome that matters to the domain, such as a total, ownership assignment or state transition. It should be derived independently enough to detect a plausible defect rather than repeat the implementation’s exact algorithm without scrutiny.
For a small order fixture, I can calculate the expected total in integer minor units and compare it with the returned amount. That avoids binary floating-point ambiguity for this deliberately simplified example. Real rounding, tax and currency rules need their own contract; the fixture does not establish them.
32. Why should a write-operation test check state after the response?
The response can claim success without the intended change being observable or correctly stored. A follow-up state check verifies the effect through a suitable supported interface or controlled test boundary. It must respect whether the operation completes synchronously or asynchronously.
After creating a synthetic address, I would retrieve the resulting record and compare the relevant fields if immediate visibility is part of the contract. If completion is deferred, an immediate read is not automatically a valid failure oracle. The test must wait through the documented mechanism and bounded expectations rather than hide uncertainty with an arbitrary long sleep.
33. How do you keep test data isolated?
Each test should control the data it depends on and avoid conflicting with other tests or users. Unique fixture identities, explicit ownership and a known initial state reduce accidental coupling. Isolation is about behavior as well as naming: shared counters or global settings can still interfere.
Two tests editing the same “default customer” may pass individually and fail together. I would give them separate records or restore a controlled state at the relevant boundary. Real customer data is unnecessary for these fixtures, and isolation should not rely on running tests only when nobody else is using the environment.
34. Why is cleanup part of API test design?
Tests that create state need a deliberate way to remove or otherwise retire it so future runs remain interpretable. Cleanup should target only test-owned resources and should be considered even when an assertion fails. A cleanup failure is information to report, not a reason to conceal the original failure.
I would retain the created test record’s identity and use an authorized cleanup path with a clear ownership marker. Deleting everything matching a broad customer name risks touching unrelated data. Where cleanup is intentionally deferred for investigation, the evidence should record what remains so the next run does not mistake it for its own result.
35. What is a mock or stub useful for in API testing?
A test double supplies controlled behavior in place of a dependency so a test can exercise a particular boundary deterministically. Terminology varies: a stub often supplies responses, while a mock may also verify expected interactions. Neither establishes that the real dependency behaves the same way.
A local double can return a documented validation failure so a client’s handling is easy to test. That does not verify TLS, authentication, serialization across a real connection or the provider’s deployment. I would state what the double replaces and complement it with appropriate integration checks when the task requires those boundaries.
36. How does a unit-level API test differ from an integration test?
A unit-level test isolates a focused behavior, often with controlled dependencies, while an integration test exercises interaction across real components. The distinction concerns the boundaries executed, not simply whether the test sends an HTTP-looking object. Both can be valuable with honest scope.
A handler called directly with an in-memory request may verify validation but bypass routing and network serialization. A deployed-environment test can cover more layers but introduces additional failure causes. I would choose the smallest boundary that proves the intended property and avoid claiming end-to-end coverage from a local function test.
37. How should dynamic response fields be asserted?
I would assert the properties the contract guarantees rather than hard-code values that legitimately change. A generated identifier may need to be present, correctly shaped and usable for a later lookup. A timestamp may need a valid representation and relationship to the tested event.
Ignoring every dynamic field is too weak, but matching one fixed generated ID is brittle. I would also distinguish formatting checks from meaning: a timestamp can parse successfully and still describe the wrong event. Where precise timing matters, a controlled clock or a documented tolerance makes the expectation clearer.
38. What makes an API test deterministic?
A deterministic test produces the same result for the same controlled conditions. It needs stable fixtures and explicit handling of variable inputs such as time, random values, ordering and dependencies. Determinism does not mean forcing an unreliable service to pass through repeated retries.
A response containing an unordered collection should be compared according to that contract, while a ranked list should preserve order in the assertion. If a test sometimes fails because another test edits its record, the fix is isolation. Increasing timeouts or rerunning automatically can hide the cause without improving the test’s evidence.
39. What evidence belongs in an API defect report?
I would include the environment and relevant version, minimal reproducible input, expected behavior, observed response and the state or assertion that demonstrates the difference. A correlation identifier can help the team find server-side evidence where supported. Logs should be sanitized before sharing.
“The endpoint failed” is less useful than “this valid fixture returned total 300 instead of 330, with these two line items.” I would distinguish confirmed facts from suspected causes and include whether the failure reproduces. Credentials, session tokens and unrelated personal records should not be copied into the report to make it look complete.
40. How would you explain the limits of a passing API test suite?
A passing suite shows that the covered cases behaved as asserted in the tested environment. It does not prove that every input, user role, deployment or failure mode works. Coverage should be described in terms of behaviors and boundaries rather than a raw test count.
For example, the offline fixtures in this article check parsing and assertion logic, not a running HTTP service. A real suite should identify important untested areas and use risk to guide additional work. Ten focused cases with strong oracles can provide more useful evidence than hundreds of requests that only assert a successful status.
API Testing Interview Questions and Answers for Intermediate
These answers examine edge cases and interactions between clients and services. A useful test distinguishes valid variations from failures without assuming every API shares the same contract.
41. How do you test ambiguity in oneOf and anyOf schemas?
oneOf requires an instance to satisfy exactly one subschema, while anyOf requires at least one. I test values matching none, exactly one, and several branches instead of assuming composition behaves like the first successful branch of an if/else statement. Overlapping definitions can make a seemingly valid oneOf payload invalid.
For example, if one branch accepts every number and another accepts integers, the value 2 matches both: it satisfies anyOf but fails oneOf. A decimal such as 2.5 matches only the number branch. For object variants, I test required distinguishing fields and branch overlap with the declared OpenAPI version and schema dialect; a discriminator should not be treated as a substitute for validating the actual branch constraints.
42. How would you test query-parameter serialization for arrays and reserved characters?
I derive the wire representation from the parameter’s documented style, explode setting, and encoding rules rather than from the client library’s default. Repeated parameters and delimiter-separated values can represent arrays differently. I verify what the server actually interprets, including empty arrays and duplicate entries where the contract defines them.
For an OpenAPI query array using form style, explode true can serialize two values as tag=red&tag=blue, while explode false uses a comma-separated value. I also include an element containing a delimiter or reserved character and verify the specified percent-encoding behavior. Comparing only the final URL text is insufficient if the server parses a different value; I check the interpreted filter and result set without assuming every framework handles repeated keys identically.
43. Why must OpenAPI tests use the document’s declared version?
OpenAPI versions differ in schema vocabulary and interpretation, so the validator must understand the declared specification and relevant schema dialect. The document’s openapi version is distinct from the API’s own info.version. A tool accepting the file does not establish that it enforced every keyword.
For example, OpenAPI 3.1 uses JSON Schema-based null types, while older 3.0 schemas commonly use nullable. I test a known invalid instance to confirm enforcement, including format behavior where the tool treats formats as annotations. I do not mechanically copy keywords between versions and assume the resulting contract means the same thing.
44. How would you assess whether a response change is backward compatible?
I examine actual consumer expectations, not only whether the new schema is valid. Removing a field, changing its type, narrowing allowed values, or altering meaning can break clients. Even an additive change can affect consumers that reject unknown properties or exhaustively handle enum values.
Adding a new status value may be valid for the provider but crash a client that recognizes only pending and complete. I combine specification comparison with representative consumer tests and a documented evolution policy. A version number alone does not prove compatibility, and a passing provider test cannot demonstrate how every deployed client parses the response.
45. How should unknown request properties be tested?
I verify the contract’s rule for additional properties and ensure sensitive internal fields cannot be set simply because the payload contains them. An API may reject unknown fields or ignore permitted extras, but the behavior should be deliberate and observable. Silent acceptance must not imply unauthorized mutation.
A create-user request containing an unexpected privileged property should not grant that privilege. I check the persisted representation and subsequent permissions, not only the response status. For harmless typos, rejecting the request may provide clearer feedback than ignoring the field; whichever policy is chosen should be consistent across relevant endpoints.
46. How do you test numeric precision and boundary values?
I select values around documented limits and verify representation, rounding, overflow, and cross-field arithmetic. JSON numbers do not guarantee that every client uses the same internal precision. Identifiers and money may require explicit string or decimal conventions.
For a two-decimal currency amount, I test a rounding boundary and compare the result using decimal arithmetic rather than binary floating-point equality. I also include a large identifier that exceeds a common client’s exact integer range if the API permits it. The expected result should follow the contract, not the accidental behavior of the test runner’s numeric type.
47. How would you test offset pagination on a stable dataset?
I create a known ordered dataset, fetch every page, and verify coverage, duplicates, page boundaries, and termination. I include an empty dataset, a partial final page, and an exact multiple of page size. The ordering must include a deterministic tie-breaker.
For five records and page size two, I expect pages of two, two, and one under the stated contract. I compare collected identifiers with the fixture, not just each page’s length. I also test invalid or excessive limits and offsets, because a server that returns the first page repeatedly can pass superficial length checks while never progressing.
48. What additional cases matter for cursor pagination?
I treat cursors as opaque tokens and test progression, invalid tokens, expiry if specified, and their relationship to filters and sorting. A cursor from one query should not silently produce misleading results for an incompatible query. Snapshot and concurrent-update guarantees must be stated rather than assumed.
I fetch a page, change a filter, and verify the documented rejection or restart behavior. I also exercise tied sort values and a final page without a continuation token. Base64-decoding a cursor does not authorize the client to construct arbitrary positions; the test should follow the public contract rather than depend on internal token layout.
49. How should pagination be tested while records change?
I first identify whether the API promises a stable snapshot, best-effort traversal, or another consistency model. Then I introduce controlled inserts, updates, and deletions between pages and compare the observed result with that promise. Different pagination strategies have different failure boundaries.
An insertion before an offset can shift rows and create a duplicate on the next page. A cursor can avoid some shifts but does not automatically capture late updates or provide a snapshot. I test the documented behavior and make any consumer reconciliation requirement explicit instead of declaring one pagination mechanism universally free of omissions.
50. How would you test combined filtering and sorting?
I build records that distinguish each predicate and the requested sort directions, including ties and nulls where supported. I verify the full predicate logic and a stable secondary order. A dataset where every row satisfies every filter cannot expose an AND-versus-OR error.
For status equals open and amount above 100, I include an open low-value row and a closed high-value row that must both be excluded. I then check the order of qualifying rows and the documented null placement. I use allowed field names and operators to test query validation without relying on undocumented internal query syntax.
51. How do you test an ETag-based conditional GET?
I retrieve the representation and its ETag, then request it with If-None-Match. For an unchanged representation, the expected conditional response is typically 304 with no representation body under the HTTP contract. After a meaningful update, the response should provide the new representation and an appropriate validator.
I keep the request’s relevant representation-selection headers consistent so I am validating the same variant. I also test a stale validator and confirm that the client retains its cached body correctly after 304. The test should not require ETags to follow a particular hash format; validators are opaque to the client.
52. How does If-Match help prevent lost updates?
If-Match makes a state-changing request conditional on a matching current validator, using strong comparison. It lets the server reject a stale client update rather than overwrite a newer version unknowingly. I test both the successful current-version path and the failed stale-version path.
Two clients read version A; the first updates it to B, and the second submits an update with A. The second should receive the contract’s precondition-failure behavior, commonly 412, and the first client’s change should remain. Checking only the error response is insufficient: I read the resource again to verify that the rejected update had no unintended effect.
53. How do weak and strong ETags affect testing?
A weak validator indicates semantic equivalence rather than the byte-for-byte strength needed by some conditional operations. Strong and weak comparison rules differ by header. I do not strip the W/ prefix and treat the values as interchangeable.
If-None-Match uses weak comparison for cache validation, while If-Match requires strong comparison. A weak tag should therefore not satisfy a strong If-Match condition merely because its opaque value resembles the current tag. I test the actual header semantics and representation variants rather than assume every server-generated ETag is suitable for optimistic write concurrency.
54. What is the difference between no-cache and no-store?
no-cache allows storage but requires successful validation before reuse under its semantics; no-store instructs caches not to store the relevant request or response. private restricts shared-cache storage rather than banning every cache. These directives control different behaviors and should not be treated as synonyms.
For a personalized response, I inspect the intended shared-cache policy and verify behavior through the relevant cache layer in an authorized environment. A header assertion alone does not prove a deployed proxy honors the design. I also avoid promising that no-store erases copies already stored elsewhere or provides a substitute for transport security and authorization.
55. How would you test cache variation without leaking one user’s data to another?
I identify the headers or request context that select a representation and test separate clients through the cache path. Vary contributes to representation selection for named request headers, but personalized caching also requires an appropriate authorization and cache-control design. I do not assume adding Vary alone makes sensitive data safe.
I request a resource as two synthetic users with different permitted views and verify that each receives only the expected fields. I repeat requests to exercise cache hits, not just cold responses. I also test relevant language or encoding variants so a cache key error does not serve one representation to a client that requested another.
56. How would you test PATCH atomicity and patch-document semantics?
PATCH applies a set of changes expressed in a supported patch format. I first check the request media type and the format’s rules; a JSON object alone does not define universal PATCH semantics. The server must apply the whole patch atomically: if it cannot apply all changes, none should take effect.
For a synthetic profile, submit a patch whose first change is valid but whose later operation fails under the supported format. Retrieve the resource and verify that the earlier change was not left behind. Also test an unsupported patch media type and stale base-version protection where needed. PATCH is not inherently idempotent: setting a field and appending an item can behave differently when repeated, so retry expectations must follow the specific operation.
57. What should an idempotency-key test cover?
I test repeated requests with the same key and payload, reuse with a different payload, concurrent duplicates, key scope, and expiry according to the API’s policy. The key is an application contract, not a universal guarantee attached to every POST. I verify the durable business effect as well as the returned result.
Two attempts to create the same synthetic order should not create two orders when the contract promises deduplication. If the same key is reused for a different amount, the documented conflict behavior should prevent silent substitution. I also test tenant separation so one customer’s key cannot retrieve or suppress another customer’s operation.
58. How would you test a timeout after the server may have committed?
I model the uncertain outcome explicitly: the client did not receive success, but the server may already have performed the operation. The recovery test should reconcile using an operation identifier, idempotency mechanism, or authoritative state query before creating another independent operation.
In a controlled test harness, I can simulate losing the response after a synthetic write completes. A retry with the same business identity should resolve to the original effect when that is the contract. Simply asserting that the client retries on timeout is inadequate; the important question is whether the retry can duplicate the completed work.
59. How should retry backoff be tested?
I verify which failures are retryable, the maximum attempts or time budget, delay growth, jitter bounds, and the terminal outcome. A fake clock or injected scheduler makes timing assertions deterministic without waiting in real time. Retry behavior should also respect operation idempotency.
For a policy with delays capped at a maximum, I can assert each computed delay is within its allowed range and that no extra attempt occurs after the budget is exhausted. I avoid requiring one exact random jitter value. Permanent validation failures should stop promptly rather than consume the same retry budget as temporary availability errors.
60. How do you test Retry-After handling?
I cover both supported HTTP-date and delay-seconds forms, as well as missing or invalid values under the client’s policy. The client should combine the server guidance with its own overall deadline and retry rules. Retry-After is not a promise that the next request will succeed.
Using a fixed test clock, I verify a future date produces an appropriate wait and a past date does not create a negative delay. I also test that a very long server delay does not bypass a shorter user deadline. The chosen response statuses and retry behavior should follow the API contract and HTTP semantics, not a rule that every error carries the same header.
61. How would you test rate limiting safely?
I use a controlled environment and an agreed request budget to test the documented limit scope, response behavior, and recovery. Limits may apply per identity, tenant, route, or another dimension. I do not infer the production capacity from an uncontrolled burst.
With a small configured test quota, I verify allowed requests succeed, excess requests receive the defined response, and service resumes after the relevant window or replenishment. I test independent synthetic tenants where isolation is promised. Rate-limit headers and exact counters are API-specific, so I avoid hard-coding conventions that the service does not advertise.
62. What should you verify for a 202 Accepted workflow?
202 indicates acceptance for processing, not successful completion of the requested operation. I test the documented status resource or completion mechanism, state transitions, failure reporting, and correlation to the original request. The initial response must provide the information the client needs under the API’s contract.
A job may move from pending to running to succeeded or failed. I verify that a failed job exposes a useful outcome and does not remain indefinitely reported as accepted. I also check that the status endpoint enforces ownership; knowing a job identifier should not reveal another tenant’s task or result.
63. How should polling tests avoid arbitrary sleeps?
I poll for a defined condition with bounded intervals and an overall deadline, using deterministic simulated state transitions where possible. I distinguish an expected intermediate state from a terminal failure. A fixed long sleep can make tests slow while still failing under different timing.
For a synthetic job that succeeds on the third observation, I verify the client stops immediately after success and does not poll again. I also test never-completing and terminal-failure cases. Polling success should validate the resulting business state, not only the status word, because a job can claim completion while returning an incomplete artifact.
64. How would you test cancellation of an asynchronous API job?
I verify which job states allow cancellation and whether the cancellation request means requested or completed. A race between cancellation and normal completion should have a documented outcome. The test must examine final state and any partial effects rather than assume cancellation reverses all prior work.
If a job has already committed its result, the API may reject cancellation or report that completion won the race. If cancellation is accepted while running, I wait for the terminal state and inspect cleanup according to the contract. Repeated cancellation should also behave predictably without creating a new job or losing the original result.
65. What should a webhook-delivery test verify beyond the payload?
I check event identity, authentication, delivery retries, acknowledgment semantics, and the receiver’s durable handling. A sender receiving a successful HTTP response does not automatically prove the business action completed unless the receiver’s contract defines that acknowledgment accordingly.
A receiver might acknowledge after safely placing the event in its own queue, then process it later. I test a failure before durable acceptance separately from a failure during processing. I also verify that malformed events do not produce a success response that causes permanent loss of required work, while avoiding retries for events the contract explicitly rejects permanently.
66. How do you test webhook signatures and replay protection?
I follow the provider’s exact signing contract, including which bytes and metadata are signed, permitted algorithms, and time tolerance. Verification should occur before trusting the payload. I use synthetic secrets and offline fixtures rather than real credentials.
Reformatting JSON before verification can change the bytes and invalidate an otherwise correct signature, so I test the raw-body requirement where specified. I also test a modified body, wrong key, missing signature, and expired timestamp. A valid signature proves the signed message’s authenticity under the key; replay prevention still requires the documented timestamp and event-identity handling.
67. How should webhook duplicates and out-of-order events be tested?
I deliver the same event more than once and deliberately reverse related event order in a controlled fixture. The receiver should follow its stated deduplication and versioning policy rather than assume network arrival order equals business order. Transport identity and business identity may serve different purposes.
If an update at version 3 arrives before version 2, applying both blindly can restore stale state. I verify that the receiver rejects, buffers, or reconciles the older version according to the design. A single successful ordered delivery test does not establish correctness under common retry and delay conditions.
68. How do GraphQL assertions differ from ordinary status-code checks?
I inspect the GraphQL response’s data and errors, including paths and partial results, rather than treat HTTP success as proof that every requested field succeeded. Request validation errors and field-execution errors have different response implications. HTTP behavior also depends on the supported transport contract.
A query can return a user name while a protected field is null with an error. The test should verify both the useful data and the denied field’s behavior. I avoid an assertion that every response containing errors must have no data, because partial execution results are a legitimate GraphQL outcome.
69. How should GraphQL nullability be tested?
I test nullable fields, non-null fields, and how execution errors propagate through non-null positions. The schema’s nullability is part of the client contract, not merely documentation. A failure in a required child field can affect a larger parent portion of the response.
For a non-null field that cannot be resolved, I verify the expected error path and resulting null propagation rather than accept an arbitrary null inserted at that field. I also distinguish request validation failures, which occur before execution, from resolver failures. This helps clients handle partial data without incorrectly assuming that every absent value means no error occurred.
70. What resource-control cases matter for GraphQL APIs?
I test the service’s documented controls on query depth, complexity, pagination, aliases, and repeated or batched work in an authorized environment. A single endpoint can expose widely varying server workloads depending on the operation. Schema validity alone does not establish acceptable cost.
A shallow query requesting a huge list can be expensive even if depth is low. Conversely, rejecting every nested query may prevent legitimate use. I use small controlled cases around configured limits and verify clear failure behavior, rather than conduct unbounded stress requests or assume one universal complexity rule fits every schema.
71. How do gRPC status assertions differ from HTTP status assertions?
A gRPC client observes the RPC status and associated details according to the gRPC protocol, not merely the underlying HTTP transport status. I assert the appropriate gRPC code and application result, including metadata where part of the contract. An HTTP transport success alone can coexist with an RPC failure.
I distinguish INVALID_ARGUMENT from a state-dependent FAILED_PRECONDITION or a temporary UNAVAILABLE response according to the service contract. That distinction affects client recovery. I avoid converting every non-OK code into the same retry path, because retrying an invalid request does not repair it.
72. How would you test gRPC deadlines?
I set explicit test deadlines and verify both client behavior when time expires and server handling of cancellation or abandoned work. A deadline limits willingness to wait; it does not prove that no server-side effect occurred. Propagation across downstream RPCs matters in a multi-service operation.
A controlled slow handler can establish that the client reports DEADLINE_EXCEEDED within the allowed tolerance. I then inspect whether the server stops unnecessary work and whether any completed effect requires reconciliation. I do not use a timeout assertion as evidence of transaction rollback or assume the default client configuration always supplies a useful deadline.
73. What additional cases do streaming RPC tests need?
Streaming tests cover message order under the contract, partial streams, end-of-stream status, cancellation, and flow-control behavior. Receiving several valid messages does not prove that the stream completed successfully. The final status can change how the client should interpret a partial result.
For a server stream of three synthetic records, I test normal completion, a failure after the second record, and client cancellation. I verify whether partial records are retained or discarded according to the consumer’s requirement. For bidirectional streams, I also test independent send and receive progress rather than assume a simple request-response sequence.
74. How do you test object-level authorization across tenants?
I create synthetic users and objects with known ownership, then attempt the same operation using the owner, another tenant’s user, and other relevant roles. I test reads, writes, deletes, and indirect access paths. Authentication success does not establish authorization to every supplied object identifier.
A user who can read their own invoice should not gain another tenant’s invoice by changing the identifier. I verify both response disclosure and persisted state, including child resources and exports. The expected denial may use different statuses under the API’s policy; the essential assertion is that unauthorized data and effects are prevented consistently.
75. How does property-level authorization differ from object-level authorization?
A caller may be allowed to access a record while lacking permission to read or modify particular properties. I test response fields and request fields separately, including nested objects. Hiding a field in a UI does not prevent a client from requesting or submitting it directly.
For an employee profile, ordinary users might update a display name but not a role or compensation field. I submit a mixed payload and verify the documented rejection or permitted-field behavior, then inspect stored values. I also check serialization so a sensitive property is not returned merely because the caller has access to the containing record.
76. How do you test function-level authorization?
I verify that role or capability checks apply to the operation itself, including administrative and bulk endpoints. Access to ordinary objects should not automatically allow an export, approval, or privileged maintenance action. I use a role-operation matrix with explicit allowed and denied cases.
A support user might view a customer but not deactivate the customer’s account. I test the privileged operation directly with that user’s authorized test identity instead of assuming a hidden menu protects it. I also cover alternate routes and methods that perform the same business action so one unprotected endpoint does not bypass the intended boundary.
77. What should JWT validation tests check beyond decoding the payload?
Decoding only reveals claims; it does not authenticate them. I verify cryptographic validation using the configured algorithms and trusted keys, then the required issuer, audience, time, and token-type rules for the application’s token profile. A well-formed token can still be unacceptable.
Using controlled test tokens, I cover a wrong audience, wrong issuer, expired token, invalid signature, and a disallowed algorithm. I do not let an untrusted token header select arbitrary verification behavior or key locations. The required claims depend on the profile, so I avoid asserting that every optional JWT claim is universally mandatory.
78. How should clock skew and key rotation be tested for tokens?
I use a controlled clock to test expiry and not-before boundaries with the explicitly permitted tolerance. For key rotation, I verify acceptance of valid active keys and rejection of untrusted or retired keys according to the rotation policy. Caching and refresh behavior should be bounded and observable.
A token just outside the allowed time window should not remain valid because the implementation applies tolerance repeatedly. An unknown key identifier should trigger only the approved lookup behavior, not an arbitrary network fetch chosen by the token. I also test that a temporary key-refresh failure does not silently disable signature validation.
79. How would you test RFC 9457 Problem Details responses and clients?
For an API using application/problem+json, I verify the problem type identity, defined members and documented extensions. The type URI identifies the problem category; instance identifies an occurrence. A producer’s optional status member must match its HTTP response status, while consumers must recognize that an intermediary can alter the HTTP status.
Using a synthetic validation problem, verify the documented field-error extension and that the client tolerates an unfamiliar extension. Test an omitted type as the default about:blank, and keep client decisions independent of localized title or occurrence-specific detail wording. Do not automatically fetch arbitrary type URIs during ordinary handling. This checks a defined error format and its evolution rules, rather than imposing Problem Details on APIs with a different contract.
80. How can a stateful model strengthen API tests?
A small reference model can track the intended state transitions and compare API observations with independently computed expectations. It is especially useful for sequences such as create, update, retry, and delete, where isolated requests miss interaction defects. The model must express the contract rather than copy server implementation details.
For an inventory reservation, I can model available quantity and active reservations, then generate bounded sequences of reserve, release, and repeated operation IDs. I assert that availability never goes below the permitted bound and duplicate releases do not add stock twice. Offline model checks validate the oracle logic; they do not replace authorized integration tests against the service.
Offline Python reference model — This narrow fixture preserves completed operation IDs, accepts only known reservation IDs for release, and does not support reusing a released ID for a new reservation. It checks duplicate effects in memory; it does not model concurrent requests or durable storage. The fixture assumes positive integer quantities supplied by the test generator; it does not validate zero, negative, boolean or non-integer inputs, which require separate contract tests.
API Testing Interview Questions and Answers for Experienced
Look for explicit invariants, representative workloads and a recovery-aware test strategy. Experienced candidates explain what their evidence proves, what remains uncertain and how that uncertainty affects a release decision.
81. How would you prioritize API tests when release time is limited?
I would rank failures by business impact, likelihood and detectability, then select evidence for the highest-risk changes and dependencies. Coverage should reflect consequential behavior rather than simply the number of endpoints exercised.
For a checkout change, authorization, total correctness and duplicate-order prevention may matter more than every optional response field. Preserve a small critical regression set and target the changed paths with negative cases. Document important gaps and who accepts the residual risk; a shortened suite should not be reported as complete validation.
82. How would you design a test architecture for many services?
I would assign each behavior to the lowest practical test boundary that can verify it accurately, with a limited set of end-to-end journeys for cross-service outcomes. Service-level tests, contract checks and integrated tests provide different evidence.
A pricing rule can often be tested deterministically within its service, while order acceptance needs a cross-boundary check. Avoid reproducing every rule through a slow shared environment. Define ownership for contracts and test data so a failing journey can be traced to a responsible boundary rather than dismissed as somebody else’s flaky test.
83. How would you create a reliable test oracle for a complex API?
I would define expected behavior from an independent business rule, known fixture or invariant rather than calculate the expected value using the same implementation under test. An oracle must be able to disagree with a defective result.
For allocation, a small hand-worked example can establish exact outputs, while conservation and nonnegative-balance checks cover larger cases. A copied algorithm in the test may reproduce the same bug. Combine exact examples with properties and have domain owners confirm ambiguous rules before turning them into automated assertions.
84. When would you use metamorphic testing for an API?
I would use it when the exact output is difficult to calculate but a justified relationship between transformed inputs and outputs is known. The relationship must follow the domain contract rather than a convenient assumption.
For an order-independent aggregation, permuting records should preserve the total; duplicating them may double an additive measure. Those properties would be wrong for a deduplicating or sequence-sensitive service. State the preconditions and pair the checks with known examples. Metamorphic success does not prove every output is correct, but can reveal defects beyond a narrow golden dataset.
85. How would you detect specification drift?
I would compare the deployed behavior with the approved contract and investigate whether differences are implementation defects, stale documentation or intentional changes awaiting governance. Generated documentation alone is not an independent specification.
A field may remain present but change its unit or null meaning, passing structural validation while breaking consumers. Combine schema checks with semantic examples and consumer evidence. Pin the specification version used by tooling and review intentional changes explicitly; automatically updating snapshots after every failure can normalize drift instead of detecting it.
86. What does consumer-driven contract testing fail to prove?
It can verify interactions represented by participating consumers, but does not establish every business invariant, security property or production dependency behavior. Its value depends on accurate examples and a supported verification process.
A provider can satisfy the expected response shape while returning an incorrect account balance. A consumer absent from the contract set can also break unnoticed. Use contracts to clarify compatibility at boundaries, then add domain, authorization and end-to-end checks where needed. Passing contract tests should not be described as proof that the entire distributed workflow is reliable.
87. How would you test a rolling API version deployment?
I would test the combinations of clients and server versions that can coexist during rollout, including shared data changes. Compatibility must hold during the transition, not only after every component is upgraded.
A new server might write an enum value an old reader cannot interpret. Exercise old-reader/new-writer and new-reader/old-writer paths with realistic stored data. Coordinate schema expansion, usage and retirement where appropriate, and verify the rollback boundary. Declaring a change additive does not prove every consumer tolerates it.
88. How would you test an API deprecation plan?
I would verify both the replacement’s behavior and the evidence used to identify remaining consumers. A published notice is not proof that scheduled jobs, mobile clients and partner integrations have migrated.
Check representative old clients, migration guidance and the expected failure or warning behavior at each stage. Use authorized telemetry to locate callers without exposing credentials. Define who decides that removal is safe and how exceptions are handled. The test plan should distinguish documented support policy from an assumption that all clients update on the server’s schedule.
89. How would you test authorization revocation during an in-flight request?
I would first define the authorization decision point promised by the service: request acceptance, a later consequential action or another explicitly documented boundary. Then I would coordinate a controlled request and revocation to test that contract, rather than assume revocation can retroactively undo every accepted operation.
For a synthetic export, pause processing before publication, revoke the test user’s access and verify whether generation and retrieval behave as required. Check durable effects and subsequent access, not only the initial response. A check made earlier can become stale before use, so the design may need revalidation at a relevant boundary. Tests should expose that timing decision and its consequences without inventing one universal rule for every operation.
Controlled point | Contract question |
|---|---|
Before initial authorization | Does the revoked identity receive the required denial without protected side effects? |
After acceptance, before consequential action | Must authority be revalidated, or does the documented acceptance grant cover completion? |
After output generation, before retrieval | Does the current identity still have access to the artifact? |
90. How would you test business invariants across a saga?
I would model the intended state transitions and compensations, then inject failures at the boundaries between completed steps. A saga does not make all external changes disappear as if one database transaction rolled back.
If inventory is reserved before payment fails, verify the supported release path and what users see while compensation is pending. Also test compensation failure and repeated delivery. The oracle should allow explicitly permitted intermediate states but reject impossible final outcomes, with an owned recovery path for cases requiring intervention.
91. How would you verify compensation without assuming it is a perfect inverse?
I would define the business effect that compensation must achieve and the evidence that it completed. Some actions, such as a sent notification or consumed service, cannot literally be undone.
A refund is a separate financial action with its own outcome, not deletion of the original payment. Use synthetic systems to test correlation, repeated requests and uncertain responses. Verify audit history and customer-visible status as well as final totals. A workflow that reports compensated before the corrective action is confirmed can conceal an unresolved obligation.
92. How would you test eventual consistency meaningfully?
I would state which observations may lag, which guarantees must still hold and the acceptable convergence condition. Polling until any response looks right is insufficient if the test never checks forbidden intermediate behavior.
After an update, a search index may temporarily lag while the authoritative detail endpoint is current. Test that distinction and bound the observation window according to the service contract. Preserve evidence when convergence fails. Do not assert immediate cross-system equality for a design that explicitly permits lag, or excuse unbounded inconsistency merely because the architecture is asynchronous.
93. How would you test multi-region consistency and failover?
I would define the promised read and write behavior across regions and test transitions under controlled routing and failure conditions. “Multi-region” does not identify a single consistency model.
A write acknowledged in one region may have different recovery implications from an unacknowledged request during failover. Verify session or read-after-write guarantees where promised, conflict resolution where applicable and the business recovery point. Tests need authorization and isolation appropriate to the environment; a local mock cannot establish the production replication or failover behavior.
94. How would you investigate a concurrency defect that passes sequential API tests?
I would identify the shared invariant and coordinate requests so they compete at a meaningful boundary. Sequential success cannot establish correctness when two operations observe the same prior state.
For a limited-capacity resource, start two synthetic reservations against the last unit and verify the permitted outcomes and final count. Use deterministic barriers or controlled dependencies where available rather than rely only on random timing. Check both responses and durable state: returning one error is not sufficient if both side effects already occurred.
95. How would you test retention and ownership of asynchronous results?
I would define who may retrieve a result, how long it remains available and what expiration means for both metadata and stored output. Completion does not establish that the artifact remains accessible indefinitely or that every holder of its identifier is authorized.
For a synthetic report job, test retrieval by its owner and an unauthorized test identity, then cross the documented expiry boundary using controlled time where supported. Verify whether retrying the original request creates a new artifact or resolves the expired operation according to the contract. Check that delayed completion cannot resurrect expired output unintentionally. Distinguish inaccessible results from physically deleted data; storage and backup retention require their own evidence.
96. How would you test a dependency outage without relying on live failure?
I would introduce a controlled substitute or fault-injection point that can represent the specific failure boundary: connection failure, slow response, malformed payload or failure after acceptance. Each produces different evidence.
A stub returning an immediate error cannot model a timeout after a remote side effect. Match the injected behavior to the recovery requirement and validate the substitute against the dependency contract. Keep experiments within authorized environments and isolate state. Use live-provider checks only where permitted and necessary; simulated success does not prove the provider’s production behavior.
97. How would you test recovery after a backlog accumulates?
I would evaluate whether the system catches up while preserving correctness and protecting downstream capacity. Recovery is not complete merely because new requests begin succeeding.
Use synthetic queued work with varied ages and some already-processed identities, then verify deduplication, expiration policy and ordering where required. Observe whether retries overwhelm the recovering dependency. Measure completed business operations and remaining lag, and test a second interruption during catch-up. An empty queue can also mean discarded work, so reconcile expected outcomes.
98. How would you validate disaster recovery through API behavior?
I would restore a controlled environment and exercise representative business reads and writes against the recovered state, with external actions disabled or safely substituted. Infrastructure restoration alone does not prove application consistency.
Check relationships, credentials, configuration and operations around the recovery point. An externally accepted transaction may be newer than the restored database and require reconciliation. Record actual data loss and time to usable service against agreed objectives. Never claim recovery success from backup-file existence or from one health endpoint returning success.
99. How would you design a representative performance workload?
I would model the request mix, arrival pattern, data distribution, authentication and state transitions that matter to users. A single repeated cached request rarely represents the service’s real resource costs.
Include expensive legitimate paths and realistic read/write ratios, while controlling test data and cleanup. Decide whether the objective is steady traffic, bursts or recovery from overload. The workload generator’s capacity and timing must also be measured. Run only within authorized load-test scope; these design examples do not authorize traffic against a public service.
100. Why can a low average latency conceal a serious API problem?
A mean can hide a slow tail or mix together fast failures and successful responses. I would inspect relevant latency distributions alongside error rates, throughput and workload composition.
If a small but important group of checkout requests takes several seconds, a fast majority can keep the average attractive. Separate operation types and success outcomes, and ensure there are enough observations to interpret high percentiles. A percentile is an empirical summary under measured conditions, not a guarantee that every future request will meet that duration.
101. Why should service percentiles not be averaged to obtain a global percentile?
Percentiles depend on the underlying observation distribution, so averaging regional or interval p99 values generally does not yield the p99 of combined traffic. Different populations and sample sizes can make that number misleading.
Use suitably aggregated distributions or another supported measurement approach, with compatible buckets and definitions where relevant. Compare the global result with per-region results so a low-volume but poorly served region is not hidden. State whether measurements include failures and timeouts. A plausible-looking arithmetic average is not an acceptable substitute for the requested statistic.
Python teaching example: averaging p99 values fails These synthetic observations use an explicitly chosen nearest-rank definition. The example demonstrates arithmetic, not an API latency measurement or a universal telemetry aggregation implementation.
102. How would you avoid coordinated omission in latency testing?
I would examine whether the generator stops issuing work while waiting for slow responses and therefore omits delays that real arrivals would experience. The arrival model must match the decision being evaluated.
A closed-loop client can reduce offered load as the service slows, making overload appear less severe than an independently arriving workload. Use an appropriate scheduling and measurement design and report achieved versus intended traffic. Do not assume one load model is always superior; explain what user behavior it represents and what its latency observations exclude.
103. How would you test overload behavior?
I would verify that the API degrades within its documented contract while protecting critical resources and producing actionable outcomes. Throughput alone is not enough if accepted work is silently lost.
In an approved environment, increase a representative synthetic load within agreed boundaries and inspect admission, queueing and recovery. Confirm that rejected or timed-out work has a clear retry or reconciliation policy and that normal performance returns after pressure subsides. Avoid interpreting an infrastructure autoscaling event as proof that application state remained correct.
104. How would you distinguish a slow service from a slow test harness?
I would instrument the client and service boundaries and inspect generator saturation, connection management and measurement overhead. The harness can become the bottleneck before the API does.
A serial data-preparation step or exhausted connection pool may limit requests while server metrics remain quiet. Compare intended arrival times, actual sends and response completion, then examine trace or server evidence where available. Report the limitation instead of extrapolating an apparent service capacity from a constrained client. Keep the measured environment and instrumentation configuration reproducible.
105. How would you use tracing to diagnose an API test failure?
I would correlate the failing request with its distributed spans and relevant logs to understand where work waited or failed. Traces provide execution evidence, not a complete oracle for business correctness.
A parent request may spend most of its time in one dependency or omit a span because context propagation broke. Verify sampling and instrumentation before treating absence as proof that no call occurred. Use safe identifiers and avoid sensitive payloads in attributes. Combine the trace with response and state assertions so observability supports, rather than replaces, the test.
106. How would you test observability itself?
I would deliberately exercise known safe failure cases and verify that the intended metrics, logs, traces and alerts identify the relevant operation. An alerting design should be tested like another system dependency.
A rejected transaction should produce its expected business signal without leaking credentials or personal data. Test missing propagation and an unavailable telemetry backend according to the design’s limits. Confirm alert ownership and useful context. A test suite that notices a failure only because a human inspected raw logs has not established the planned operational response.
107. How would you investigate a flaky API test?
I would preserve the failing run’s inputs, timing and environment evidence, then classify likely causes such as shared state, nondeterministic ordering, eventual consistency or a real intermittent product defect. A rerun passing does not identify the cause.
If parallel tests reuse the same customer, one may delete data another still needs. Isolate that lifecycle and reproduce the conflict. For asynchronous behavior, wait on the specified condition with a bounded diagnostic timeout rather than add arbitrary sleep. Quarantine may protect the pipeline temporarily, but it needs an owner and a resolution criterion.
108. How would you recover from test-fixture provisioning failures?
I would track resources as they are created and define how interrupted setup transfers responsibility to a controlled cleanup process. A test that fails before teardown runs can leave accounts, files or queued work even if normal tests isolate their data correctly.
Use a durable run manifest or supported lease mechanism with explicit ownership and expiry, then test interruption after each provisioning step. Reclamation must verify that a resource belongs to the test and is no longer actively leased; a broad name or age filter can delete another run’s state. Account for delayed callbacks that may create more resources after cleanup starts. Reconcile the manifest and actual owned resources, and surface leftovers that cannot safely be removed automatically.
109. How would you test time-dependent behavior reliably?
I would control time at the appropriate application boundary where feasible and specify the clock, timezone and business-date rules. Wall time, elapsed time and event time can lead to different expected results.
For expiry, test immediately before and after the boundary without waiting hours. Include timezone transitions where the contract uses local dates, and distinguish a late-arriving event from a newly generated one. A fake clock helps deterministic logic tests, but separate integration evidence is needed for real schedulers, certificates or external systems that use independent clocks.
110. How would you control randomized API testing?
I would generate inputs within a defined domain, retain reproducible seeds or minimized failing cases and assert meaningful properties. Randomness expands exploration but cannot replace an oracle.
A property test for totals should include empty collections, duplicates and boundary values under the actual numeric contract. When a failure appears, preserve the smallest relevant case as a regression. Track which behaviors the generator cannot reach. Thousands of valid random requests may still miss a rare authorization transition or a specific malformed boundary.
111. How would you scope an authorized API security test?
I would confirm the systems, identities, operations, data and test techniques covered by the authorization, then use isolated synthetic accounts wherever possible. Security testing must have a defined boundary and response plan.
For cross-tenant access checks, create two permitted test tenants and verify expected denial without touching real users’ records. Avoid assuming permission to test one endpoint includes disruptive load or unrelated hosts. Record findings with safe evidence and a clear impact explanation. OWASP risk categories guide coverage; they are not authorization to probe any available API.
112. How would you test authorization across a resource lifecycle?
I would model who may act at each state and test transitions as well as static roles. Access can change after ownership transfer, membership removal or finalization of a business operation.
A user allowed to edit a draft may no longer be allowed to change it after approval. Verify direct API behavior for both the permitted and denied identity using owned test records. Check returned fields and side effects, not just status codes. A successful denial response is insufficient if the protected update already happened.
113. How would you test that sensitive data stays out of diagnostics?
I would place distinctive synthetic markers in sensitive fields and inspect the permitted diagnostic outputs for inappropriate propagation. Include failures, retries and validation errors, where raw requests are often logged.
Check logs, trace attributes, test reports and captured fixtures, with access controls appropriate to the environment. A masked success response does not establish that the same value was absent from an exception or attachment. Define which safe identifiers remain available for support so privacy controls do not make incidents impossible to investigate.
114. How would you assess risks when consuming a third-party API?
I would test the consumer’s validation and failure behavior against unexpected but plausible provider responses, not assume upstream data is trustworthy merely because the provider is familiar. The contract includes operational limits and change management.
A provider can return a valid schema with an invalid business value, redirect unexpectedly or delay a response after acceptance. Use approved stubs and provider sandboxes to exercise the relevant boundaries. Separate what was verified locally from what the provider guarantees; do not describe a mock passing as validation of the external service.
115. How would you keep mocks from becoming misleading?
I would tie them to reviewed contracts and representative captured or synthetic examples, with periodic verification against an authorized real boundary where appropriate. A mock that mirrors only the client’s preferred behavior can hide incompatibility.
Include the provider’s meaningful error and timing cases instead of always returning a fast success. Version fixtures when the contract changes and investigate drift rather than automatically accepting new snapshots. Keep the mock’s limits explicit: it may verify consumer handling but not production authentication, networking, performance or persistence.
116. How would you define evidence for an API release decision?
I would summarize the changed risks, relevant tests, observed results and material gaps against agreed acceptance criteria. A pass percentage is less useful than knowing whether the consequential behavior was checked.
For a write-path change, include duplicate-delivery, uncertain-outcome and authorization evidence where relevant, along with compatibility and performance scope. Identify unresolved failures and who owns the decision. Avoid calling a release safe merely because the pipeline is green when tests skipped a dependency or used a materially different configuration.
117. How would you turn a production incident into useful regression tests?
I would reconstruct the specific trigger and invariant that failed, then create a stable test at the boundary best able to detect recurrence. Also examine why existing monitoring or tests missed the problem.
If a retry after a lost response duplicated an order, reproduce that failure point rather than add another normal create-order test. Preserve a small end-to-end check where needed, but do not reproduce the entire incident environment unnecessarily. A regression should fail for the original defect and pass for the corrected behavior, with its limits documented.
118. How would you review AI-generated API tests?
I would check whether the assertions can detect the intended defect, whether fixtures reflect the contract and whether setup and cleanup are isolated. Generated volume is not evidence of useful coverage.
A test may assert only that a response exists or copy the implementation’s mistaken calculation into its expected result. Add a deliberate negative control or inspect a known failing case to assess the oracle. Keep credentials and real customer data out of unapproved tools. Human review must own risk selection and interpretation of results.
119. What should an API test-suite handover contain?
It should explain the contract versions, test boundaries, environment and data requirements, critical oracles and recovery from interrupted runs. Another team should understand both failures and the evidence a passing suite does not provide.
Rehearse one meaningful failure and show how to find its safe request identity, state evidence and dependency diagnostics. Document quarantined tests and shared fixtures with owners. Keep secrets in the approved system rather than the repository. A command that runs the suite is necessary, but not enough for responsible maintenance.
120. What demonstrates senior API testing judgment?
A senior tester connects client observations with durable business state, distributed boundaries and the consequences of failure. They choose tests that can challenge the design rather than merely repeat its happy path.
When a write times out, they ask what may have committed; when p99 improves, they examine workload and failures; when security checks pass, they verify the tested identities and scope. They communicate uncertainty and recovery limits clearly. Reliable evidence comes from meaningful oracles and controlled conditions, not the largest possible count of requests or assertions.
API Testing Documentation and Further Reading
These primary references define protocol semantics and provide authoritative contract, security and reliability guidance. Apply the versions and service contracts used by the system under test.
Similar Posts
