PATCH vs PUT: Partial vs Full Updates
What you'll learn: You'll understand when to use PATCH for modifying specific fields versus PUT for replacing entire resources in REST APIs.
The Core Difference
When updating resources in a REST API, you have two HTTP verbs: PUT and PATCH. Think of PUT like replacing an entire document in a filing cabinet—you remove the old one completely and insert a brand new one. PATCH is like using correction fluid on specific words—you only change what needs fixing while leaving everything else intact.
PUT expects you to send the complete resource representation. Even if you're only changing one field, you must include all other fields. The server replaces the entire resource with what you send.
PATCH allows partial updates. You send only the fields you want to modify, and the server updates just those specific parts while preserving everything else.
When to Use Each
Use PUT when:
- The client has the full, current state of the resource
- You want to ensure complete replacement (avoiding partial update errors)
- Your API design treats updates as "set the resource to exactly this"
Use PATCH when:
- Clients need to modify one or a few fields without fetching the entire resource first
- Bandwidth or payload size matters
- The resource is large, and sending everything is inefficient
- You want clearer intent: "change only these fields"
Practical Impact
Imagine updating a user profile. With PUT, changing just the email requires sending name, email, bio, preferences—everything. With PATCH, you send only {"email": "new@example.com"}. This is more efficient and clearer in intent.
Key Takeaway: Use PUT for complete resource replacement (send everything), and PATCH for partial modifications (send only what changes). PATCH is more efficient for selective updates, while PUT ensures full state consistency.