Repaso
EspaƱol
Backend & APIsCoreAPI-02

What is the difference between PUT and PATCH?

Options

  1. PUT creates a resource; PATCH deletes a resource
  2. PUT replaces the whole resource; PATCH updates part of it (Correct option)
  3. PATCH is idempotent by definition, but PUT is not
  4. There is no difference, both update in the same way

Answer

PUT replaces the whole resource; PATCH applies a partial update

Why

PUT sends the COMPLETE new version of a resource and replaces the old one. Fields you leave out may be reset.

PATCH sends only the fields that change, e.g. {"email": "new@x.com"}.

PUT is idempotent; PATCH is not guaranteed to be (e.g. 'add 1 to counter').

Remember

PUT = replace all. PATCH = change some fields.

Key terms

Practice this question in Repaso