HTTP & APIs Interview Questions: REST Idempotency
Reviewed by Mark Dickie · Last updated
14 questions on this page you can answer and see marked on the spot. Go to the first one
HTTP idempotency is a property where sending the same request more than once leaves the server in the same state as sending it a single time. Know which REST methods the HTTP spec calls idempotent (GET, HEAD, PUT, DELETE, OPTIONS) versus which it does not (POST, PATCH), and how that differs from safety. Idempotency keys are the other pattern to know: the header-based approach that lets a client retry a POST without creating a duplicate.
| Method | Safe | Idempotent | Typical use |
|---|---|---|---|
| GET | Yes | Yes | Read a resource |
| HEAD | Yes | Yes | Read headers only |
| OPTIONS | Yes | Yes | Describe capabilities |
| POST | No | No | Create or non-safe action |
| PUT | No | Yes | Replace a resource |
| DELETE | No | Yes | Remove a resource |
| PATCH | No | No | Partial update |
What is the difference between idempotent and safe HTTP methods?
A safe method does not modify server state. GET and HEAD are safe because reading a resource should never change it. Idempotency is a weaker guarantee: the method can change state, but repeating the call produces the same result each time. PUT and DELETE fit here. A DELETE on the same resource twice should end with the resource gone, whether the second call found it or returned 404.
How do idempotency keys make POST retries safe?
POST is not idempotent, so retrying it can create duplicate records or charges. An idempotency key lets the server deduplicate retries by storing the first response under a client-supplied key:
- Client generates a unique key, often a UUID, and sends it in the
Idempotency-Keyheader on the POST request. - Server processes the request and stores the response keyed by that ID before returning it, usually with a short TTL.
- On a retry with the same key, the server returns the stored response instead of re-running the operation.
- If the key is not found (expired or first seen), the server processes the request normally and stores the result.
Key facts
- Tarmac's HTTP & APIs interview questions cover 24 questions at difficulty 1–5 of 5.
- Tarmac tracked 2,644 job postings asking for HTTP & APIs in September 2026.
- Roles asking for HTTP & APIs advertise a median base salary of US$165,000, across 867 job postings as of September 2026.
- Tarmac last reviewed these HTTP & APIs interview questions on 13 October 2026.
At a glance
| Questions | 24 |
|---|---|
| Difficulty | 1–5 of 5 |
| Formats | True / false, Short answer, Multiple choice, Fill in the blank, Multiple answer, Find the bug |
What you'll review
- idempotency
Practice questions
Try one before you open the answer. Pick an option and press Check; it's marked on the spot.
In REST API design, a GET request is idempotent: sending the same GET request multiple times produces the same result as sending it once. True or false?#
Options
Show answer
True. A GET request is idempotent in REST: sending the same GET request repeatedly returns the same representation and leaves server state unchanged. Because GET only reads data, repeating it has no side effects.
A GET request only retrieves a representation of a resource and does not modify server-side state, so repeating the identical request yields the same observable result as sending it once. Idempotency is defined by the effect of repeated identical requests on the server, and a GET has no such effect, so the statement is true.
Among the HTTP methods GET, PUT, DELETE, and POST, which one is NOT idempotent in REST API design? Answer with the method name.#
Show answer
POST is not idempotent because repeated identical POST requests can create duplicate resources or trigger repeated side effects on the server.
POST is the canonical non-idempotent HTTP method: each identical POST can create a new resource or trigger a new side effect, so repeating it changes the outcome. GET is a read-only retrieval, PUT replaces the same target resource state each time, and DELETE removes the same resource each time, all producing the same end state regardless of repetition. Restricting the question to these four methods avoids PATCH, whose idempotency depends on the patch document.
Which of the following HTTP methods is NOT idempotent?#
Options
Show answer
POST is the HTTP method that is not idempotent. Sending the same POST request several times typically creates a new resource each time, so the outcome differs from sending it once. GET, PUT, and DELETE all leave the server in the same state when repeated.
An idempotent HTTP method is one where sending the same request multiple times has the same effect as sending it once. GET, PUT, and DELETE are idempotent: repeated GETs return the same resource state, repeated PUTs set the resource to the same target state, and repeated DELETEs leave the resource deleted. POST is not idempotent because each request typically creates a new resource, so sending it twice creates two resources rather than one.
An HTTP method is called _____ if making the same request multiple times has the same effect on the server's state as making it a single time.#
Show answer
An HTTP method is called idempotent if making the same request multiple times has the same effect on the server's state as making it a single time.
Idempotency means that repeated identical requests do not change the server's resource state beyond the effect of the first request. This property lets clients safely retry a request (for example, after a network timeout) without worrying about duplicating side effects. GET, PUT, and DELETE are the classic idempotent methods, while POST is not.
Which of the HTTP methods PUT, POST, PATCH, and CONNECT is idempotent?#
Options
Show answer
PUT is the only idempotent method among PUT, POST, PATCH, and CONNECT. Repeating a PUT with the same representation leaves the server in the same state as a single call. POST can create duplicate resources, and PATCH is not guaranteed idempotent.
PUT is idempotent because it replaces the target resource with the representation in the request, so repeating the same PUT leaves server state the same as a single call. POST is not idempotent because it typically creates a new resource on each call. PATCH is not guaranteed idempotent because it applies a change set that may be additive, so repeating it can change the result. CONNECT establishes a tunnel and is not idempotent. PUT is therefore the only idempotent method in this set.
According to RFC 9110 (HTTP Semantics), which HTTP request methods are defined as idempotent? List all of them. Then explain why POST is not idempotent, and why PATCH (defined in RFC 5789, not RFC 9110) is not guaranteed to be idempotent.#
Show answer
Per RFC 9110, the idempotent methods are GET, HEAD, OPTIONS, TRACE, PUT, and DELETE. Idempotent means that sending the same request multiple times has the same intended effect on server state as sending it once. The safe methods (GET, HEAD, OPTIONS, TRACE) do not change state at all, and PUT (replace the whole target representation) and DELETE (remove the target) reach the same end state on repetition. POST is not idempotent because each request typically asks the server to create a new subordinate resource, so repeats create duplicates. RFC 5789 defines PATCH as neither safe nor idempotent: a patch document can describe relative changes (for example, append an item or increment a counter), so applying it twice can produce a different state than applying it once.
RFC 9110 states that PUT, DELETE, and the safe methods are idempotent; the safe methods are GET, HEAD, OPTIONS, and TRACE, giving six idempotent methods in total. Idempotency is judged by the effect on server state, so repeated identical requests must leave the same end state as one request. POST is not idempotent because it typically creates a new subordinate resource on each request, so repetition creates more resources. PATCH is not idempotent by definition in RFC 5789 because a patch document may express relative changes such as appending or incrementing, whose effects accumulate when repeated.
Which statement about HTTP idempotency is correct?#
Options
Show answer
PUT is idempotent: repeating an identical PUT request leaves the resource in the same state as a single request. Idempotency concerns the effect on server-side state, so PUT stays idempotent even when it creates a resource. POST and PATCH do not carry that guarantee in general.
Idempotency means that repeated identical requests have the same effect on server-side state as a single request. PUT meets this even when it creates a resource, because every identical PUT leaves the resource in the same state. POST can create duplicate records when repeated, and PATCH is not guaranteed idempotent by its definition, since only some PATCH operations (such as full replacement) are. Idempotency concerns the effect on state rather than the response body, so requiring identical response bodies is not part of the definition.
Under RFC 9110, a method is idempotent if multiple identical requests leave server-side resource state the same as a single request, even when the responses carry different status codes (for example, the first DELETE returns 200 and a repeated DELETE returns 404). True or false: under this definition, DELETE is idempotent.#
Options
Show answer
True. RFC 9110 defines idempotency by its effect on server-side resource state, not by the response code returned. Repeated DELETE requests leave the resource absent just as a single DELETE does, so a first 200 followed by a 404 does not break idempotency.
The statement is true. RFC 9110 defines idempotency by the effect a request has on server-side resource state, not by the response it receives. Repeating a DELETE leaves the resource absent in the same way as a single DELETE, so the state is identical. The first request returning 200 and a repeat returning 404 does not change that, so DELETE is idempotent.
Per the HTTP specification (RFC 9110), sending an Idempotency-Key header with a POST request makes the POST method itself idempotent. Is this statement true or false?#
Options
Show answer
False. Adding an Idempotency-Key header does not make the POST method idempotent under the HTTP specification. RFC 9110 defines idempotent methods such as GET, PUT, and DELETE, and POST is not among them. The key is an application-level convention that lets the server detect duplicate requests and return the stored response.
RFC 9110 lists the idempotent methods as GET, HEAD, OPTIONS, TRACE, PUT, and DELETE; POST is not one of them, and no header defined in the specification changes that. The Idempotency-Key header is a de facto convention popularized by payment APIs such as Stripe, not part of HTTP/1.1, HTTP/2, or RFC 9110-9114. It does not alter the formal semantics of POST. The guarantee comes from server-side logic: the server stores the response for a given key and replays it for duplicate requests instead of re-executing the operation. The statement is therefore false.
A REST API exposes POST /payments to charge a customer. A network timeout causes the client to retry the identical request. Describe how an Idempotency-Key header prevents a duplicate charge, and state the one storage requirement that makes this guarantee reliable across server restarts and multiple backend instances.#
Show answer
The client sends a unique Idempotency-Key (e.g., a UUID) with each logical operation. Before processing the request, the server checks whether it has already seen that key in a durable store (e.g., a database). If the key is new, the server executes the charge and persists both the key and the resulting response (status code, body) to that store. If the key already exists, the server skips re-processing and returns the previously stored response. Because the key-to-response mapping is stored durably (not in process memory), the guarantee survives restarts and is visible to all backend instances behind the load balancer.
The retry is safe because the server ties the client's unique key to the outcome of the first attempt. On the first request the server records the key with the stored response; on any retry carrying the same key, it finds the record and replays that response instead of charging again. The required storage property is durability: the key-to-response mapping must live in a shared, persistent store (such as a database) rather than process memory, so that it survives restarts and is visible to every instance behind a load balancer. Without that, a retry routed to a different instance or after a restart would find no record and charge the customer a second time.
Per RFC 9110 and the IANA HTTP Method Registry, which of the following HTTP methods is idempotent but NOT safe?#
Options
Show answer
PUT is the HTTP method that is idempotent but not safe among GET, POST, PATCH and PUT. Repeating an identical PUT leaves the target resource in the same state, but PUT is not safe because it modifies the representation of the target resource on the server.
Per RFC 9110, a safe method is one whose semantics are read-only, and safe methods are also idempotent, so GET is both safe and idempotent and fails the 'not safe' condition. POST is neither safe nor idempotent. PATCH (RFC 5789) is listed in the IANA HTTP Method Registry as not idempotent, because applying the same patch document to different resource states can yield different results. PUT is idempotent, since repeated identical PUT requests leave the resource in the same state, but it is not safe because it changes the state of the target resource. The question is limited to the listed choices, so DELETE, which shares the same idempotent-but-not-safe property, does not appear.
Your REST API exposes a POST /charges endpoint for processing payments. A client sends a request with an Idempotency-Key: 8f14e45f header, but the connection drops before the response arrives. The client retries the identical request with the same Idempotency-Key: 8f14e45f header. In 2-3 sentences, describe what the server must do to ensure the charge is created only once and the client receives a consistent response.#
Show answer
The server must store the Idempotency-Key along with the request details and the resulting response (status code, headers, body) the first time it processes the charge. When the retry arrives with the same Idempotency-Key, the server returns the stored response instead of processing the charge again, so the payment is created exactly once and the client sees the same result both times.
Idempotency keys work by having the server persist a mapping from the key to the full response of the first request. On a retry with the same key, the server short-circuits processing and returns the stored response, which guarantees the side effect (charge creation) happens exactly once. This pattern matters for non-idempotent methods like POST, where a naive retry would create a duplicate charge.
An API requires an Idempotency-Key header on POST /payments. A client sends a charge, the server commits it successfully, but the 200 response is lost to a network timeout. The client retries with the same Idempotency-Key. What should a correctly-implemented server do?#
Options
Show answer
The server should recognise the stored key and return the exact same response it produced the first time, without charging the card again. An idempotency key makes an unsafe POST safe to retry: the server records the key alongside its response, then replays that stored response verbatim on any later request bearing the same key. So the timed-out retry gets the original 200 and the card is charged once.
The whole point of an idempotency key is to make an unsafe operation (POST of a charge) safe to retry: the server records the key together with the response it produced, and a later request bearing the same key replays that stored response verbatim instead of re-executing the side effect. So the timed-out retry gets the original 200 and the card is charged once. The option that describes plain stateless HTTP defeats the mechanism — it would double-charge. The option that says a repeated key is a malformed, duplicate request is wrong because a repeated key is exactly the expected, supported case, not a client error. The option that says to respond 409 Conflict is the tempting trap: 409 Conflict is the right answer only for the different scenario where a second request with the same key arrives while the first is still in flight — the server locks on the key and rejects the concurrent duplicate. For a replay of an already-completed request there is nothing in conflict; the server simply returns the cached original result.
Which HTTP methods are idempotent — making the identical request many times leaves the server in the same state as making it once?#
Options
Pick every one that applies.
Show answer
GET, PUT, and DELETE are idempotent — but not POST. Repeating PUT re-sets the same state, and repeating DELETE leaves the resource deleted (later calls may return 404, but the server state is unchanged). POST is not idempotent because each call typically creates a new resource, which is why retries need an idempotency key.
GET, PUT, and DELETE are idempotent: repeating PUT re-sets the same state, and repeating DELETE leaves the resource deleted (the later calls may return 404, but the server state is unchanged). POST is not idempotent — each call typically creates a new resource, which is why retries need an idempotency key (RFC 9110 §9.2.2).
This Express handler implements idempotent payments: clients send an Idempotency-Key and a retry with the same key should never charge twice. Under load, some customers are still being charged twice by simultaneous retries. What is the flaw?#
app.post("/payments", async (req, res) => {
const key = req.header("Idempotency-Key");
const existing = await store.get(key);
if (existing) {
return res.status(existing.status).json(existing.body);
}
const charge = await gateway.charge(req.body);
const response = { status: 201, body: charge };
await store.set(key, response);
return res.status(response.status).json(response.body);
});Options
Show answer
The key is only written to the store after gateway.charge returns, and the check-then-charge-then-store sequence is not atomic, so two concurrent retries both pass the existing check and both charge
The guarantee breaks because the key is recorded only after the side effect. The read (store.get), the charge, and the write (store.set) are three separate awaits with no lock and no atomic reserve. Two retries that arrive close together both run store.get before either has called store.set, both see no existing record, and both call gateway.charge — a double charge. The fix is to atomically reserve the key before charging (e.g. an INSERT … ON CONFLICT DO NOTHING / conditional put that the second request loses, or a row lock on the key), so a concurrent duplicate is detected up front and either waits for or replays the first result. The claim that the handler must use PUT is wrong: HTTP method semantics describe intent, they do not enforce at-most-once execution — PUT would have the identical race. The claim that replaying a stored response must use 200 OK is wrong: replaying the original response means returning the original status, including 201; rewriting it to 200 would misreport what happened. The claim that the server should generate the key itself is an actively harmful trap: the key must be minted by the client and held stable across attempts — that stability is what links a retry to its original. A server-generated key would differ on every attempt, so no two retries would ever match and deduplication would be impossible.
What does it mean for an HTTP method to be idempotent, and why does it matter for clients that retry?#
Show answer
An idempotent method produces the same server state whether the identical request is sent once or many times. PUT and DELETE are idempotent (and GET is too); POST is not. It matters because a client that times out can safely retry an idempotent request without risk of duplicating the effect — repeating a DELETE still leaves the resource gone, whereas blindly retrying a POST could create duplicates, which is why non-idempotent writes use an idempotency key.
Idempotency is about the effect on server state, not the response body: repeating an idempotent request leaves the same state as a single call (RFC 9110 §9.2.2). Safe methods are a subset — all safe methods are idempotent. This property is what makes automatic retries of GET/PUT/DELETE safe, while POST retries need an idempotency key to avoid duplicate side effects.
A REST API exposes PUT /users/{id}/profile. The handler replaces the profile resource in the database, but it also increments an update_count field that is stored inside the profile resource itself, so every call changes that field. The team debates whether this endpoint is idempotent per RFC 9110. State your determination and justify it using the RFC 9110 definition of idempotency.#
Show answer
Not idempotent. RFC 9110 §9.2.2 defines an idempotent method as one where the intended effect on the server of multiple identical requests is the same as the effect of a single such request. Here, update_count is part of the profile resource, so after one PUT its value is N and after two identical PUTs it is N+1. The resource state therefore differs between one request and repeated requests, so the endpoint fails the definition even though it uses the PUT method, which only carries an expectation of idempotency, not a guarantee.
RFC 9110 §9.2.2 defines idempotency by comparing the effect of one request with the effect of multiple identical requests. The profile resource includes update_count, and the handler increments it on every call, so one PUT leaves the value at N while two identical PUTs leave it at N+1. Because the resource state changes with each repetition, the endpoint is not idempotent. The PUT method's default expectation does not override this: idempotency depends on what the handler actually does to the resource, not on the method name.
The following Python code implements idempotency-key handling for a POST /payments endpoint. It has a correctness bug that can cause duplicate charges under concurrent retries. Identify the bug by naming the class of concurrency flaw and the two operations involved.#
Show answer
TOCTOU (time-of-check-to-time-of-use) race condition between the SELECT that checks whether the idempotency key already exists and the INSERT that records it; two concurrent requests can both pass the SELECT check and both INSERT, resulting in duplicate charges.
The code does SELECT ... WHERE key = ? then conditionally INSERT ... in Python. There is no database-level uniqueness constraint on the idempotency key column and no transaction or lock protecting the gap between the two statements. Two concurrent requests with the same key can both execute the SELECT, both find no existing row, and both proceed to INSERT and charge, so the bug is a TOCTOU (time-of-check-to-time-of-use) race between the SELECT existence check and the INSERT write. The fix is to enforce a UNIQUE constraint on the idempotency key column and catch the resulting integrity-error on INSERT, or to use INSERT ... ON CONFLICT so the database serializes the check atomically.
Per RFC 9110 (HTTP Semantics) and RFC 5789 (PATCH), explain the distinction between HTTP method safety and idempotency, and classify the standard HTTP methods GET, HEAD, OPTIONS, TRACE, PUT, DELETE, POST, and PATCH accordingly.#
Show answer
Safety means a method is read-only: it produces no observable change to server state, so it can be cached and prefetched. Idempotency means that sending the same request multiple times has the same effect on server state as sending it once. Per RFC 9110, GET, HEAD, OPTIONS, and TRACE are both safe and idempotent. PUT and DELETE are idempotent but not safe: they modify state, yet repeating the same request leaves the resource in the same final state. POST is neither safe nor idempotent, since each request may create a new resource or trigger a unique side effect. Per RFC 5789, PATCH is also neither safe nor idempotent, because applying a partial modification twice (for example, incrementing a counter) can produce a different result than applying it once.
Safety and idempotency are distinct semantic properties defined in RFC 9110. A safe method is read-only and produces no observable state change, which makes it suitable for caching and prefetching; GET, HEAD, OPTIONS, and TRACE are safe. Idempotency is weaker: repeating a request has the same effect as sending it once. GET, HEAD, OPTIONS, TRACE, PUT, and DELETE are idempotent. PUT and DELETE are idempotent but not safe because they modify state while repeating the same replacement or deletion leaves the same final state. POST is neither because each request may create a distinct resource or trigger a unique side effect. RFC 5789 states that PATCH is neither safe nor idempotent, since a partial modification such as incrementing a counter gives a different result when applied twice.
An e-commerce REST API exposes POST /orders to create a new order. The server assigns the order ID, so the client cannot use PUT /orders/{id}. The API team wants to guard against duplicate orders when a client retries after a network timeout. Describe the standard Idempotency-Key pattern for making this POST endpoint safe against duplicate submissions: what the client sends, what the server stores, and what the server returns on a retried request whose original request already succeeded. What HTTP status code should the replayed response carry?#
Show answer
The client generates a unique Idempotency-Key (for example, a UUID) and sends it as a request header on every attempt of the POST /orders call, reusing the same key when it retries. The server stores the key together with a fingerprint of the request parameters and the full response it produced (status code, headers, body). When a request arrives with a key that already has a stored result, the server returns that stored response verbatim without re-processing the request or creating a second order. If no result exists for the key, the server processes the request normally and persists the result under that key. The replayed response carries 201 Created, the same status the original successful creation returned, because the server replays the exact stored response rather than computing a new one.
The Idempotency-Key pattern is a server-side convention layered on top of the non-idempotent POST method, since HTTP itself does not define this header. The client generates a unique key and reuses it on retries. The server persists the key with the request and the complete response it produced, and on a repeated key it replays that stored response, including the original status. For an order that was successfully created, the replay therefore carries 201 Created, not 200 OK, because the stored response is returned verbatim and no new operation is executed.
A REST API uses PUT /widgets/{id} to replace the entire representation of a widget resource. A client sends PUT /widgets/7 with body {'name':'gadget','version':1}, and the resource does not yet exist. The server creates it and returns 201 Created with body {'name':'gadget','version':1,'created_at':'2024-06-01T10:00:00Z'}. The client hits a network timeout and retries the identical request. The server now returns 200 OK with the same body and the same created_at value, and no state change occurs. A teammate argues that because the status changed from 201 to 200, the PUT is not idempotent and the API should use POST instead. Which statement is correct?#
Options
Show answer
The status change does not make PUT non-idempotent. HTTP idempotency (RFC 9110 §9.2) is judged by the intended effect on server state, not by response equality. A retried identical PUT leaves the resource unchanged, and the 201 to 200 difference simply reflects that the resource already exists. POST is not idempotent by definition, so switching would not help.
Per RFC 9110 section 9.2, idempotency is defined by the intended effect on server state: making the same request N times should leave the server in the same state as making it once. It places no requirement that responses match. The first PUT creates the resource, so 201 Created is correct (RFC 9110 allows PUT to return 201 when it creates a resource). The retry finds the resource already in the target representation, so the server answers 200 OK and changes nothing, which is exactly what idempotency requires. The status difference reflects the server's knowledge of the prior creation, not a second state transition. POST is not idempotent by definition, so moving to POST would make the non-idempotency real rather than fix it.
RFC 9110 (HTTP Semantics) defines idempotency for certain HTTP methods. Which of the following statements is true about idempotency as defined in that specification?#
Options
Show answer
Logging each request does not violate idempotency. RFC 9110 §9.2.2 defines idempotency by the intended effect of the requested action on server state, so the server may separately perform independent actions such as writing log entries or incrementing a request counter. Idempotent methods need not be safe, and POST is not idempotent.
Per RFC 9110 §9.2.2, a request method is idempotent when multiple identical requests with that method have the same intended effect on server state as a single such request. The specification explicitly says the idempotent property applies only to what the user requested, and the server may separately initiate actions independent of the request, such as logging, without violating idempotency. The statement about logging and counters is therefore the true one. The statement that idempotent methods must be safe is false, since PUT and DELETE are idempotent but not safe. POST is not defined as idempotent, and the specification does not require identical response bodies across repeated requests.
A REST API implements these endpoints (RFC 9110 semantics assumed throughout):<br><br>• <code>GET /widgets/{id}</code> — returns the widget or 404.<br>• <code>PUT /widgets/{id}</code> — creates or replaces the widget with the request body; returns 201 on first create, 200 on subsequent replace.<br>• <code>DELETE /widgets/{id}</code> — deletes the widget; returns 200 if it existed, 404 if not.<br>• <code>POST /widgets/{id}/views</code> — increments a view counter; returns 200.<br>• <code>POST /widgets</code> — creates a new widget with a server-generated id; returns 201.<br><br>Regarding HTTP idempotency as defined by RFC 9110, which of the following statements are TRUE?#
Options
Pick every one that applies.
Show answer
Three statements hold: DELETE and PUT are idempotent because RFC 9110 defines idempotency as identical server state after one or more identical requests — not identical responses — so different status codes (200→404, 201→200) conform. POST …/views is non-idempotent since the counter changes per call. The other two fail: GET safety doesn't bar all server side effects (the RFC acknowledges logging), and POST has no protocol-level deduplication requirement on retry.
RFC 9110 defines idempotency as a property of server state — identical requests, whether issued once or N times, leave the server in the same state — not as identical responses. DELETE and PUT are idempotent methods: after two identical DELETE calls the resource is gone just as it was after the first, and after two identical PUT calls with the same body the resource content is the same as after one. The differing status codes (200→404 for DELETE, 201→200 for PUT) are fully conformant because the RFC states that idempotent requests 'might not have the same response.' POST /widgets/{id}/views is non-idempotent: each call mutates the counter, so the server state after two calls differs from after one. The GET statement is false because the RFC explicitly acknowledges that 'it is not possible to ensure that the server does not generate side effects while handling a request' — safety concerns the requested semantics (read-only intent), not a prohibition on all server-side side effects. The POST /widgets statement is false because POST is not idempotent per the spec; there is no protocol-level requirement to deduplicate or return the same resource id on retry — preventing duplicates is an application-level concern typically handled with an Idempotency-Key header or a uniqueness constraint.
A REST API for an order management system exposes these endpoints:#
Options
Pick every one that applies.
Show answer
The correct statements are that PUT is idempotent under RFC 7231, that DELETE is idempotent because repeated deletes leave the resource absent, and that a POST with an Idempotency-Key returns the stored original response for duplicates. PATCH is not idempotent by its method definition, and a JSON Patch add to /tags/- appends a new element on every application.
The three correct statements are the PUT claim, the DELETE claim, and the POST-with-Idempotency-Key claim. RFC 7231 section 4.2.2 defines PUT as idempotent because the intended effect of a full replacement is the same whether it is sent once or many times, and it names DELETE as idempotent because repeating a delete leaves the resource absent; a second DELETE returning 404 does not change server state. The Idempotency-Key convention makes a retried POST safe by returning the stored original response instead of re-running the operation. The PATCH claim is wrong because RFC 5789 explicitly says PATCH is not required to be idempotent; a particular patch document may happen to be idempotent, but that is a property of the document, not a method-level guarantee. The JSON Patch claim is wrong because an add to /tags/- appends on every application, so applying it once yields ['vip'] and applying it twice yields ['vip','vip'], which differ.
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.
Practise these until they stick
That's every question we hold on this topic, and the page marks what you pick. What it can't do is remember. A free account keeps every answer, and what you miss comes back until it's right: after a day, then at longer gaps.
Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan