API testing interview questions and answers

API testing interview questions check whether you can test a service without its UI: send the right requests, verify status codes, bodies, headers and side effects, and prove the API fails safely when given bad input, missing auth or repeated calls. Expect questions on HTTP from a tester's point of view, Postman and newman, a code-based tool such as REST Assured, authentication, schema and contract testing, and the negative and idempotency cases that separate testers from people who only check for 200 OK.

By Published 9 min read

How API testing is tested in interviews

API testing questions come up in QA engineer, SDET and automation tester loops, and increasingly in manual testing roles too, because a lot of business logic now sits behind services rather than screens. Expect a concepts round on HTTP and REST, a practical round where you test a public or sample API in Postman or write a few tests in code, and a design question such as "how would you test this endpoint?" where the interviewer counts how many kinds of failure you think of. For backend-heavy teams, a senior round adds contract testing, test data strategy and how the suite runs in CI.

HTTP from a tester's angle

Fundamentals for freshers and first screens
QuestionWhat it testsWhat a strong answer shows
What do you verify in an API response?CoverageStatus code, response body structure and values, headers such as Content-Type, response time, the error format on failures, and side effects: was the record really created, updated or deleted?
Which HTTP methods should be idempotent, and how do you test it?SemanticsGET, PUT and DELETE should leave the same state however many times they run. Send the same request twice and compare the stored state, not just the status code (a second DELETE may return 404 and still be correct).
400 versus 422?Status codes400 for a request the server cannot parse, such as broken JSON. 422 for valid JSON that breaks a business rule. Check that the API is consistent with its own documentation.
401 versus 403?Auth401 means no valid credentials were sent. 403 means the caller is known but not allowed. Test both: no token, expired token, and a valid token for the wrong role.
404 versus 405?Routing404 means the resource does not exist. 405 means the resource exists but does not support that method, and the response should list allowed methods in an Allow header.
When do you expect 409 and 429?Status codes409 when the request conflicts with current state, such as a duplicate username. 429 when a rate limit is hit, ideally with a Retry-After header.
500, 502, 503 and 504?Server errors500 is an unhandled error in the service. 502 and 504 come from a gateway that got a bad or no answer from upstream. 503 means temporarily unavailable. A 500 on bad input is a bug: invalid input should get a 4xx.
REST versus SOAP from a testing point of view?ProtocolsREST usually uses JSON over plain HTTP methods and status codes. SOAP uses an XML envelope with a WSDL contract and reports errors as SOAP faults. Tools such as SoapUI and Postman handle both.
What is the difference between API testing and UI testing?ScopeAPI tests are faster, more stable and reach business rules directly. UI tests check what the user sees. Most suites put many more checks at the API layer than in the browser.
Fundamentals for freshers and first screens. Scroll sideways on a small screen.

Postman and newman

  • How do you organize a Postman collection? Folders by resource or flow, requests that use variables for base URL and tokens, and tests on every request rather than only on the happy path.
  • What variable scopes does Postman have? Global, collection, environment, data (from a CSV or JSON file in a run) and local. Environments hold per-stage values like the base URL, so the same collection runs against dev and staging.
  • How do you chain requests? Save a value from one response in a test script with pm.collectionVariables.set or pm.environment.set, and reference it as {{userId}} in the next request.
  • What are pre-request scripts for? Preparing a request: generating a timestamp or unique email, fetching a token, or computing a signature header.
  • How do you run data-driven API tests in Postman? Use the collection runner or newman with a CSV or JSON data file. Each row becomes an iteration and its columns become variables.
  • How do you run Postman tests in CI? Export the collection and environment and run them with newman, for example newman run orders.postman_collection.json -e staging.json --reporters cli,junit, so the pipeline gets a JUnit report.
  • What are Postman's limits for a large suite? Logic spread across many scripts is hard to review and reuse, and version control of exported JSON is clumsy. Teams often keep Postman for exploration and write the regression suite in code.
pm.test("status is 201", () => {
  pm.response.to.have.status(201);
});

pm.test("body matches the user schema", () => {
  const schema = {
    type: "object",
    required: ["id", "email"],
    properties: { id: { type: "string" }, email: { type: "string" } },
    additionalProperties: false,
  };
  pm.response.to.have.jsonSchema(schema);
});

pm.test("responds within 800 ms", () => {
  pm.expect(pm.response.responseTime).to.be.below(800);
});

pm.collectionVariables.set("userId", pm.response.json().id);
Postman test script on a create-user request: status, schema, timing, and saving the new ID for the next request.

Authentication and authorization testing

  • Which auth types have you tested? Basic auth, API keys in a header, bearer tokens, OAuth 2.0 (client credentials for service-to-service, authorization code for user login) and session cookies. Say how you got tokens in automated runs without a human logging in.
  • How do you test token expiry? Use a short-lived token in a test environment or a token signed with a past expiry, and check for 401 and the documented error. Then check that the refresh flow issues a new token and that the old refresh token cannot be reused if rotation is in place.
  • What is broken object-level authorization and how do you test for it? Log in as user A, take the ID of a record owned by user B, and request or modify it. The API must refuse. This simple test finds some of the most serious API bugs.
  • How do you test role-based access? Build a matrix of roles against endpoints and methods, and run each call as each role. Expected results come from the permission spec, not from what the API currently does.
  • What would you try against a JWT? Change a claim without re-signing, remove the signature, send an expired token and a token for another audience. Each should be rejected. Never put real secrets in test tokens or logs.

