liveBook · Manning

PATCH

As explained in The Design of Web APIs, Second Edition

PATCH is the HTTP method for applying partial modifications to an existing resource.

PATCH applies partial modifications to an existing resource. A consumer sends only the properties that change, rather than reconstructing the complete resource as with replacement-oriented PUT. section 4.3.1 section 5.3.4

Updating a product

Use PATCH /products/{productReference} with a modification model whose properties are optional. For example, changing a transaction’s review state can use {"checked": true}; a product update might send only a new price and description. The successful response returns the product’s new state. section 5.3.4 section 13.5.5

Choose PATCH when these trade-offs fit the operation:

  • Prefer PATCH when transmitting or processing the complete resource would create meaningful cost at scale. section 13.5.5
  • Restrict the modification schema to properties that are permitted to change; creation-only data such as a supplier may remain immutable. section 5.3.4
  • Treat PUT and PATCH as interchangeable only at an early design stage; PUT may be simpler, while PATCH communicates partial modification more directly. section 4.3.4
  • Avoid blindly replaying PATCH requests because identical replays are treated as non-idempotent and can jeopardize data integrity. section 12.5.2
Figure 4.8 Refer to this mapping when in doubt about choosing an HTTP method for an action. CRUD stands for create, read, update, delete.
figure

Use the CRUD-to-HTTP mapping to distinguish PATCH’s update role from POST, GET, PUT, and DELETE. section 4.3.1

PATCH commonly uses JSON Merge Patch (RFC 7396), while JSON Patch (RFC 6902) is an alternative. Adding or removing PATCH operations affects compatibility: removal can produce 405 Method Not Allowed, whereas adding PUT alongside PATCH is backward compatible. section 5.3.4 section 15.2.4

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains request models, efficiency, formats, replay risks, and compatibility, but defers detailed implementation behavior.
Examples
Uses product price and description changes, transaction checking, optional modification schemas, and PATCH endpoint removal.
What it assumes
Assumes familiarity with HTTP resources and CRUD while establishing PATCH’s relationship to PUT and update models.
What you can do after
Operate/configure PATCH endpoints with partial schemas, suitable payloads, replay precautions, and compatible method changes.
How it connects
Connects PATCH to HTTP methods, CRUD, PUT, JSON Merge Patch, JSON Patch, idempotency, and backward compatibility.

Also explained in

Compare how 4 books explain PATCH →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.