API Style & Pattern Comparisons

Side-by-side trade-offs. Neither column wins — the consumer environment, the data shape and the operational budget decide.

PUT (replace) vs PATCH (partial update)

Send the whole resource and mean "make it exactly this" vs send only the changes and mean "modify these fields" — a difference in idempotency, payload and failure modes, not style.

PUT (replace)Open lesson →
Use when

The client naturally holds the full representation — an edit form that loaded the resource and now saves it.

Avoid when

Clients only know the fields they're changing — a full PUT forces a read-modify-write round trip first.

Strengths

Naturally idempotent: replaying the same PUT converges on the same state; simple mental model.

Fails when

A client built against an older schema PUTs the fields it knows — silently erasing every field added since.

Operational cost

Full payloads on every update; clients must stay current with the complete schema to avoid destructive writes.

PATCH (partial update)Open lesson →
Use when

Resources are large or contended and clients change one or two fields: toggling a flag, renaming, changing status.

Avoid when

The merge semantics are undefined — what null means, how arrays merge — so every client guesses differently.

Strengths

Small payloads, no full read required, expresses intent field by field.

Fails when

null-vs-absent is unspecified, so "clear this field" and "I didn't mention this field" collide in one representation.

Operational cost

A documented merge specification (JSON Merge Patch or your own rules) plus tests for the null/absent/array cases.

DimensionPUT (replace)PATCH (partial update)
IdempotencyYes by definition — same body, same resultUsually, but "append to array" style patches break it
PayloadEntire resource every timeOnly the changed fields
Silent-erasure riskHigh — omitted fields are removedLow — omitted fields are untouched
null vs absentMoot — everything is presentThe core design decision; must be specified
Concurrency pairingIf-Match strongly advised — replaces blow away concurrent editsNarrower writes collide less, but versioning still applies