API Fundamentals Course
API Fundamentals
/
Intermediate

PUT

Definition

An HTTP method used to UPDATE an existing resource by completely replacing it with the new data provided in the request payload.

Explain Like I'm New

If you use PUT to update a user's name, you must send their name, their email, their age, and their phone number. PUT takes the entire old record, throws it in the trash, and replaces it with the brand new record you just sent.

Real World Example

Updating a user's entire profile settings page. When they click 'Save', the frontend sends every single setting (even the ones they didn't change) to completely overwrite the database row.

Common Use Cases

  • Full resource replacements

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • What is the main difference between PUT and POST?

intermediate

  • Is a PUT request Idempotent?

Flash Cards

Question

PUT vs POST?

Click to reveal answer
Answer

POST is for creating entirely new things. PUT is for updating/replacing existing things.

Question

Is it Idempotent?

Click to reveal answer
Answer

Yes! If you send a PUT request saying 'Set age to 25', doing it 1 time sets the age to 25. Doing it 100 times still just leaves the age at 25. The end state is the same.