Schema validation and contract testing

Intermediate questions on keeping services compatible
QuestionWhat it testsWhat a strong answer shows
Why validate the response schema and not just a few fields?RobustnessA schema check catches a renamed field, a wrong type, a missing required field or an unexpected extra field in one assertion, across every test that hits the endpoint.
Where does the schema come from?SourcesFrom the OpenAPI description if the team keeps one, otherwise a JSON Schema the testers write and review with developers. Generated from the spec is better than hand-copied.
What is contract testing?ContractsChecking that a provider API still meets what each consumer expects, without running the whole system. In consumer-driven contract testing (Pact is the common tool), consumers record their expectations and the provider verifies them in its own pipeline.
How is contract testing different from integration testing?Test levelsIntegration tests run real services together and check behavior. Contract tests check the shape of the interface in isolation, so they are faster and point at which side broke the agreement.
What changes would break a consumer?CompatibilityRemoving or renaming a field, changing a type, making an optional input required, or changing an error code that clients branch on. Adding an optional field is usually safe.
How do you test against a dependency that is not ready?IsolationStub it with a mock server (WireMock, Postman mock servers or a small local stub) that returns recorded or agreed responses, including errors and timeouts.
Intermediate questions on keeping services compatible. Scroll sideways on a small screen.

Code-based API tests: REST Assured and friends

  • What is REST Assured? A Java library for HTTP tests with a given, when, then style: given() sets headers and body, when() sends the request, then() asserts status, body paths and headers. It pairs with TestNG or JUnit and can validate JSON Schema.
  • What would you use outside Java? Python with requests and pytest, JavaScript with a test runner and fetch or supertest, or Karate, which describes API tests in a Gherkin-like syntax.
  • How do you manage test data for API tests? Create what each test needs through the API or a seed script, give records unique names, and clean up afterwards or use a disposable environment. Shared fixed records are the main cause of flaky API suites.
  • How do you test an asynchronous API that returns 202? Check the 202 and the job or status URL, then poll it with a timeout until it reports done or failed, and verify the final result. Avoid fixed sleeps.
  • How do you test webhooks your service sends? Point the service at a capture endpoint in the test environment, trigger the event, and check the payload, signature header and retry behavior when the receiver returns an error.
import { test, before, after } from "node:test";
import assert from "node:assert/strict";
import http from "node:http";

// A tiny stand-in for the service under test.
const users = new Map();
const server = http.createServer((req, res) => {
  let raw = "";
  req.on("data", (chunk) => (raw += chunk));
  req.on("end", () => {
    const send = (status, body) => {
      res.writeHead(status, { "Content-Type": "application/json" });
      res.end(JSON.stringify(body));
    };
    if (req.headers.authorization !== "Bearer test-token") return send(401, { code: "unauthorized" });
    if (!req.url.startsWith("/users/")) return send(404, { code: "not_found" });
    const id = req.url.slice("/users/".length);
    if (req.method === "GET") return users.has(id) ? send(200, users.get(id)) : send(404, { code: "not_found" });
    if (req.method !== "PUT") return send(405, { code: "method_not_allowed" });
    let body;
    try { body = JSON.parse(raw); } catch { return send(400, { code: "bad_json" }); }
    if (typeof body.email !== "string" || !body.email.includes("@")) return send(422, { code: "invalid_email", field: "email" });
    const existed = users.has(id);
    users.set(id, { id, email: body.email });
    send(existed ? 200 : 201, users.get(id));
  });
});

let base;
before(() => new Promise((resolve) => server.listen(0, () => {
  base = "http://127.0.0.1:" + server.address().port;
  resolve();
})));
after(() => server.close());

const call = (method, path, body, token = "test-token") =>
  fetch(base + path, {
    method,
    headers: { "Content-Type": "application/json", ...(token ? { Authorization: "Bearer " + token } : {}) },
    body: body === undefined ? undefined : typeof body === "string" ? body : JSON.stringify(body),
  });

test("PUT creates once, and repeating it leaves the same state", async () => {
  const first = await call("PUT", "/users/u-1", { email: "ana@example.com" });
  assert.equal(first.status, 201);
  const second = await call("PUT", "/users/u-1", { email: "ana@example.com" });
  assert.equal(second.status, 200);

  const stored = await (await call("GET", "/users/u-1")).json();
  assert.deepEqual(Object.keys(stored).sort(), ["email", "id"]);
  assert.equal(stored.email, "ana@example.com");
});

test("bad requests get the right 4xx and an error code", async () => {
  const cases = [
    ["no token", () => call("GET", "/users/u-1", undefined, null), 401],
    ["unknown id", () => call("GET", "/users/nobody"), 404],
    ["broken JSON", () => call("PUT", "/users/u-2", "{bad"), 400],
    ["invalid email", () => call("PUT", "/users/u-2", { email: "no-at-sign" }), 422],
    ["wrong method", () => call("DELETE", "/users/u-1"), 405],
  ];
  for (const [name, send, expected] of cases) {
    const res = await send();
    assert.equal(res.status, expected, name);
    assert.equal(typeof (await res.json()).code, "string", name);
  }
});
api.test.mjs: idempotency and negative tests with Node's built-in test runner against a small stub service. Run it with `node --test api.test.mjs`.

Negative tests, idempotency and senior scenarios

Questions for experienced API testers
QuestionWhat it testsWhat a strong answer shows
Which negative tests do you run on a new endpoint?BreadthMissing and extra fields, wrong types, empty and very long strings, boundary numbers, invalid enum values, malformed JSON, wrong content type, missing auth, another user's IDs, unsupported methods and oversized payloads.
How do you test that a retried POST does not create a duplicate?IdempotencyIf the API supports an idempotency key, send the same request twice with the same key and confirm one record and identical responses; then reuse the key with a different body and expect a rejection. Without a key, document the risk.
Two clients update the same record at once. What do you check?ConcurrencyWhether the API uses ETags or version numbers and returns 409 or 412 for a stale update, or silently lets the last write win. Fire both requests in parallel in a test to see.
The API returns 200 with an error message in the body. Is that a bug?JudgmentIt breaks HTTP semantics and makes monitoring and client handling harder. Raise it, but check the API's documented convention first; some older or RPC-style APIs do this on purpose.
How do you test pagination?ListsFirst, middle and last pages, an empty result, page size at and over the maximum, invalid cursors, and that items are not skipped or repeated when records are added during paging.
Your API suite is flaky in CI. What do you look at?ReliabilityShared test data, order-dependent tests, environment instability, rate limits hit by parallel runs and time-sensitive assertions. Fix data ownership first.
How much performance checking belongs in functional API tests?ScopeA loose response-time assertion catches big regressions. Real load, stress and soak testing is separate work; see the performance testing questions.
Questions for experienced API testers. Scroll sideways on a small screen.

Fictional example

Answering "How would you test POST /orders?"
Interviewer
You have an endpoint that creates an order from a cart ID and a payment token. How do you test it?
Candidate
I would start with the contract: required fields, response schema, and the status codes the docs promise. Positive cases first: a valid cart gives 201, a Location header, a body that matches the schema, and an order I can fetch afterwards with the right items and total. Then I check side effects: the cart is marked as converted, stock is reduced, and only one payment is captured. Negative cases: missing cart ID, unknown cart, a cart that belongs to another user, which must be refused, an empty cart, a declined payment token, wrong content type and no auth. For reliability I send the same request twice with the same idempotency key and confirm there is still one order and one charge, and I fire two orders for the last item in stock at the same time to see that one of them fails cleanly. I would automate the stable cases in the regression suite and keep the concurrency test as a separate, tagged check.

How to prepare for an API testing interview

  1. Learn the codes and methods coldFor each method and each common status code, write the test you would run to prove the API uses it correctly.
  2. Test a public API in PostmanBuild a collection with environments, chained requests, schema checks and negative cases, then run it from the command line with newman.
  3. Write the same tests in codeRecreate five of those tests in REST Assured, Python requests with pytest, or the Node example above, and run them twice in a row to check they clean up.
  4. Practice "how would you test" questionsPick endpoints like login, file upload, search and payment, and list positive, negative, auth, idempotency and pagination cases for each in ten minutes.
  5. Prepare one real storyA bug you found at the API layer that the UI hid, and how you proved it.

API testing sits between manual testing skills and automation framework design. If the team is backend heavy, backend developer interview questions show what the developers you will work with are asked.

When you rehearse "how would you test this endpoint", the gaps are usually the categories you forgot to mention. Natively, an AI interview assistant for Mac and Windows, transcribes a mock round so you can count what you covered afterwards. During practice it can read a screenshot of an API response, a Postman failure or a spec and suggest checks you missed, help with REST Assured or Python test code, and, with Pro or the free trial, use the résumé and job description you add. The transcript and notes are kept for you to review.

Questions people ask

What API testing questions are asked in interviews?

What to verify in a response, idempotent methods, status codes such as 400 versus 422 and 401 versus 403, Postman variables and newman, REST Assured, authentication and authorization checks, schema validation, contract testing and negative tests.

How do you test an API endpoint?

Check the contract, then positive cases with status, schema, values and side effects, then negative cases for bad input, missing auth and other users' data, then idempotency, concurrency and pagination where they apply.

What is the difference between contract testing and integration testing?

Integration tests run real services together to check behavior. Contract tests check, in isolation, that a provider still meets what its consumers expect, so they are faster and show which side broke the agreement.

What API testing questions do experienced testers get?

Duplicate prevention on retried POSTs, concurrent updates, flaky suites in CI, test data strategy, testing asynchronous APIs and webhooks, and how API tests fit with UI and performance testing.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP