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?

TopicWhat to be able to explain
MethodsWhy PUT and DELETE are idempotent while POST is not, and when PATCH fits a partial update
Status codesHow 401 Unauthorized differs from 403 Forbidden, why 204 has no body, when 409 signals a conflict
CachingHow max-age in Cache-Control differs from ETag revalidation with If-None-Match, and what a 304 means
HeadersContent-Type versus Accept, how a Bearer token travels in Authorization, and why Host matters on shared servers
CookiesWhat SameSite limits (CSRF), what HttpOnly blocks (script access), and why Secure requires HTTPS

How do you practise HTTP questions before the interview?

  1. Trace one request with curl -v and label the method, request headers, status line, and response headers.
  2. Build a small REST endpoint that returns 201 with a Location header on create and 404 for an unknown ID.
  3. Send the same PUT twice and confirm the resource state does not change, which tests idempotency in practice.
  4. 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 224 HTTP & APIs interview questions on this topic, 10 of them on this page, at difficulty 2–5 of 5.
  • Tarmac tracked 2,497 job postings asking for HTTP & APIs in November 2026.
  • Roles asking for HTTP & APIs advertise a median base salary of £75,000, across 489 job postings as of November 2026.
  • Tarmac last reviewed these HTTP & APIs interview questions on 2 November 2026.

At a glance

Questions10 shown · 224 in the bank
Difficulty2–5 of 5
FormatsMultiple choice, Find the bug, Flashcard, Fill in the blank, Multiple answer, Ordering, Short answer, Code output, True / false

What you'll review

  1. webhooks
  2. status codes
  3. cookies sessions
  4. oauth basics
  5. api design
  6. 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.

Why:

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

Why:

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.

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:

  1. 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.
  2. The state parameter in the authorization request is an opaque value the client generates and later verifies in the callback response, primarily to prevent CSRF attacks.
Why:

Blank 0 is "short-lived" (also accepted as short-term): access tokens expire quickly, minutes to hours, to limit the damage window if stolen. Blank 1 is "long-lived" (also accepted as long-term): refresh tokens last days to months so the client can silently get new access tokens without the user logging in again. Blank 2 is "CSRF" (equivalently XSRF or cross-site request forgery): the state parameter is a per-request anti-forgery value the client stores, sends in the authorization request, and checks against the callback, so a malicious site cannot make the client complete an authorization flow it did not start.

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

Unique immutable event IDs, HMAC-SHA256 payload signatures, and retries with exponential back-off plus jitter capped at a maximum attempt count are established webhook producer best practices. Delivering only to a hard-coded IP list with no retries is not, because a single transient failure would permanently lose the event.

Why:

Three practices are established for a production webhook producer. Including a unique, immutable event identifier in each payload lets consumers deduplicate redelivered events and process them idempotently. Signing each payload with HMAC-SHA256 using a per-consumer secret lets consumers verify that the request really came from the producer and was not altered. Retrying failed deliveries with exponential back-off plus jitter, capped at a maximum attempt count, recovers from transient consumer outages without a retry storm. The option that delivers only to a hard-coded list of IP addresses with no retry is wrong, because any transient failure would permanently lose the event and the fixed list cannot accommodate consumers that move or scale.

Place the following steps of inbound webhook request handling in the correct order, from first to last, so that the signature is checked against the exact bytes the sender signed and before any payload data is trusted:#

Put these in order

Show answer

Inbound webhook handling must read the raw body first, then verify the HMAC signature over those exact bytes, and only then parse the JSON. Verifying before parsing means unauthenticated data is never trusted, and parsing first can alter the bytes so the signature no longer matches.

Why:

The HMAC must be computed over the exact raw bytes the sender signed, so the body has to be read and buffered before anything else touches it; parsing and re-serializing JSON can change whitespace or key order and break the signature. Signature verification comes next, and a mismatch is rejected with 401 Unauthorized. Only after verification succeeds is the payload parsed, because unauthenticated data should not be trusted or processed. This order is forced by these two dependencies, so the three steps have a single correct sequence.

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.

Why:

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

Reject the token. A JWT whose exp time has passed is invalid under RFC 7519, because the current time must be before exp. Under RFC 6750, the resource server should return HTTP 401 with WWW-Authenticate: Bearer error="invalid_token".

Why:

RFC 7519 §4.1.4 requires that the current date/time be before the exp value for the token to be valid; at 1700000001 the token is one second past exp, so it fails that check. RFC 6750 §3.1 classifies an expired token as an invalid_token error, for which the resource server should respond with HTTP 401 and a WWW-Authenticate: Bearer header including error="invalid_token". The other statements are false: sub is an opaque string with no email requirement, aud may legitimately be a URI, and RFC 7519 sets no one-hour acceptance window (any small clock-skew leeway is an optional implementation choice, not a requirement of the RFC).

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
Why:

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.

Why:

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 214 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 214 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 answers per 30 days, each marked with written feedback

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.