Dung (Donny) Nguyen

Senior Software Engineer

PUT and PATCH in RESTful APIs

Both PUT and PATCH are HTTP methods used in RESTful APIs to update resources, but they have some key differences:

PUT

PUT /users/123
{
  "name": "John Doe",
  "email": "john.doe@example.com",
  "age": 30
}

PATCH

PATCH /users/123
{
  "email": "john.newemail@example.com"
}

In summary, use PUT when we need to replace the entire resource and PATCH when we only need to update specific fields.