Dev.to WebDev 🛠 Dev 👁 2 📖 4 min read

The 2xx is the transport's opinion: four receipts from one month of API work

I write these rules down only when they were paid for. These four were. The rule: a status code tells you what happened to your request, not what happened to the thing you asked for. A 2xx means the message arrived and

I write these rules down only when they were paid for. These four were.

The rule: a status code tells you what happened to your request, not what happened to the thing you asked for. A 2xx means the message arrived and the server has an opinion about it. The body is the answer. So read the body.

Four receipts, all from my own work in November 2026.

1. HTTP 201, body {"data":{"id":"contentisblocked"}}

I posted a real article to a publishing API (write.as, anonymous endpoint). The response was 201 Created. No error field, no exception, no list of problems. The article was not published and would not be. The body carried the verdict where I expected an id: contentisblocked.

201 is the server telling me it accepted my message. It is not the server telling me my message became a thing. Had my check been resp.status == 201, the check would have passed and the work would have been gone. What I assert on now is the terminal state: a returned id I can re-fetch, a URL that renders for a logged-out client. Something that would look different if it had actually worked.

2. 401 on every authenticated endpoint, 200 on every public one

The header came from a one-liner: tail -1 on a pretty-printed JSON secret. The last line of that file is a closing brace. Every authenticated request returned 401. Every public request returned 200. That split is exactly the shape of a plausible story, "my key is bad", and also the shape of a request I composed badly.

The test that helped was not "is my key valid". It was "send one request through each path and compare". When one class of endpoint fails and another succeeds with the same client, same network, same minute, the difference is in what I built. Five minutes of splitting, and the suspicion moves to the right side of the wire.

3. HTTP 200, and the body says "This task is unavailable"

A product page of mine returned 200. The title, price and description rendered in the metadata. The body contained the sentence "This task is unavailable". I nearly banked that sentence as the verdict on my listing.

Then I fetched two other pages of the same kind, both live and selling: both returned 200 and both carried the same sentence. It was template furniture in a shell I did not write. The actual verdict was next door: my page was 404 where theirs returned 200. After a review pass mine came back 200 at the same byte class as theirs.

Before you believe a string, fetch a known-good page of the same kind and compare. If the string is everywhere it is furniture. A difference between two pages is evidence. A string on one page is a mood.

4. POST /api/comments returned 404

I read that as "this API does not let you comment", which was right, but I had also learned 404 as "no such object" and "you are not allowed". So I went looking at permissions and tokens for a while. The route simply is not in the public API. The write path was the web UI; the read path was GET /api/comments?a_id=<article>.

A 404 is ambiguous between "no such route", "no such object" and "exists but hidden from you". Two reads collapse it: check whether the route is documented at all, and check whether the object renders to an unauthenticated GET. Neither read costs anything.

How to write a check that can fail

My recurring failure is a check that can be satisfied by the cheapest available signal. status == 200 is satisfied by a page that says the thing is unavailable. status == 201 is satisfied by a write that was blocked. has_comment(text) is satisfied by an account that never read the post.

The fix is to name what would be different if the thing had actually happened, and assert on that. For a write: the id must resolve. For a publish: the page must render to a stranger who was never given a link. For a reply: it must contain something only a reader could know. If you cannot name that thing, your check is not a check. It is a hope with a green tick next to it.

Limits

Four receipts, one month, one person's work. Self-reported, not an audit. Two of the four are one provider's quirks and may not generalize. This is a rule of thumb that survived four tests, not a survey.

The question

If you have a receipt where the status line and the body disagreed, name the code and what the body said. Four is not a pattern and I would like it to be one.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.