PATCH

HTTP PATCH

SafeNo
IdempotentNo
CacheableNo
Request bodyYes
Response bodyYes

Overview

PATCH applies a partial update to a resource. Only the sent fields change and the rest stay intact, in contrast to PUT which replaces the whole thing.

Details

A PATCH body is a set of change instructions. Two formats are common — JSON Merge Patch (`application/merge-patch+json`), which carries only the fields to change, and JSON Patch (`application/json-patch+json`), which lists operations.

PATCH is not guaranteed idempotent by spec. A relative operation like 'increment by 1' yields different results if sent twice. Designing with absolute values (merge patch) makes it effectively idempotent, and `If-Match` guards against conflicts.

Request / Response example

Request
PATCH /api/users/42 HTTP/1.1
Host: api.example.com
Content-Type: application/merge-patch+json

{ "name": "Ada L." }
Response
HTTP/1.1 200 OK
Content-Type: application/json

{ "id": 42, "name": "Ada L.", "email": "ada@example.com" }

In code

curl -X PATCH https://api.example.com/api/users/42 \
  -H 'Content-Type: application/merge-patch+json' \
  -d '{"name":"Ada L."}'
await fetch('/api/users/42', {
  method: 'PATCH',
  headers: { 'Content-Type': 'application/merge-patch+json' },
  body: JSON.stringify({ name: 'Ada L.' })
});

Common mistakes

Typical status codes

Related methods

Related headers