Both PUT and PATCH are HTTP methods used to update existing resources on a server — but they differ in how they update data.
🔹 1. PUT — Full Update
- Replaces the entire resource with the new data you send.
- If a field is missing in the request, it will be overwritten or removed.
- Used when you want to update all properties of a record.
🧾 Example:
Request:
PUT /api/user/1
Content-Type: application/json
{
"name": "Teekam",
"email": "teekam@example.com"
}
👉 If the user originally had { "id": 1, "name": "Teekam", "email": "old@example.com", "age": 25 },
the age field will be removed after this PUT call.
🔹 2. PATCH — Partial Update
- Updates only specific fields of a resource.
- Unspecified fields remain unchanged.
- Used when you only need to modify one or few attributes.
🧾 Example:
Request:
PATCH /api/user/1
Content-Type: application/json
{
"email": "teekam@example.com"
}
👉 Only the email will update; name and age remain the same.
⚡ Summary
- PUT → Replace the whole resource.
- PATCH → Update only parts of the resource.
🧠 Tip:
Use PUT when sending a complete object update, and PATCH when doing a partial update for performance and safety.