DEV Community

Rençber AKMAN
Rençber AKMAN

Posted on

🔍⭐What is the difference between POST and PUT?

Both POST and PUT are used to send data to the server, but their purposes and typical use cases are different.

POST is usually used to create new data. For example, when submitting a user registration form, we use POST. The server creates a new user.

PUT is used to update existing data. For instance, if we want to change a user’s email address, we use PUT.

One key difference is:

POST can create a new record every time it is called (like a new object with a different ID).

PUT updates the content of an existing record with a specific ID, keeping the ID the same.

✅In short: → POST = Create. → PUT = Update.

Top comments (2)

Collapse
 
tracygjg profile image
Tracy Gilmore

Another related question is "What is the difference between PUT and PATCH?"

Collapse
 
rencberakman profile image
Rençber AKMAN

Since I’m still learning, it never occurred to me and I hadn’t looked it up. Thank you so much for asking this question. I’m going to start researching it right away.