HTTP interview questions: methods, status codes, caching, cookies, and REST APIs
Reviewed by Mark Dickie · Last updated
7 questions on this page you can answer and see marked on the spot. Go to the first one
HTTP is the request-response protocol clients use to talk to servers, and most web APIs are built on top of it. Interviewers usually start with the basics: which method fits which action, what a status code tells the client, and why GET should never change server state. From there they move to idempotency, caching with Cache-Control and ETag, and how REST resources map onto URLs. Expect at least one question about what happens between typing a URL and receiving a response, since that answer touches DNS, TCP, TLS, and HTTP in sequence.
Which HTTP topics come up most in interviews?
| Topic | What to be able to explain |
|---|---|
| Methods | Why PUT and DELETE are idempotent while POST is not, and when PATCH fits a partial update |
| Status codes | How 401 Unauthorized differs from 403 Forbidden, why 204 has no body, when 409 signals a conflict |
| Caching | How max-age in Cache-Control differs from ETag revalidation with If-None-Match, and what a 304 means |
| Headers | Content-Type versus Accept, how a Bearer token travels in Authorization, and why Host matters on shared servers |
| Cookies | What SameSite limits (CSRF), what HttpOnly blocks (script access), and why Secure requires HTTPS |
How do you practise HTTP questions before the interview?
- Trace one request with curl -v and label the method, request headers, status line, and response headers.
- Build a small REST endpoint that returns 201 with a Location header on create and 404 for an unknown ID.
- Send the same PUT twice and confirm the resource state does not change, which tests idempotency in practice.
- Set Cache-Control and ETag on a response, then request it again with If-None-Match and check for a 304.
Key facts
- Tarmac has 208 HTTP & APIs interview questions on this topic, 10 of them on this page, at difficulty 2–5 of 5.
- Tarmac tracked 2,889 job postings asking for HTTP & APIs in October 2026.
- Roles asking for HTTP & APIs advertise a median base salary of £77,500, across 671 job postings as of October 2026.
- Tarmac last reviewed these HTTP & APIs interview questions on 2 November 2026.
At a glance
| Questions | 10 shown · 208 in the bank |
|---|---|
| Difficulty | 2–5 of 5 |
| Formats | Multiple choice, Find the bug, Flashcard, Fill in the blank, Multiple answer, Ordering, Short answer, Code output, True / false |
What you'll review
- webhooks
- status codes
- cookies sessions
- oauth basics
- api design
- rate limiting
Practice questions
Try one before you open the answer. Pick an option and press Check; it's marked on the spot.
You are designing a webhook consumer endpoint that receives order-created events from a third-party payment provider. The provider retries delivery up to 5 times with exponential back-off if it does not receive an HTTP 2xx within 10 seconds. Processing each event involves writing to a database and sending an email, which can take up to 30 seconds.#
Options
Show answer
The correct strategy is to verify the webhook's HMAC signature, persist the raw payload to a durable queue or store, return 200 OK right away, and process the event asynchronously — using the event ID to deduplicate before taking any action. This matters because the provider expects a 2xx within its 10-second timeout window, but the actual work (database write, email send) can take up to 30 seconds. If you do that work synchronously, the provider times out and retries, producing duplicate deliveries. Storing the raw payload first and processing it later is the standard accept-then-process pattern; checking the event ID before acting prevents duplicate side effects across retries.
Webhook reliability requires the consumer to respond quickly (within the provider's timeout window, often 5–30 s) with a 2xx status to acknowledge receipt, then process asynchronously. If the consumer does heavy work synchronously and times out, the provider may retry, causing duplicate deliveries. Idempotency keys/event IDs let consumers deduplicate retries. Signature verification (HMAC) guards against spoofed payloads but does not help with duplicate delivery. Storing the raw payload before processing is the correct 'accept-then-process' pattern. The strategy of verifying the HMAC signature, persisting the raw payload to a durable queue/store, returning 200 OK immediately, and processing asynchronously — using the event ID to deduplicate before acting — describes returning a 200 immediately and queuing the work — the correct pattern — while the others describe anti-patterns or incomplete solutions.
This Express handler creates a new user. From an HTTP-semantics standpoint, what is wrong with the response?#
app.post("/users", async (req, res) => {
const user = await db.users.create(req.body);
res.status(200).json(user);
});Options
Show answer
It should respond 201 Created (ideally with a Location header), not 200 OK, because a new resource was created
When a request creates a new resource the correct status is 201 Created, and best practice is to include a Location header (e.g. /users/{id}) pointing at it (RFC 9110 §15.3.2). POST is a perfectly valid way to create a subordinate resource, returning the representation in the body is fine, and 204 would be wrong because there is a body to send.
What does the HttpOnly attribute on a Set-Cookie header do, and why use it for session cookies?#
Show answer
HttpOnly makes the cookie inaccessible to client-side JavaScript (document.cookie); it is only sent automatically on HTTP requests. Setting it on a session cookie blunts XSS attacks, because injected script cannot read or exfiltrate the session token. Pair it with Secure (HTTPS only) and SameSite (CSRF mitigation).
HttpOnly is a core defence for session cookies: even if an attacker injects script via XSS, they cannot steal the cookie through the DOM. It does not prevent the cookie from being sent, so SameSite and CSRF tokens remain necessary for cross-site request protection.
Complete the following statements about OAuth 2.0 token types and the state parameter:#
Show answer
Complete the following statements about OAuth 2.0 token types and the state parameter:
- An access token is typically short-lived (lasting minutes to hours), while a refresh token is typically long-lived (lasting days to months) and is used to obtain new access tokens without re-involving the user.
- The
stateparameter in the authorization request is an opaque value the client generates and later verifies in the callback response, primarily to prevent CSRF attacks.
Access tokens are intentionally short-lived to limit the damage window if they are compromised; once expired, the client must use a long-lived refresh token to get a new one without forcing the user to log in again. The state parameter acts as a CSRF mitigation: the client stores it locally (e.g., in session or a cookie), includes it in the authorization request, and then verifies that the value returned in the callback matches—preventing a malicious site from tricking the client into completing an authorization flow it did not initiate.
You are building a webhook producer system that notifies registered consumers of payment.succeeded events. Select all statements that represent established best practices for a production-grade webhook producer.#
Options
Pick every one that applies.
Show answer
A production-grade webhook producer should include a unique, immutable event_id in every payload so consumers can deduplicate and process events idempotently. Each payload must be signed with HMAC-SHA256 using a per-consumer secret, with the signature placed in a request header such as X-Signature so consumers can verify authenticity. Failed deliveries should be retried using exponential back-off with jitter, stopping after a configurable maximum number of attempts and notifying the consumer owner when failures persist.
A robust webhook producer must handle consumer-side failures gracefully. The correct practices are: (1) retry with exponential back-off and jitter to avoid thundering-herd effects, (2) include a unique, stable event ID so consumers can deduplicate, (3) sign payloads (e.g., HMAC-SHA256) so consumers can verify authenticity, and (4) emit a full event envelope rather than just an identifier (although 'thin' notification + fetch is a valid alternative pattern). Delivering from a single IP without fallback, expecting synchronous processing in under 1 s, and omitting signatures are all anti-patterns. The event ID, the signed payload and retry with back-off are all correct best practices; delivering only to a fixed IP with no retry is not.
Place the following steps of inbound webhook request handling in the correct order, from first to last, for a secure and reliable consumer implementation:#
Put these in order
Show answer
Inbound webhook handling proceeds in five stages: first, read and buffer the raw request body bytes before any parsing so the HMAC is computed over the exact bytes the sender signed. Second, verify the HMAC-SHA256 signature over that raw body with the shared consumer secret, rejecting with 401 if it does not match. Third, parse the verified JSON into a domain object. Fourth, check the event ID against already-processed IDs so duplicate retries are skipped. Fifth, enqueue the event for asynchronous processing and return 200 OK. Computing the signature before parsing and verifying authenticity before idempotency are the two orderings that matter most — reversing either opens a security hole or a correctness gap.
The ordering question covers the correct sequence for securely and reliably processing an inbound webhook. You must first read and buffer the raw body before any parsing so the HMAC can be computed over the exact bytes the sender signed. Next you verify the HMAC signature against the raw body — rejecting with 401/403 if invalid — before trusting any data. Then you parse/deserialize the verified payload. After that you perform idempotency check using the event ID so duplicate retries are ignored. Finally you enqueue the work for async processing and return 200 OK. Reversing signature verification and parsing, or checking idempotency before verifying authenticity, are both security or correctness errors.
You are designing a REST API endpoint that allows a client to partially update a resource. The client wants to update only the email field of a user without touching any other fields. Explain which HTTP method you should use, why it is preferred over the alternative update method for this use case, and what a minimal correct request would look like (method, path, and body).#
Show answer
Use PATCH instead of PUT. PUT is meant for full replacement of a resource — the client must send the complete representation, and any omitted fields may be set to null or cause errors. PATCH is designed for partial updates: the client sends only the fields it wants to change. A correct request would be: PATCH /users/42 with body {"email": "[email protected]"}. The server applies only that change, leaving all other fields intact.
PATCH is the semantically correct method for partial updates per RFC 5789. PUT implies a complete replacement of the resource at the given URI; sending a partial body with PUT can lead to data loss or implementation-specific behavior. PATCH lets clients send a diff/patch document (often just a JSON subset) so only specified fields are changed. Strong candidates also note that PUT is idempotent and PATCH may be idempotent depending on the patch semantics, and that the server should return 200 or 204 on success.
An OAuth 2.0 authorization server issues tokens with the following JWT payload:#
Options
Show answer
The resource server must reject the token with HTTP 401 and WWW-Authenticate: Bearer error="invalid_token" because the exp claim has elapsed. RFC 7519 §4.1.4 states JWT processors MUST reject tokens where the current time is at or after exp. RFC 6750 §3.1 mandates the 401 + invalid_token response. There is no mandatory default clock-skew tolerance defined by the spec.
RFC 7519 §4.1.4 mandates that JWT processors MUST reject tokens where the current time is at or after the exp value. RFC 6750 §3.1 specifies that an expired token is an invalid_token error and the resource server MUST respond with HTTP 401 and a WWW-Authenticate header carrying error="invalid_token". The azp claim (authorized party) is checked by the client, not required by the resource server for basic validation. The aud as a URI is perfectly valid per RFC 7519 §4.1.3. RFC 7519 does acknowledge that implementors may allow small clock skew, but it is not a default tolerance, and 'MUST reject' takes precedence — accepting is never the correct answer once past exp.
A Node.js API gateway uses the following sliding-window rate-limiter logic. Given that the current Unix timestamp is 1000 seconds and the client has prior request timestamps of [994, 996, 998, 999] stored in a sorted set, what does the function log when a new request arrives at t = 1000 with a 5-second window and a limit of 4 requests?#
function checkRateLimit(timestamps, now, windowSecs, limit) {
const windowStart = now - windowSecs; // 1000 - 5 = 995
const recent = timestamps.filter(t => t > windowStart);
if (recent.length >= limit) {
const retryAfter = windowSecs - (now - recent[0]);
console.log(`429 Too Many Requests. Retry-After: ${retryAfter}s`);
} else {
recent.push(now);
console.log(`200 OK. Requests in window: ${recent.length}`);
}
}
checkRateLimit([994, 996, 998, 999], 1000, 5, 4);Options
Show answer
200 OK. Requests in window: 4
windowStart = now - windowSecs = 1000 - 5 = 995. The filter t > 995 (strictly greater than) drops 994 (which equals 995 − 1, not strictly greater) and keeps [996, 998, 999] — that is 3 entries. Since 3 < 4 (the limit), the if branch is not taken; the else branch runs, pushes 1000 onto recent making its length 4, and logs 200 OK. Requests in window: 4. The output 429 Too Many Requests. Retry-After: 1s would be the output only if all four prior timestamps were in-window (i.e., recent.length >= 4 before the push), but that is not the case here because 994 is excluded by the strict > comparison.
HTTP/2 multiplexing completely eliminates head-of-line (HOL) blocking for all requests sharing a single connection, including scenarios involving packet loss at the TCP layer.#
Options
Show answer
False. HTTP/2 multiplexing eliminates HOL blocking at the HTTP layer by interleaving frames from multiple streams on one connection, but TCP's own HOL blocking remains: a single lost packet stalls every stream on that connection until it is retransmitted. HTTP/3 (QUIC over UDP) is what actually addresses the TCP-level HOL problem.
HTTP/2 multiplexing eliminates head-of-line blocking at the HTTP layer by allowing multiple streams over a single TCP connection. However, TCP itself still suffers from head-of-line blocking at the transport layer — a single lost packet stalls all streams on that connection. HTTP/3 (QUIC) solves this by operating over UDP with per-stream loss recovery. The statement that HTTP/2 fully eliminates head-of-line blocking is therefore false; it only solves it at the application layer, not the transport layer.
Sources
The official documentation these questions are checked against:
Related interview questions
Job market
See http-apis salaries and hiring demand from live job postings.
The other 198 questions
This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 198 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.
Free · the whole bank · 100 answers per 30 days, each marked with written feedback