What is the difference between PUT and PATCH?
PUT replaces an entire resource with the data you send, while PATCH updates only the specific fields you include. If you PUT a user but leave out the email, the email can be wiped, because PUT means replace the whole thing. PATCH is safer for partial updates because it only touches the fields you provide.
- PUT replaces an entire resource with the data you send.
- PATCH updates only the specific fields you include.
- PUT is idempotent, and PATCH usually is but does not have to be.
A simple example
Say a user has a name and an email. To change only the email, PATCH lets you send just the email field. With PUT you should send the full user object, because anything you leave out may be reset.
PATCH /users/42
{ "email": "new@site.com" } // only email changes
PUT /users/42
{ "name": "Ann", "email": "new@site.com" } // full replace
The clean summary interviewers want is PUT replaces the whole resource and PATCH updates part of it. Adding that PUT is idempotent while PATCH may or may not be earns extra credit.
Frequently asked questions
When should you use PATCH instead of PUT?
Use PATCH when you want to change a few fields without sending the whole resource, which saves bandwidth and avoids overwriting untouched fields.
Is PATCH idempotent?
It can be, but it is not guaranteed. A patch that sets a field to a fixed value is idempotent, while one that increments a value is not.
Common follow up questions
Related interview questions
Want the full API Design guide?
Read every API Design concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the API Design guide All API Design questions