Sobes.tech
Junior

What is the difference between the PUT, POST, and PATCH methods?

sobes.tech AI

Answer from AI

PUT is used to create or completely replace a resource at the specified URL. If the resource exists, it will be fully overwritten with the provided data. If it does not exist, a new resource will be created. It is an idempotent method.

POST is used to send data to the server for processing. This can be creating a new resource, submitting form data, or performing some operation. The URL usually points to a "collection" to which the action applies. It is not idempotent.

PATCH is used for partial modification of a resource. Instead of sending a complete representation of the resource, only the data that needs to be changed is sent.

Method Purpose Idempotent
PUT Create / Replace Yes
POST Create / Process No
PATCH Partial update No (usually)