100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
API Design & Best Practices
30 minintermediate

HTTP Methods, Status Codes and Semantics

A `PUT` request that quietly creates a resource on its first call and simply updates it on a retry looks identical from a monitoring dashboard whether it ran once or three times — right up until it wasn't, and a client library's automatic retry on a bare `POST` created the same order twice because a load balancer timed out waiting for a response that had actually already succeeded. The decisions this lesson covers — which HTTP method, which status code — read like a vocabulary problem, something you look up once in a table and never think about again. They are not. They are the actual mechanism by which a piece of infrastructure that has never seen your business logic — a load balancer, a retrying SDK, a message queue — can decide, correctly and automatically, whether it's safe to resend a failed request. Get the vocabulary wrong and that decision gets made wrong, invisibly, until the exact moment a network hiccups in production.

Most engineers can recite that GET is for reading and DELETE is for deleting; the actual failure mode in this lesson lives one level deeper, in three specific places teams consistently get subtly wrong: conflating "idempotent" with "has no side effects" as though they were the same guarantee, reaching for `200 OK` on every success regardless of what kind of success it was, and treating `PATCH` as though the method name alone told a server how to interpret a partial request body. None of these mistakes look wrong in a code review. All three become real incidents the first time a network behaves the way real networks actually behave.

This lesson works through the distinction between safety and idempotency precisely enough to apply under pressure, the concrete difference between `200`, `201`, `202`, and `204` and when each is the honest choice, and why `PATCH` cannot be implemented correctly without first choosing, explicitly, what its request body actually means.

Analogy🏏Cricket
🏏 Think of it like cricket: Asking the third umpire to replay a contentious catch a second time, or a fifth time, doesn't change what actually happened on the field — the ball either carried or it didn't, and reviewing footage has zero effect on the match state, so it's completely free to repeat as many times as anyone needs. Signalling an actual bowling change is a different category of action entirely: a captain can't casually repeat that signal to be sure it registered, because calling for a bowling change twice means two different bowlers genuinely got handed the ball, and whatever happened in the over bowled in between the two signals cannot be undone by a third signal correcting course. Somewhere between those two is stopping play for bad light — an umpire re-signalling "stop play" a moment after the first signal, because a nervous fourth official wasn't sure it registered, doesn't make the match "more stopped"; play was already halted, and the second signal converges on the exact same state as the first, even though stopping play very much did change something. Just as reviewing a replay is safe to repeat because nothing about the match state moves at all, a `GET` request is safe to repeat because it changes nothing on the server. Just as re-signalling a bowling change genuinely creates a second, unwanted event, retrying a `POST` without protection genuinely creates a second, unwanted resource. The insight is that these are two separate questions — does this action change anything, and does repeating it change anything further — and conflating them is exactly how a system ends up treating an unsafe action as if it were harmless to retry.
Lesson 4 of 35
0% complete