QA Interview Hub · Knowledge base · Quizzes · Українська
61 API questions that come up in QA interviews, with short answers. Open the topic in the knowledge base for a deeper explanation.
DNS turns the domain into an IP, and a TCP connection and TLS are established. The client sends POST /api/transfers with the token and JSON, and the load balancer or API Gateway passes it to a server instance. The server checks authorisation, validates the data, runs the business logic such as checking the balance and limits, and writes to the database in a transaction. Then it returns 201 with the transfer id, and the client shows the result.
Every request is independent: the server does not remember earlier ones, so a token or cookie goes with each request. For tests: a request can be replayed on its own if all headers are present; the client holds the "session", not the connection; a request without a cookie or token gets 401, not a continuation of the earlier conversation.
The UI can be bypassed: Postman, curl or a script send a request directly. Client validation is a convenience (fast feedback), server validation is security and data integrity. Test: send directly the values the UI does not allow (a negative amount, a too long string, an extra field) and expect 4xx with a clear error, not 2xx or 500; an extra field is rejected or ignored as the contract says, but never stored.
A request: a start line (method, path with query parameters, HTTP version), headers (Host, Authorization, Content-Type, Accept) and an optional body (JSON, a form, a file). A response: a status line (version, code and text like 200 OK), headers (Content-Type, Set-Cookie, Cache-Control) and a body. Example: POST /users with Content-Type: application/json and the body {"name": "Ann"}. In an API test I check the status code, key headers (for example Content-Type), the body fields against a schema, and the response time. A GET request usually has no body.
A path parameter identifies a specific resource, for example /users/42. A query parameter filters, sorts or paginates the output, for example /users?status=active&page=2. For path I check an invalid type, such as abc instead of a number, which must give 400, and a nonexistent or someone else's id with 404 or 403. For query I check filter combinations and pagination boundaries.
These are three different states. A missing field means "not sent" (in PATCH usually "do not change"), null is an explicit "no value" (often "clear"), and an empty string "" is a value that is empty. The contract must describe each case, and a test checks that the server does not confuse them and does not fail with 500.
REST is an architectural style of API over HTTP: resources have URLs (/users/42) and actions are expressed by methods; the server keeps no client state between requests (stateless). The main methods: GET — read, POST — create, PUT — full replace, PATCH — partial update, DELETE — remove, plus HEAD and OPTIONS. Idempotent methods give the same server state when repeated: GET, PUT, DELETE, HEAD, OPTIONS. POST is not idempotent: two requests create two resources. PATCH depends on the implementation. Safe methods (they do not change data) are GET, HEAD, OPTIONS.
PUT replaces the resource entirely: the client sends its full representation, and fields absent from the request are reset or become empty. PATCH changes only the fields sent. PUT is idempotent by definition; PATCH may be idempotent ({"status": "active"}) or not (for example, incrementing a counter). Example: a user has {name, email, phone}; PATCH {"phone": "123"} changes only the phone, while PUT with the same body leaves the user without a name and email or returns 400. That is what I check in tests: after a PATCH the other fields are unchanged.
I would send POST /transfers with a particular Idempotency-Key and get 201 with an id. Then I would send the same request with the same key and check that the same id is returned and the database has one transaction. Separately I would check the same key with a different body: the server must return an error, not create a new payment. And one more scenario with a response timeout and a client retry.
Groups: 1xx — informational, 2xx — success, 3xx — redirection, 4xx — client error, 5xx — server error. 200 OK — the request succeeded and the response has a body. 201 Created — a resource was created (usually after POST, often with a Location header). 204 No Content — success without a body, typical for DELETE. 400 Bad Request — an invalid request, for example an invalid body. 404 Not Found — there is no such resource. 500 Internal Server Error — an unexpected server failure. In tests I check not just "success" but the exact code: 401 without a token, 403 without rights, 404 for someone else’s or a deleted resource.
401 means the client is not authenticated: there is no token, or it is expired or corrupted. 403 means I know who you are, but you have no rights to this resource. 400 means the request is syntactically malformed, for example broken JSON. 422 means the syntax is right but the data fails validation: a missing required field or an amount greater than the balance. Some APIs return 400 for a missing field, so the code is checked against the contract.
{ "error": "Invalid amount" } in the body. Is that fine?No, it is a bug. Clients, monitoring and automated tests go by the status and will consider such a request successful. An invalid amount must give a 4xx, for example 400 or 422, with a clear message. Likewise a 500 on invalid input is a bug, because it means an unhandled exception on the server.
From wide to narrow: Global, Collection, Environment, Data and Local. When names are the same, the narrower one wins, so an environment variable overrides a collection one. pm.variables.get returns exactly the value from the scope that won. I almost never use global variables, and I keep baseUrl and test logins in the environment.
Folders by resource for exploration and separate scenario folders for Newman; authorization, variables and shared scripts on the collection level; requests named "action + resource + expectation", each with a response example and a description.
In the Local value, a secure variable or Postman Vault; in CI from the pipeline secrets through --env-var. The Shared value is synced, reaches exports and git. If a secret ended up there, it is reissued.
A mock server created from a collection answers with saved examples when the backend is not ready (parallel development). A monitor runs the collection on a schedule in the cloud and notifies about failures. A monitor sees only Shared values and, from the cloud, cannot see localhost (internal networks have Private API Monitoring).
Authentication answers "who are you": verifying identity with a login and password, a token, a one-time code. Authorization is "what are you allowed to do": checking rights to an action or resource once the identity is known. When the token is missing or invalid, the server responds 401 Unauthorized; when the user is known but lacks rights, 403 Forbidden. In tests I check separately: a request without a token (401), with an expired token (401), a user without the needed role (403), and access to someone else’s resource, a typical IDOR vulnerability.
Without a token, with an expired one, a corrupted one and a token after logout: I expect 401. With a role without rights: 403. The most important is IDOR: I create a resource under the first user and request it with the second user's token, expecting 403 or 404, but never the data. I check this not only for GET, but also for modification and deletion.
Broken object level authorization: the user is authenticated but sees or changes a resource of another user, because the server did not check the owner. Test: with the token of user A request the ids of resources of user B (GET, PUT, DELETE) and expect 403 or 404. It is the first risk in the OWASP API Security Top 10.
Pre-request runs before sending: I generate unique data, get a token through pm.sendRequest or compute a timestamp. Post-response runs after the response: checks with pm.test and pm.expect and saving values, for example the id of a new account for the next request. The execution order is the collection script, the folder's, then the request's.
In the collection pre-request store the token and its expiry (expires_in) in variables and call pm.sendRequest only when less than a margin is left; write the new value inside the callback.
A test without pm.expect is always green; asynchronous pm.sendRequest (set outside the callback); variable and CSV values are strings; shadowing by a narrower scope; a token in console.log; hard-coded ids; a heavy collection script for every request.
I export the collection and the environment to JSON and put them in the repository. In the pipeline I run newman run with -e for the environment, -d for the data file and the reporters cli, htmlextra and junit. I pass secrets through --env-var from the CI secrets. If at least one test fails, Newman returns a non-zero code and the job turns red, and the JUnit report is picked up by Jenkins or GitHub Actions.
-e environment, -d data, --env-var secrets, --folder, --bail (stop at the first failure), -r cli,junit,htmlextra with --reporter-*-export. Everything passed — code 0, any failure — non-zero: it is not swallowed.
Generate unique fields in pre-request, create the data in the test itself, clean up at the end of the iteration (Cleanup), reset temporary variables between iterations and do not rely on data already in the database.
I start with the positive case: status 201, the schema, the values, and a check through GET or SQL that the transfer was saved. Then the negative ones: without required fields, null, wrong types, zero, a negative amount, an amount greater than the balance, an unsupported currency, invalid JSON. Then security: 401 without a token, IDOR, no sensitive data. And the fintech specifics: a repeat with the same Idempotency-Key, cent precision, and the balances of both parties after the transfer.
That the state changed: a repeated GET (404 after DELETE), related objects (balances, stock), side effects exactly once (an event, an email, an audit entry). And that nothing extra changed: after an error the state is unchanged, other people's data untouched, a repeat creates no duplicate.
Content-Type and Location (after creation); the schema and types; field values against the input; formats (ISO 8601 dates, money as integers or a decimal string); empty lists as [], not null; no extra sensitive fields; response time within the SLA.
For exploring a new endpoint and quick checks I use Postman. The regression suite I keep in code, for example on Playwright request, next to the UI tests. That way tests go through review in git, I can reuse data factories and helpers, and I can type the responses in TypeScript.
Offset works through limit and offset, lets you jump to any page, but is slow at large offsets and may duplicate or skip records on inserts. Cursor returns a nextCursor after the last element, so it is stable and fast, but with no jump to an arbitrary page. I test the limit boundaries, the last page, the absence of duplicates when walking through all pages, and an invalid cursor, which must give 400.
GraphQL has one endpoint, and the client picks the fields. The status is often 200 even with an error, so I check data and the errors array, not only the status. I check authorisation at the field and nested object level, because someone else's data may leak through a nested field. I also check the limits on query depth and complexity.
A standard error shape (application/problem+json): type, title, status, detail, instance plus custom fields. A test checks Content-Type, that status matches HTTP, a stable type or code (not the text of detail) and the absence of a stack trace. The shape must be the same for all errors, including those from a gateway.
First I suspect CORS, because it is a browser restriction and Postman doesn't apply it. I open Console and Network: I see whether a preflight OPTIONS went out and what it returned. I check Access-Control-Allow-Origin, Allow-Methods and Allow-Headers for our origin. I also compare whether the headers and cookies differ between the browser and Postman.
Cache-Control: no-cache and no-store differ, and how does ETag work?no-cache allows storing the response, but it must be validated with the server before use. no-store forbids storing at all, and for financial data that is the one I expect. ETag is the resource's version: the client sends If-None-Match with the old ETag, and if nothing changed, the server returns 304 without a body. I check that the ETag also changes after the resource is modified.
Vary lists the request headers the response depends on (Accept-Language, Accept-Encoding, Origin). The cache keeps a separate copy for each value. Without Vary a shared cache (CDN, proxy) serves the first stored version to everyone, for example Ukrainian to users with English.
It is when the server binds the whole request body to a model and saves fields that the client has no right to change. For example, in PATCH /users/me I add "role": "admin" or "balance": 1000000. Then I do a GET and check that those fields didn't change. If they did, it is a critical security bug.
I check a token with alg: none and no signature, a token with a changed role in the payload without re-signing, and a token from another environment: everywhere I expect 401. I look at whether the payload has sensitive data, because it is only encoded. I also check what happens to a token after logout and a password change, because a JWT is stateless and may live until exp.
Compare responses for someone else's and a non-existing resource: under a hiding policy both must be the same (usually 404), not 403 versus 404. The same for login, registration and password reset: an identical message and a similar response time for a known and an unknown account.
A consumer, for example the front end, describes in a Pact test which requests it makes and which fields it expects, and a contract is generated from that. The provider in its own CI verifies that the real API meets it, so a break is visible before deployment. Adding an optional field or a new endpoint usually doesn't break clients. Removing or renaming a field, changing a type or a new required field in a request is a breaking change.
required: the key must be present. Nullable (type ["string", "null"] in OpenAPI 3.1): the value may be null. Optional: the key may be absent. These are independent properties: a required field may be null, and {"id": 1} without a required middleName is invalid even if it is nullable.
It checks shape: types, required fields, enum, formats (if the validator enforces them: in ajv via ajv-formats), extra fields (additionalProperties: false) and ranges. It misses business errors: a value of the right type but wrong (a wrong total, a foreign owner), system state and side effects. So it is combined with value checks.
Load is the expected load, to check the SLA. Stress: we raise it above normal and look for the breaking point. Spike is a sudden burst, soak is a moderate load for hours to find memory leaks. The average hides the slow tail, so I look at p95 and p99: for example, p95 under 500 ms means 95% of requests fit within that time.
I retry only temporary errors: a timeout, 429, 502, 503, 504, and never 400 or 422. I use exponential backoff with jitter and limit the number of attempts, and on 429 and 503 I respect Retry-After. The main thing is that every retry goes with the same Idempotency-Key, because a timeout doesn't mean the payment didn't go through. In a test I emulate a timeout and check in the database that there is one transaction.
An SLI is a measurable metric, an SLO is a target for it. For an API: the share of successful responses (availability, no 5xx), latency by percentiles p95/p99 and throughput. Example: p99 ≤ 500 ms and under 0.1 % errors over 30 min. Without an SLO a load test result proves nothing.
An RPC framework: a contract in .proto, generated clients and server stubs, HTTP/2 transport, Protocol Buffers messages. Pros: performance, strict typing, streaming. Cons: the binary format is harder to debug, and a browser needs grpc-web/Connect.
Unary (request-response), server streaming (one request, a stream of responses), client streaming (a stream of requests, one response), bidirectional streaming (both sides send streams independently).
The HTTP status is normally 200. The real result is grpc-status (0 = OK) and grpc-message in the trailers, and structured error details are in grpc-status-details-bin (google.rpc.Status). A test checks the gRPC code.
An absolute time up to which the client waits for a response; sent as grpc-timeout. There is none by default, so a call can hang forever. The deadline is propagated down the chain of services; after expiry the result is DEADLINE_EXCEEDED and the server must stop working.
Positive scenarios and default values; validation (INVALID_ARGUMENT); error codes and the UNAUTHENTICATED/PERMISSION_DENIED difference; deadlines and cancellation; stream order and completion; the message size limit; version compatibility; retries and idempotency; TLS and authorization; gateway behaviour.
In its own test the consumer describes the minimum it needs from the provider, and that description is stored as a contract. The provider proves in its own CI that real code fulfils it. No test needs both services at once, so it is fast and deterministic. It does not replace the provider's functional tests and a few e2e: a contract checks the shape of communication, not business logic.
1) A consumer test against a mock provider → a pact file. 2) Publishing to the Broker with a version (SHA) and a branch. 3) Provider verification: the Verifier replays requests against the real provider and publishes the result. 4) can-i-deploy before a release checks the matrix against versions in the target environment. 5) record-deployment after a deploy records what runs where.
Business logic and exact values (only type or format), fields the consumer does not read, every possible error code "just in case" (only those the client handles), element order, UI details. The rule: a contract is an acceptance test for the consumer's need, not a copy of the provider's response.
Identify the valid and invalid classes (out of range, wrong type, empty), take a representative of each and check the boundaries: the minimum, the maximum and the values right beyond them. For quantity 1…100 that is 0, 1, 100, 101. Boundaries come from the specification (minimum, maximum, maxLength, enum).
An absent field, null, an empty string or array (three different cases), a wrong type, a wrong format, a value outside the range or length, extra fields (especially role or balance), broken JSON and a wrong Content-Type. Expected: a controlled 4xx naming the field and an unchanged state, not 500.
A minimal set of combinations in which every pair of values of two parameters appears at least once: for 3 × 2 × 2 that is 6 tests instead of 12. Used when there are many parameters (filters, sorting, options). Generated by tools (PICT, AllPairs), while dependent and dangerous combinations are added by hand.
Build a transition table: each allowed transition works, each forbidden one gives 409 and leaves the state unchanged, a repeat does not duplicate effects. Data: each test creates and cleans up its own, run order does not matter. Priority by risk: probability of a defect × impact; money, access rights and new logic get the deepest testing.
Do not go deeper; reproduce minimally; isolate the layer; gather evidence (request, response, trace id, time); assess the scope without harm; severity; report; mitigation; verify the fix; add a regression.
The server checks the token but not the owner of the resource, so a user reads or changes foreign data by id. Test with two accounts: open B’s resource with A’s token in every method, nested resource and export. The bug is critical.
A title with severity, environment and version, steps, expected and actual, request and response (without secrets), trace id, time with a zone, impact and scope, what was checked, a workaround, reproduction frequency.
A binary floating-point number does not store 0.1 exactly (3 × 0.1 = 0.30000000000000004). Use integer minor units or decimal with one rounding rule. Check the sum of items against total, percentage discounts, rounding boundaries, currencies with 0 and 3 decimals.
Send N identical requests in parallel and compare the state (record count, balance), not only the responses. A race is non-deterministic: repeat 5–10 times and record the frequency. The fix: an idempotency key, a unique index, locking.