When an API returns 200 but does nothing, it has usually dropped part of your request without telling you: a misspelt field, a value it could not use, an id that matched nothing. RFC 9110 says a 200 indicates that the request has succeeded. Our own first API gave that answer to eight requests that had not succeeded at all, and we only found out by sending them on purpose.

Eight requests where our API returned 200 but did nothing

Mosaic has a local REST API at /api/v1, and our build already checked that every route existed. Nothing checked what a route did with a bad request. So we sent bad requests to the running app, before fixing anything, and wrote down what came back:

PATCH /settings {"apiPort": "not-a-number"}  200, and it stored the string
PATCH /settings {"theme": "chartreuse"}      200
POST  /projects {}                           500 "…undefined (reading 'trim')"
POST  /proxies/parse {"text": 12}            500 "text.split is not a function"
POST  /proxies {"host":"h","port":70000}     200, stored, failed at launch
POST  /profiles {"count": "abc"}             200 carrying undefined
POST  /profiles/bulk/delete {}               200 {"deleted": 0}
DELETE /profiles/does-not-exist              200 {"deleted": true}

Every row tells the caller something worked when it did not. The apiPort row could have bricked the app: the next start would have tried to listen on a string. The port of 70000 was saved, shown as a working proxy and failed only when somebody launched a profile behind it, far from the request that caused it.

The last two are the worst. A delete that deleted nothing and a delete of a misspelt id both came back as success, byte-identical to a real one. From outside, there was no way to see the bug.

Everything the window does, from a script on your own computerIn Mosaic: REST API. Everything the window does, from your own scripts. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

How it works: REST API

Why "be liberal in what you accept" fails here

The usual argument for ignoring an unknown field is forward compatibility: an old server should not choke on a newer client's extra key. That argument assumes the extra key is harmless. In a settings call it is the opposite.

Take PATCH /settings with maxConcurentProfiles, one r short. A server that drops it answers 200. The caller now believes a cap on running browsers is in force, and it is not. Nothing will ever tell them, because the next read of settings shows the old value and nobody reads settings back after writing them.

The three rules

All three live in one file, validate.ts, which every REST route goes through.

  1. An absent field is not an invalid one. Our bodies are PATCH-shaped, so leaving a key out leaves that value alone. Only a key that is present and wrong is an error. That is what lets a caller send one field without restating the rest.
  2. Never silently repair. Clamping -1 to 1 leaves the caller believing something untrue about what was stored. Refuse, and name the field and the reason.
  3. An unknown key is an error, not something to drop. PATCH /settings with maxConcurentProfiles now returns a 400 that lists the real setting names.

The second rule is the one people argue with, because a repair feels helpful. It is helpful to the person who sent -1 by accident and saw nothing. It is harmful to the script that sent -1 meaning something, and to everyone who later reads the stored value and trusts it.

A 500 is our bug

Two rows in the table were 500s with messages like Cannot read properties of undefined (reading 'trim'). That sentence describes a line in our code. It means nothing to the caller, and it told them their request had broken the server when their request was simply missing a name.

So the handler now does two different things. A 4xx message is written for the caller and passed through untouched: it says which field and what to send. A 500 is logged in full on our side, and the caller gets one sentence saying it was an internal error. If a message tells the caller what to do, it is a 400, never a 500.

The same lie in a batch

The single request is the easy case. A batch can tell the same lie at scale. Warm-up runs one plan across many profiles, and "warmed 40 profiles" over eight failures is a 200 that did nothing, eight times, in a run nobody watched. Every profile in a batch now gets a row with its name and whether it worked, and one dead proxy costs its own row rather than the batch.

Closing a browser had the same fault in a quieter form. Two of the code paths that trash a profile stopped its browser with .catch(() => undefined), which turns "it would not close" into a clean success. The profile vanished from the list while its window stayed open on its proxy. A stop that fails now costs the trash: the profile stays on the list, where it still has a Stop button.

How we keep it fixed

A script sends the whole matrix, forty-odd malformed requests and the shape of every collection, to a running app, and fails if any comes back as a success. It is not part of the normal build, because a check that needs a running app should not be able to fail a build for the wrong reason, so we run it by hand after API changes.

The same rules hold on MCP, the API's other door, where a model is the caller and cannot ask what an error meant; letting an AI assistant run browser profiles has the three faults a model found. The routes themselves are listed on the REST API page, and what a local API in this kind of browser should and should not do is in the anti-detect browser local API guide.