Agent Wranglers

Requests and responses Recommended

Say which format PATCH accepts

Accept PATCH bodies in one documented patch format, and name it in the Content-Type header.

How to do it

Use JSON Merge Patch from RFC 7396 for simple updates, served as application/merge-patch+json. In it, a field set to null is removed and missing fields stay unchanged. Use JSON Patch from RFC 6902 when clients must edit lists. List the formats in the Accept-Patch header, as RFC 5789 describes. Answer 415 to any other type.

Example

PATCH /orders/ord_8f2k HTTP/1.1
Content-Type: application/merge-patch+json
If-Match: "v7"

{"note":"Leave at the door","giftWrap":null}

How to check

A PATCH that changes one field leaves every other field unchanged. A PATCH sent as text/plain gets 415 with Accept-Patch.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers api design playbook: https://agentwranglers.se/playbook/api-design/requests-and-responses/patch-format.