Blog

PUT vs PATCH: The Difference That Breaks More APIs Than It Should

September 17, 2026Xerat024 min read
Share
PUT vs PATCH: The Difference That Breaks More APIs Than It Should

Ask a room of backend developers "what's the difference between PUT and PATCH" and most will say some version of "PUT replaces, PATCH updates." That's directionally right and specifically wrong enough to cause real bugs, because the actual distinction isn't about how much of the resource changes — it's about what a client is allowed to assume happens to the fields it didn't send.

What each one actually promises

A PUT request, per RFC 9110, asks the server to store the enclosed representation as the complete state of the target resource. Anything not in the body isn't merged — it's gone. Send PUT /users/42 with {"name": "Ada"} on a user that also has an email field, and a spec-compliant server drops the email, because a PUT body is supposed to be the whole resource, not a diff.

PATCH, defined separately in RFC 5789, asks the server to apply a set of changes described in the body — everything not mentioned stays exactly as it was. PATCH /users/42 with {"name": "Ada"} only touches name.

That's the real rule: PUT is "this is now the entire resource," PATCH is "apply this diff." Whether the diff happens to touch one field or all of them is irrelevant to which verb is correct.

Where the confusion actually bites

The bug this produces in practice: a frontend built against a partial form — "edit display name" — sends PUT because "PUT feels more official," includes only the field the form actually has, and the API dutifully treats the missing fields as intentionally cleared. Nothing errors. The response is a clean 200. The user's avatar URL, preferences, and phone number just silently disappear, and the bug report that eventually shows up says "my profile keeps resetting," which is a much harder trail to follow back to "someone used the wrong verb" than the actual cause deserves.

The fix isn't complicated once you see it: a form that only edits a subset of fields should send PATCH. PUT is for a client that has, and intends to send, the resource's complete current representation — a "load the whole object into a form, edit it, save the whole thing back" flow, not a "change this one field" flow.

Idempotency is the other place people get it wrong

PUT is idempotent by definition — the spec requires it, and it's genuinely useful: a client that isn't sure whether its PUT request actually landed can safely retry it, because sending the same complete representation twice produces the same end state as sending it once.

PATCH is not guaranteed idempotent by its spec, and it's worth being precise about why: it depends entirely on what the patch describes. "Set status to shipped" is idempotent — replay it as many times as you want, the end state is identical. "Increment the view counter by 1" or "append this item to the array" is not — replaying it changes the outcome every time. The verb doesn't decide idempotency; the semantics of the specific patch operation do. A team that assumes "PATCH is safe to retry" because "PUT is idempotent and PATCH is basically PUT" is one retried request away from double-incrementing something.

What a real PATCH body looks like

Unlike PUT, which just takes the resource shape directly, PATCH doesn't mandate a body format — RFC 5789 leaves that to the media type. Two are common enough to know by name: JSON Merge Patch (RFC 7396), which is just "send the fields you want changed, null to delete one" — simple, but can't always distinguish "set this field to null" from "delete this field" — and JSON Patch (RFC 6902), which is a list of explicit operations (add, remove, replace, test) against JSON Pointer paths, more verbose but unambiguous about exactly what changed. Most APIs that call themselves "PATCH" are actually doing a Merge Patch without naming it, which is fine for simple resources and gets awkward fast once you need to distinguish "unset this field" from "leave this field alone."

Testing the difference on purpose

The failure mode above — a PUT silently wiping fields a client didn't think to include — is exactly the kind of thing that's easy to miss in manual testing (you always send the fields you're thinking about) and easy to catch with a route that actually behaves like the real API would: stateful CRUD routes handle PUT's full-replace and PATCH's partial-merge with the real semantics, not a single "update" handler pretending they're interchangeable — so a client sending a partial PUT against a mock shows the same field-loss a real backend would produce, before it ships anywhere near production data.

X

Xerat02

Building MockBase.