HTTP PATCH: Apply partial changes without treating them as replacement
PATCH asks a server to apply a change document to the current resource; PUT supplies a representation to replace it. PATCH body semantics depend on the media type and API contract, so sending only some fields does not imply the same merge behavior everywhere. RFC 5789 requires the server to apply a patch atomically: all changes succeed or none do.
PATCH asks a server to apply a change document to the current resource; PUT supplies a representation to replace it. PATCH body semantics depend on the media type and API contract, so sending only some fields does not imply the same merge behavior everywhere. RFC 5789 requires the server to apply a patch atomically: all changes succeed or none do.
For edits based on a previously read version, send a strong ETag with If-Match when the API supports it. A failed precondition means reread the resource and reconcile the change. This prevents some lost updates; atomicity alone does not resolve concurrent edits.
Choose and verify the patch format
PATCH has no universal body format. Use a media type supported by the resource. An OPTIONS response may advertise accepted types in Accept-Patch; API documentation is another source. Allow may list PATCH without identifying accepted formats.
JSON Patch uses application/json-patch+json and an ordered list of operations such as add, remove, replace, move, copy, and test. JSON Merge Patch uses application/merge-patch+json: object members merge recursively, null removes a member, and arrays are replaced as a whole. Merge Patch may not fit models where explicit null is meaningful.
Before sending a request, verify the resource permits PATCH, field omission/deletion rules, concurrency conditions, all-or-nothing failure behavior, retry safety, authentication, and field-level authorization. PATCH itself is not idempotent, although a particular patch may be designed to be. A success may return 200 with a representation or 204 without one; follow the API contract and verify the resulting representation or ETag.
Sources
[RFC 5789: PATCH Method for HTTP](https://www.rfc-editor.org/rfc/rfc5789.html)
[RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html)
[RFC 6902: JSON Patch](https://www.rfc-editor.org/rfc/rfc6902.html)
[RFC 7396: JSON Merge Patch](https://www.rfc-editor.org/rfc/rfc7396.html)